HACKS revision 1.36
11.36She# $NetBSD: HACKS,v 1.36 2004/06/06 17:11:33 he Exp $
21.1Slukem#
31.1Slukem# This file is intended to document workarounds for currently unsolved
41.1Slukem# (mostly) compiler bugs.
51.1Slukem#
61.1Slukem# Format:
71.1Slukem#   hack		title
81.1Slukem#   cdate		creation date
91.1Slukem#   mdate		mod date
101.1Slukem#   who			responsible developer
111.1Slukem#   port		...
121.1Slukem#  	  affected ports, space separated, if not "all"
131.1Slukem#   file		affected file : revision : line from : line to
141.1Slukem#  	  affected files and revision and line numbers describing hack
151.1Slukem#  	  multiple lines if necessary.
161.1Slukem#   pr			NNNN ...
171.1Slukem#  	  problem reports this hack works around, if known. Space
181.1Slukem#  	  separated.
191.1Slukem#   regress		src/regress/directory/where/test/found
201.1Slukem#  	  regression test directories, if available.
211.1Slukem#   descr
221.1Slukem#  	  insert short informal description (multi-line). (Longer ones
231.1Slukem#  	  should be in the PR database. More formal descriptions might
241.1Slukem#  	  be in the regress tree. See above).
251.1Slukem#   kcah
261.1Slukem#  	  closing bracket.
271.1Slukem#
281.1Slukem# this is a comment.
291.1Slukem
301.1Slukemhack	netstat ieee1394 address printing.
311.1Slukemmdate	14 Nov 2000
321.1Slukemwho	matt
331.1Slukemfile	lib/libc/net/getnameinfo.c	: 1.32 : 497 : 503
341.1Slukemdescr
351.1Slukem	Because the current implementation of IP over IEEE1394, the
361.1Slukem	fw device address contains more than just the IEEE1394 EUI-64.
371.1Slukem	So when printing out IEEE1394 addresses, ignore the extra stuff.
381.1Slukemkcah
391.1Slukem
401.1Slukemhack	xterm vs. libterm
411.1Slukemmdate	01 Aug 2000
421.1Slukemwho	jdc
431.1Slukemfile	xsrc/xc/programs/xterm/main.c	: 1.2 : 3609 : 3614
441.1Slukempr	10383
451.1Slukemdescr
461.1Slukem	In order to extend the termcap string over 1023 bytes, a ZZ entry was
471.1Slukem	introduced to point to a memory location containing the full entry.
481.1Slukem	Without this hack, xterm will export a termcap containing the ZZ
491.1Slukem	entry, which will then be ignored by libterm.  As xterm modifies the
501.1Slukem	exported termcap, this would cause those modifications to be ignored.
511.1Slukemkcah
521.1Slukem
531.1Slukemhack	wi-at-big-endian-bus
541.1Slukemcdate	15 Mar 2002
551.1Slukemwho	martin
561.1Slukemfile	dev/ic/wireg.h
571.1Slukemdescr	Add an option to access the underlying bus in big endian byte order
581.1Slukem	to work around deficiencies in bus_space_{read,write}_* macros.
591.1Slukem	Those don't allow the implementation of a proper pcmcia bus space
601.1Slukem	tag.
611.1Slukemkcah
621.1Slukem
631.3Sjdchack	specific knowledge of colours in curses code
641.3Sjdccdate	Sun Apr  6 11:05:24 BST 2003
651.3Sjdcwho	jdc
661.3Sjdcfile	lib/libcurses/color.c : r1.24
671.3Sjdcdescr
681.3Sjdc	Swap red/blue and yellow/cyan colours for COLOR_OTHER.
691.3Sjdc	Fix is to enhance libtermcap to understand terminfo-style % sequences.
701.3Sjdc	See also:
711.5Ssalo	    http://mail-index.NetBSD.org/tech-userlevel/2003/04/06/0000.html
721.4Sscwkcah
731.4Sscw
741.7Shehack	Compensation for differing types of LINUX_USRSTACK and USRSTACK
751.7Shecdate	21 Aug 2003
761.7Shewho	he
771.7Shefile	sys/miscfs/procfs/procfs_linux.c : 1.14
781.7Shedescr
791.7She	Not all ports have LINUX_USRSTACK and/or USRSTACK defined as
801.7She	literals/constants, but refer to variables of a type which is
811.7She	not "unsigned long", causing compilation of procfs_linux.c to
821.7She	fail with "makes integer from pointer without a cast".  This
831.7She	is observed on e.g. the sun3 port.  Ideally the "types" for
841.7She	symbols should be consistent across all ports.
851.25Smrgkcah
861.25Smrg
871.25Smrghack	GCC2 isn't C99
881.25Smrgcdate	5 December 2003
891.25Smrgwho	mrg
901.25Smrgfile	gnu/dist/binutils/ld/ldlex.c: r1.2
911.25Smrgdescr
921.25Smrg	ldlex.c is generated from ldlex.l and we get macro redefinition
931.25Smrg	errors from it if __STDC_VERSION__ is not C99 compliant.  This
941.25Smrg	hack forces NetBSD 1.6 and later systems to also include <stdint.h>
951.25Smrg	to get the relevant definitions.  This hack should be backed out
961.25Smrg	when all platforms have switched away from GCC2.
971.11Slukemkcah
981.11Slukem
991.13Ssimonb
1001.21Smycroftport	vax
1011.21Smycroft
1021.21Smycroft	hack	gcc 2.95/vax cannot handle __builtin_ffs()
1031.21Smycroft	cdate	Fri Aug 23 21:31:15 CEST 2002
1041.21Smycroft	who	ragge
1051.21Smycroft	file	sys/lib/libkern/libkern.h : 1.42
1061.21Smycroft	descr
1071.21Smycroft		__builtin_ffs() is ifdef'd away if __vax__. Matt Thomas has
1081.21Smycroft		added this feature to GCC 3 so it can be removed when switching.
1091.21Smycroft	kcah
1101.21Smycroft
1111.21Smycroft	hack	gcc-vax-libbz2
1121.21Smycroft	mdate	27 Jun 2002
1131.21Smycroft	who	thorpej
1141.21Smycroft	file	lib/libbz2/Makefile
1151.21Smycroft	descr
1161.21Smycroft		libbz2 is mis-compiled with optimization with GCC 2.95.3
1171.24Sragge		on VAX.  -O0 works around this problem.
1181.24Sragge	kcah
1191.24Sragge
1201.24Sragge	hack	gawk
1211.24Sragge	mdate	8 Nov 2003
1221.24Sragge	who	ragge
1231.24Sragge	file	gnu/usr.bin/gawk/Makefile
1241.24Sragge	descr
1251.24Sragge		gawk is mis-compiled with optimization with GCC 2.95.3
1261.21Smycroft		on VAX.  -O0 works around this problem.
1271.21Smycroft	kcah
1281.21Smycroft
1291.21Smycroft	hack	vax Toolchain bug
1301.21Smycroft	cdate	28 Mar 2003
1311.21Smycroft	who	he
1321.21Smycroft	file	sys/arch/vax/vax/intvec.S : 1.5
1331.21Smycroft	descr
1341.21Smycroft		Workaround for PR toolchain/20924.  The assembler apparently
1351.21Smycroft		tries to range-check byte offsets when it doesn't have
1361.21Smycroft		sufficient information to make that decision.
1371.21Smycroft		Workaround uses `brw' instead of `brb' instruction.
1381.23She	kcah
1391.23She
1401.23She	hack	vax gcc 2.95.3 -Wuninitialized workarounds
1411.23She	cdate	6 Nov 2003
1421.23She	who	he
1431.23She	file	sys/dev/bi/if_ni.c : 1.22
1441.23She	file	sys/arch/vax/vax/ctu.c : 1.20
1451.23She	descr
1461.23She		Workaround for gcc 2.95.3 failing to detect that certain
1471.23She		variables will be initialized; so that this code compiles
1481.23She		with -Wuninitialized.  Should be reviewed and possibly
1491.23She		reverted when gcc 3.3.2 is ready for vax.
1501.21Smycroft	kcah
1511.21Smycroft
1521.34Scl	hack	vax gcc 2.95.3 structure initialization
1531.34Scl	cdat	13 May 2004
1541.34Scl	who	cl
1551.34Scl	file	sys/miscfs/kernfs/kernfs_vnops.c : 1.104
1561.34Scl	descr
1571.34Scl		Workaround for gcc 2.95.3 failing to initialize structures
1581.34Scl		and/or unions inside structures using nested designators.
1591.34Scl		Should be reverted when gcc >=3.3.3 is ready for vax.
1601.34Scl	kcah
1611.21Smycroft
1621.35She	hack	vax gcc 2.95.3 needs -I. to build nslexer.c
1631.35She	cdat	6 Jun 2004
1641.36She	who	mhitch
1651.36She	file	lib/libc/arch/vax/Makefile.inc : 1.6
1661.35She	descr
1671.35She		It appears necessary to add -I. to CPPFLAGS when building
1681.35She		nslesxer.c.  This may be caused by gcc 2.95.3 being used.
1691.35She		Should be reverted when a newer gcc is ready for vax.
1701.35She	kcah
1711.35She
1721.21Smycroftport	sparc64
1731.21Smycroft
1741.21Smycroft	hack	binutil-2.11-sparc64-pltrela
1751.21Smycroft	mdate	14 Aug 2001
1761.21Smycroft	who	eeh
1771.21Smycroft	file	libexec/ld.elf_so/arch/sparc64/mdreloc.c
1781.21Smycroft	descr
1791.21Smycroft		The first for PLT entries are reserved.  There is some
1801.21Smycroft		disagreement whether they should have associated relocation
1811.21Smycroft		entries.  Both the SPARC 32-bit and 64-bit ELF specifications
1821.21Smycroft		say that they should have relocation entries, but the 32-bit
1831.21Smycroft		SPARC binutils do not generate them, and now the 64-bit SPARC
1841.21Smycroft		binutils have stopped generating them too.
1851.21Smycroft
1861.21Smycroft		To provide binary compatibility, we will check the first entry,
1871.21Smycroft		if it is reserved it should not be of the type JMP_SLOT.  If it
1881.21Smycroft		is JMP_SLOT, then the 4 reserved entries were not generated and
1891.21Smycroft		our index is 4 entries too far, so we frob the rela pointer.
1901.21Smycroft	kcah
1911.21Smycroft
1921.21Smycroft
1931.21Smycroftport	arm
1941.21Smycroft
1951.21Smycroft	hack	gcc-unsigned-compare
1961.21Smycroft	cdate	09 Mar 2002
1971.21Smycroft	mdate	18 Mar 2002
1981.21Smycroft	who	bjh21
1991.21Smycroft	file	dist/bind/lib/nameser/ns_parse.c : 1.3
2001.21Smycroft	file	dist/dhcp/minires/ns_parse.c : 1.3
2011.21Smycroft	file	dist/dhcp/omapip/result.c : 1.2
2021.21Smycroft	file	dist/dhcp/server/failover.c : 1.3
2031.21Smycroft	file	gnu/dist/gawk/eval.c : 1.4
2041.21Smycroft	file	gnu/dist/toolchain/bfd/bfd.c : 1.2
2051.21Smycroft	file	gnu/dist/toolchain/bfd/format.c : 1.2
2061.21Smycroft	file	gnu/dist/toolchain/gdb/target.c : 1.2
2071.21Smycroft	file	sys/kern/vfs_subr.c : 1.172
2081.21Smycroft	descr	When checking that a potentially-unsigned enum is >= 0, assign
2091.21Smycroft		it to an int first.  This is necessary to avoid "comparison is
2101.21Smycroft		always true" warnings with -fshort-enums.  Casting to an int
2111.21Smycroft		really should be enough, but turns out not to be.
2121.21Smycroft	kcah
2131.21Smycroft
2141.21Smycroft	hack	gcc 3.3.2/arm sys/kern/uipc_socket.c
2151.21Smycroft	cdate	Tue Oct 28 18:02:16 GMT 2003
2161.21Smycroft	who	skrll
2171.21Smycroft	file	sys/conf/arm/Makefile.arm : 1.19
2181.21Smycroft	descr
2191.21Smycroft		Performing a build.sh tools on a CATS with NFS mounted 
2201.21Smycroft		obj and src directories results in "panic: receive 1"
2211.21Smycroft		The hack is to compile sys/kern/uipc_socket.c with
2221.21Smycroft		-fno-strict-aliasing
2231.21Smycroft	kcah
2241.21Smycroft
2251.21Smycroft
2261.13Ssimonbport	pc532
2271.16Scl
2281.21Smycroft	hack	egcs-pc532-ip6_mroute
2291.21Smycroft	cdate	09 Jul 2002
2301.21Smycroft	who	simonb
2311.21Smycroft	file	sys/arch/pc532/conf/Makefile.pc532 : 1.70
2321.21Smycroft	file	sys/arch/pc532/conf/files.pc532 : 1.47
2331.21Smycroft	descr
2341.21Smycroft		egcs 1.1.2 gets an "internal error--insn does not satisfy its
2351.21Smycroft		constraints" error compiling ip6_mroute.c with -O2 or greater.
2361.21Smycroft		-O1 works around this problem.
2371.21Smycroft	kcah
2381.21Smycroft
2391.21Smycroft	hack	gcc-pc532-duffs_device
2401.21Smycroft	cdate	Mon Oct 27 07:23:05 UTC 2003
2411.21Smycroft	who	simonb
2421.21Smycroft	file	sys/arch/pc532/conf/Makefile.pc532 : 1.71
2431.21Smycroft	file	sys/arch/pc532/conf/files.pc532 : 1.52
2441.21Smycroft	pr	GCC PR optimization/5230
2451.21Smycroft	descr
2461.21Smycroft		gcc incorrectly gives an "unreachable code at beginning of
2471.21Smycroft		switch statement" for a Duff's device construct in
2481.21Smycroft		arch/pc532/dev/ncr.c.  There is no way to disable just this
2491.21Smycroft		warning, so -Wno-error is turned on for this file.
2501.21Smycroft	kcah
2511.21Smycroft
2521.26Ssimonb	hack	gcc332-cppmacro-ice
2531.26Ssimonb	cdate	Sun Dec  7 12:48:33 UTC 2003
2541.26Ssimonb	who	simonb
2551.26Ssimonb	file	gnu/usr.bin/gcc3/libcpp/Makefile : 1.2
2561.26Ssimonb	descr
2571.26Ssimonb		gcc 3.3.2 gets an ICE when compiling cppmacro.c with -O2.
2581.26Ssimonb		The hack is to use -O1 for this file.  Fixed in gcc
2591.26Ssimonb		-current mainline, unable to work out where the fix is
2601.26Ssimonb		right now.
2611.26Ssimonb	kcah
2621.26Ssimonb
2631.21Smycroft
2641.21Smycroftport	sh3
2651.21Smycroft
2661.21Smycroft	hack	gcc-sh3-sed
2671.21Smycroft	mdate	23 Apr 2002
2681.21Smycroft	who	thorpej
2691.21Smycroft	file	usr.bin/sed/Makefile	: 1.9 : 9 : 13
2701.21Smycroft	descr
2711.21Smycroft		The in-tree GCC 2.95.3-based compiler ICEs when building
2721.26Ssimonb		with optimization for SuperH.  Hack is to build with -O0.
2731.21Smycroft	kcah
2741.21Smycroft
2751.21Smycroft
2761.21Smycroftport	sh5
2771.21Smycroft
2781.21Smycroft	hack	SuperH SH5 Toolchain Bugs
2791.21Smycroft	cdate	11 Jul 2002
2801.21Smycroft	who	scw
2811.21Smycroft	file	usr.sbin/ndbootd/ndbootd.c : 1.6
2821.21Smycroft	file	usr.sbin/traceroute/traceroute.c : 1.48
2831.21Smycroft	descr
2841.21Smycroft		The SuperH SH5 toolchain (2.97-sh5-010522) gets an internal
2851.21Smycroft		compiler error when assigning a bit-wise inverted value
2861.21Smycroft		under some circumstances.
2871.21Smycroft		Work around it by splitting the statement into two.
2881.21Smycroft	kcah
2891.21Smycroft
2901.21Smycroft	hack	SuperH SH5 Toolchain Bugs
2911.21Smycroft	cdate	17 May 2003
2921.21Smycroft	who	scw
2931.21Smycroft	file	lib/libpthread/pthread_lock.c : 1.7
2941.21Smycroft	descr
2951.21Smycroft		The SuperH SH5 toolchain generates incorrect PIC code when
2961.21Smycroft		faced with a symbol which is declared extern, but has local
2971.21Smycroft		scope due to being defined within an asm() statement (without
2981.21Smycroft		being declared .globl in that statement). Work around it by
2991.21Smycroft		adding the .globl.
3001.27Sscw	kcah
3011.27Sscw
3021.27Sscw	hack	gcc 3.3.2 on sh5 - ICE compiling reload1.c at -O2
3031.27Sscw	cdate	Sun Dec  7 19:44:05 GMT 2003
3041.27Sscw	who	scw
3051.27Sscw	file	gnu/usr.bin/gcc3/backend/Makefile : 1.13
3061.27Sscw	descr
3071.27Sscw		Gcc3 for sh5 gets an ICE compiling reload1.c at -O2.
3081.27Sscw		Drop to -O1 for now when building for sh5.
3091.27Sscw	kcah
3101.28Sscw
3111.28Sscw	hack	gcc 3.3.2 on sh5 - ICE compiling elf32.c/elf64.c at -O2
3121.28Sscw	cdate	Sun Dec  7 21:10:46 GMT 2003
3131.28Sscw	who	scw
3141.28Sscw	file	gnu/lib/libbfd/Makefile : 1.39
3151.28Sscw	descr
3161.28Sscw		Gcc3 for sh5 gets an ICE compiling libbfd's elf32.c
3171.28Sscw		and elf64.c at -O2.
3181.28Sscw		Drop to -O1 for now when building for sh5.
3191.28Sscw	kcah
3201.28Sscw
3211.27Sscw
3221.27Sscw	hack	gcc 3.3.2 on sh5 - fatal warning compiling function.c
3231.27Sscw	cdate	Sun Dec  7 19:44:05 GMT 2003
3241.27Sscw	who	scw
3251.27Sscw	file	gnu/usr.bin/gcc3/backend/Makefile : 1.13
3261.27Sscw	descr
3271.27Sscw		Gcc3 for sh5 issues a warning:
3281.27Sscw		.../gnu/dist/gcc/gcc/function.c:4742: warning: `and' of
3291.27Sscw		    mutually exclusive equal-tests is always 0.
3301.27Sscw		This causes the build to fail because of -Werror.
3311.27Sscw		Work-around by defining NOGCCERROR when building for sh5.
3321.27Sscw	kcah
3331.27Sscw
3341.27Sscw	hack	gcc 3.3.2 on sh5 - ICE compiling dist/bind/bin/named/ns_main.c
3351.27Sscw	cdate	Sun Dec  7 19:44:05 GMT 2003
3361.27Sscw	who	scw
3371.27Sscw	file	usr.sbin/bind/named/Makefile : 1.15
3381.27Sscw	descr
3391.27Sscw		Gcc3 for sh5 gets an ICE compiling ns_main.c at -O2.
3401.27Sscw		Drop to -O1 for now when building for sh5.
3411.21Smycroft	kcah
3421.17Smrg
3431.17Smrg
3441.17Smrgport	sun2
3451.20Sskrll
3461.21Smycroft	hack	gcc 3.3.2/mdsetimage
3471.21Smycroft	cdate	Tue Oct 28 18:43:05 EST 2003
3481.21Smycroft	who	fredette
3491.21Smycroft	file	gnu/usr.sbin/mdsetimage/Makefile : 1.15
3501.21Smycroft	descr
3511.21Smycroft		mdsetimage.c causes cc1 to barf for as-yet unknown reasons.
3521.26Ssimonb		this hack uses -O0 to avoid the problem.
3531.21Smycroft	kcah
3541.21Smycroft
3551.21Smycroft	hack	gcc 3.3.2/installboot/ffs.c
3561.21Smycroft	cdate	Tue Oct 28 18:43:05 EST 2003
3571.21Smycroft	who	fredette
3581.21Smycroft	file	usr.sbin/installboot/Makefile : 1.26
3591.21Smycroft	descr
3601.21Smycroft		ffs.c causes cc1 to barf for as-yet unknown reasons.  this
3611.26Ssimonb		hack uses -O0 to avoid the problem.
3621.22Smrg	kcah
3631.22Smrg
3641.22Smrg
3651.22Smrgport	sun2, m68k
3661.22Smrg
3671.22Smrg	hack	gcc 3.3.2/gcc/ra-colorize.c
3681.22Smrg	cdate	Wed Nov  5 11:03:13 EST 2003
3691.22Smrg	who	mrg
3701.22Smrg	file	gnu/usr.bin/gcc/backend/Makefile : 1.11
3711.22Smrg	descr
3721.22Smrg		ra-colorize.c causes a whole spew of unreferenced .L* local
3731.22Smrg		symbols.  using -O0 (or even -O2 reportedly) avoids the problem.
3741.21Smycroft	kcah
3751.31Smartin
3761.31Smartinport	sparc64
3771.31Smartin
3781.31Smartin	hack	disable optimzations for uvm_bio.c on 32 bit kernels
3791.31Smartin	cdate	Sun Mar 21 14:14:04 MET 2004
3801.31Smartin	who	martin
3811.32Smartin	file	sys/arch/sparc64/conf/Makefile.sparc64 : 1.53-1.54
3821.32Smartin	file	sys/arch/sparc64/conf/files.sparc64 : 1.93
3831.31Smartin	descr
3841.31Smartin		The sparc compiler miscompiles uvm_bio.c when using
3851.31Smartin		any optimization. This results in ubc_release panics.
3861.31Smartin	kcah
387