HACKS revision 1.3
11.3Sjdc# $NetBSD: HACKS,v 1.3 2003/04/06 10:12:20 jdc 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	gcc 2.95/vax cannot handle __builtin_ffs()
311.1Slukemcdate	Fri Aug 23 21:31:15 CEST 2002
321.1Slukemwho	ragge
331.1Slukemport	vax
341.1Slukemfile	sys/lib/libkern/libkern.h : 1.42
351.1Slukemdescr
361.1Slukem	__builtin_ffs() is ifdef'd away if __vax__. Matt Thomas has added
371.1Slukem	this feature to GCC 3 so it can be removed when switching.
381.1Slukemkcah
391.1Slukem
401.1Slukemhack	gcc 2.95.3 -O2 bug
411.1Slukemcdate	Sun Jan  6 23:17:28 UTC 2002
421.1Slukemwho	lukem
431.1Slukemport	alpha
441.1Slukemfile	sbin/newfs/mkfs.c : (all?)
451.1Slukempr	15156
461.1Slukemdescr
471.1Slukem	newfs built with gcc -O2 dumps core part-way through.
481.1Slukem	using -O1 avoids the problem
491.1Slukemkcah
501.1Slukem
511.1Slukemhack	binutil-2.11-sparc64-pltrela
521.1Slukemmdate	14 Aug 2001
531.1Slukemwho	eeh
541.1Slukemport	sparc64
551.1Slukemfile	libexec/ld.elf_so/reloc.c: 1.41 : 597 : 619
561.1Slukemdescr
571.1Slukem	The first for PLT entries are reserved.  There is some disagreement
581.1Slukem	whether they should have associated relocation entries.  Both the
591.1Slukem	SPARC 32-bit and 64-bit ELF specifications say that they should have
601.1Slukem	relocation entries, but the 32-bit SPARC binutils do not generate
611.1Slukem	them, and now the 64-bit SPARC binutils have stopped generating them
621.1Slukem	too.
631.1Slukem
641.1Slukem	To provide binary compatibility, we will check the first entry, if it
651.1Slukem	is reserved it should not be of the type JMP_SLOT.  If it is JMP_SLOT,
661.1Slukem	then the 4 reserved entries were not generated and our index is 4
671.1Slukem	entries too far, so we frob the rela pointer.
681.1Slukemkcah
691.1Slukem
701.1Slukemhack	gcc-arm32-schedule
711.1Slukemmdate	04 May 2000
721.1Slukemwho	is
731.1Slukemfile	lib/libc/stdlib/strtoull.c	: 1.3 : 78 : 81
741.1Slukemfile	lib/libc/stdlib/strtouq.c	: 1.15 : 73 : 76
751.1Slukempr	9613
761.1Slukemdescr
771.1Slukem	strtoull() was returning a wrong result for small numbers with bit 31
781.1Slukem	set. This is a gcc/arm32 compiler bug in gcc < 2.95.2. Adding
791.1Slukem	(void)&acc; works around it.
801.1Slukemkcah
811.1Slukem
821.1Slukemhack	gcc-sparc64-memorysize
831.1Slukemmdate	17 Sep 2000
841.1Slukemwho	mrg
851.1Slukemport	sparc64
861.1Slukemfile	lib/libc/hash/sha1.c		: 1.6 : 78 : 129 : 162 : 189
871.1Slukemfile	sys/lib/libkern/sha1.c		: 1.6 : 78 : 129 : 162 : 189
881.1Slukemfile	usr.sbin/bind/lib/Makefile	: 1.14 : 87 : 91
891.1Slukemdescr
901.1Slukem	the normal SHA1Transform() function causes the sparc64 compiler to
911.1Slukem	use excessive amounts of memory attempting to optimise this function.
921.1Slukem	using no optimisation allows the function to build.  this hack
931.1Slukem	splits the mathematical functions inside SHA1Transform() into 4
941.1Slukem	separate functions, which avoids the optimiser explosion.
951.1Slukemkcah
961.1Slukem
971.1Slukemhack	gcc-sparc64-double-arguments
981.1Slukemmdate	18 Sep 2000
991.1Slukemwho	mrg
1001.1Slukemport	sparc64
1011.1Slukemfile	xsrc/xc/lib/fonts/Type1/type1.c		: 1.2 : 1461 : 1507 : 1702 : 1709
1021.1Slukemdescr
1031.1Slukem	in passing 17 "double" arguments to a function, gcc incorrectly tries
1041.1Slukem	to use a register that doesn't exist, causing an internal error.  this
1051.1Slukem	hack changes the way arguments are passed to the function, such that
1061.1Slukem	a pointer to a "double" (really an array) is passed, and the old
1071.1Slukem	arguments are assigned within the function.
1081.1Slukemkcah
1091.1Slukem
1101.1Slukemhack	gcc-sparc64-gawk
1111.1Slukemmdate	28 Oct 2000
1121.1Slukemwho	mrg
1131.1Slukemport	sparc64
1141.1Slukemfile	gnu/usr.bin/gawk/Makefile		: 1.11 : 21 : 24
1151.1Slukemdescr
1161.1Slukem	gcc fails to build gawk properly, due to double floating point bugs.
1171.1Slukem	this simple test program will fail to print ``ab'':
1181.1Slukem		BEGIN { f = "abc"; print substr(f, 1, 2); exit }
1191.1Slukem	the work around is simple: use -msoft-quad-float.
1201.1Slukemkcah
1211.1Slukem
1221.1Slukemhack    gcc-sparc64-libgcc
1231.1Slukemmdate   01 Dec 2001
1241.1Slukemwho	jmc
1251.1Slukemport	sparc64
1261.1Slukemfile	gnu/lib/libgcc/Makefile			: 1.29 : 24 : 27
1271.1Slukemdescr
1281.1Slukem	gcc fails to do double -> int conversions correctly without 
1291.1Slukem	soft-quad-float. Add it in there for the internal conversion
1301.1Slukem	routines. This appears to be more than likely emulations bugs than
1311.1Slukem	compiler bugs as the assembly looks correct on the surface.
1321.1Slukem
1331.1Slukemkcah
1341.1Slukem
1351.1Slukemhack	gcc-sparc64-iostat-systat
1361.1Slukemmdate	04 Feb 2001
1371.1Slukemwho	mrg
1381.1Slukemport	sparc64
1391.1Slukemfile	usr.sbin/iostat/Makefile	: 1.17 : 7 : 10
1401.1Slukemfile	usr.bin/systat/Makefile		: 1.23 : 6 : 9
1411.1Slukemdescr
1421.1Slukem	gcc fails to build iostat properly, due to double floating point bugs.
1431.1Slukem	results will include "Inf" and other garbage.
1441.1Slukem	the work around is simple: use -msoft-quad-float.
1451.1Slukemkcah
1461.1Slukem
1471.1Slukemhack	gcc-sparc64-nawk
1481.1Slukemmdate	25 Oct 2001
1491.1Slukemwho	martin
1501.1Slukemport	sparc64
1511.1Slukemfile	usr.bin/awk/Makefile		: 1.3 : 13 : 15
1521.1Slukemdescr
1531.1Slukem	Don't use long double on sparc64.
1541.1Slukemkcah
1551.1Slukem
1561.1Slukemhack	gcc-sparc64-ntp
1571.1Slukemmdate	12 Nov 2000
1581.1Slukemwho	martin
1591.1Slukemport	sparc64
1601.1Slukemfile	usr.sbin/ntp/Makefile.inc	: 1.5 : 17 : 19
1611.1Slukemdescr
1621.1Slukem	gcc fails to build ntpd properly, due to double floating point bugs.
1631.1Slukem	Ntpd will fail to decode incoming packets; ntpdc -s will report
1641.1Slukem	a delay, offset and dispersion of 0.0000 for all peers.
1651.1Slukem	the work around is simple: use -msoft-quad-float.
1661.1Slukemkcah
1671.1Slukem
1681.1Slukemhack	gcc-sparc64-x_dhclient
1691.1Slukemmdate	27 Dec 2000
1701.1Slukemwho	mrg
1711.1Slukemport	sparc64
1721.1Slukemfile	distrib/utils/x_dhclient/Makefile	: 1.6 : 28 : 30
1731.1Slukemdescr
1741.1Slukem	gcc fails with an ICE while building dhclient's parse.c with -O2
1751.1Slukem	and -Os.  the work around is simple: don't use -Os.
1761.1Slukemkcah
1771.1Slukem
1781.1Slukemhack	lint-no-long-double
1791.1Slukemmdate	17 Aug 2001
1801.1Slukemwho	eeh
1811.1Slukemport	sparc64
1821.1Slukemfile	usr.bin/xlint/lint1/param.h: 1.14 :
1831.1Slukemdescr
1841.1Slukem	Don't use long double on sparc64.
1851.1Slukemkcah
1861.1Slukem
1871.1Slukemhack	netstat ieee1394 address printing.
1881.1Slukemmdate	14 Nov 2000
1891.1Slukemwho	matt
1901.1Slukemfile	lib/libc/net/getnameinfo.c	: 1.32 : 497 : 503
1911.1Slukemdescr
1921.1Slukem	Because the current implementation of IP over IEEE1394, the
1931.1Slukem	fw device address contains more than just the IEEE1394 EUI-64.
1941.1Slukem	So when printing out IEEE1394 addresses, ignore the extra stuff.
1951.1Slukemkcah
1961.1Slukem
1971.1Slukemhack	xterm vs. libterm
1981.1Slukemmdate	01 Aug 2000
1991.1Slukemwho	jdc
2001.1Slukemfile	xsrc/xc/programs/xterm/main.c	: 1.2 : 3609 : 3614
2011.1Slukempr	10383
2021.1Slukemdescr
2031.1Slukem	In order to extend the termcap string over 1023 bytes, a ZZ entry was
2041.1Slukem	introduced to point to a memory location containing the full entry.
2051.1Slukem	Without this hack, xterm will export a termcap containing the ZZ
2061.1Slukem	entry, which will then be ignored by libterm.  As xterm modifies the
2071.1Slukem	exported termcap, this would cause those modifications to be ignored.
2081.1Slukemkcah
2091.1Slukem
2101.1Slukemhack	gcc-3-libtelnet
2111.1Slukemmdate	29 Jan 2002
2121.1Slukemwho	thorpej
2131.1Slukemfile	lib/libtelnet/Makefile	: 1.14 : 14 : 17
2141.1Slukemdescr
2151.1Slukem	GCC 3.x issues a spurious warning when compiling a Duff's Device
2161.1Slukem	with optimization, even though it compiles the file correctly.
2171.1Slukem	GCC PR optimization/5230.  kerberos.c contains a Duff's Device
2181.1Slukem	in the checksum routine.  Hack is to build libtelnet w/o optimization
2191.1Slukem	if HAVE_GCC3 is set.
2201.1Slukemkcah
2211.1Slukem
2221.1Slukemhack	gcc-sh3-sed
2231.1Slukemmdate	23 Apr 2002
2241.1Slukemwho	thorpej
2251.1Slukemfile	usr.bin/sed/Makefile	: 1.9 : 9 : 13
2261.1Slukemdescr
2271.1Slukem	The in-tree GCC 2.95.3-based compiler ICEs when building
2281.1Slukem	with optimization for SuperH.  Hack is to biuld with -O0.
2291.1Slukemkcah
2301.1Slukem
2311.1Slukemhack	gcc-unsigned-compare
2321.1Slukemcdate	09 Mar 2002
2331.1Slukemmdate	18 Mar 2002
2341.1Slukemwho	bjh21
2351.1Slukemport	arm
2361.1Slukemfile	dist/bind/lib/nameser/ns_parse.c : 1.3
2371.1Slukemfile	dist/dhcp/minires/ns_parse.c : 1.3
2381.1Slukemfile	dist/dhcp/omapip/result.c : 1.2
2391.1Slukemfile	dist/dhcp/server/failover.c : 1.3
2401.1Slukemfile	gnu/dist/gawk/eval.c : 1.4
2411.1Slukemfile	gnu/dist/toolchain/bfd/bfd.c : 1.2
2421.1Slukemfile	gnu/dist/toolchain/bfd/format.c : 1.2
2431.1Slukemfile	gnu/dist/toolchain/gdb/target.c : 1.2
2441.1Slukemfile	sys/kern/vfs_subr.c : 1.172
2451.1Slukemdescr	When checking that a potentially-unsigned enum is >= 0, assign it
2461.1Slukem	to an int first.  This is necessary to avoid "comparison is always
2471.1Slukem	true" warnings with -fshort-enums.  Casting to an int really should
2481.1Slukem	be enough, but turns out not to be.
2491.1Slukemkcah
2501.1Slukem
2511.1Slukemhack	wi-at-big-endian-bus
2521.1Slukemcdate	15 Mar 2002
2531.1Slukemwho	martin
2541.1Slukemfile	dev/ic/wireg.h
2551.1Slukemdescr	Add an option to access the underlying bus in big endian byte order
2561.1Slukem	to work around deficiencies in bus_space_{read,write}_* macros.
2571.1Slukem	Those don't allow the implementation of a proper pcmcia bus space
2581.1Slukem	tag.
2591.1Slukemkcah
2601.1Slukem
2611.1Slukemhack	gcc 2.95.3 -O2 (-fgcse) bug
2621.1Slukemcdate	Sun May  5 18:36:04 UTC 2002
2631.1Slukemwho	tsutsui
2641.1Slukemport	macppc
2651.1Slukemfile	sys/arch/macppc/dev/adb_direct.c:	1.24 : 1895 : 1896
2661.1Slukempr	16678
2671.1Slukemdescr
2681.1Slukem	gcc-2.95.3 does generates wrong code on optimization
2691.1Slukem	by gcc -O2 (-fgcse), and adb_read_date_time() returns
2701.1Slukem	wrong value on cuda system.
2711.1Slukem	A null asm statement has been added to avoid this for workaround.
2721.1Slukemkcah
2731.1Slukem
2741.1Slukemhack	gcc-vax-libbz2
2751.1Slukemmdate	27 Jun 2002
2761.1Slukemwho	thorpej
2771.1Slukemport	vax
2781.1Slukemfile	lib/libbz2/Makefile
2791.1Slukemdescr
2801.1Slukem	libbz2 is mis-compiled with optimization with GCC 2.95.3
2811.1Slukem	on VAX.  -O0 works around this problem.
2821.1Slukemkcah
2831.1Slukem
2841.1Slukemhack	egcs-pc532-ip6_mroute
2851.1Slukemcdate	09 Jul 2002
2861.1Slukemwho	simonb
2871.1Slukemport	pc532
2881.1Slukemfile	sys/arch/pc532/conf/Makefile.pc532 : 1.70
2891.1Slukemfile	sys/arch/pc532/conf/files.pc532 : 1.47
2901.1Slukemdescr
2911.1Slukem	egcs 1.1.2 gets an "internal error--insn does not satisfy its
2921.1Slukem	constraints" error compiling ip6_mroute.c with -O2 or greater.
2931.1Slukem	-O1 works around this problem.
2941.1Slukemkcah
2951.1Slukem
2961.1Slukemhack	SuperH SH5 Toolchain Bugs
2971.1Slukemcdate	11 Jul 2002
2981.1Slukemwho	scw
2991.1Slukemport	sh5
3001.1Slukemfile	usr.sbin/ndbootd/ndbootd.c : 1.6
3011.1Slukemfile	usr.sbin/traceroute/traceroute.c : 1.48
3021.1Slukemdescr
3031.1Slukem	The SuperH SH5 toolchain (2.97-sh5-010522) gets an internal
3041.1Slukem	compiler error when assigning a bit-wise inverted value
3051.1Slukem	under some circumstances.
3061.1Slukem	Work around it by splitting the statement into two.
3071.2Shekcah
3081.2She
3091.2Shehack	vax Toolchain bug
3101.2Shecdate	28 Mar 2003
3111.2Shewho	he
3121.2Sheport	vax
3131.2Shefile	sys/arch/vax/vax/intvec.S : 1.5
3141.2Shedescr
3151.2She	Workaround for PR toolchain/20924.  The assembler apparently
3161.2She	tries to range-check byte offsets when it doesn't have
3171.2She	sufficient information to make that decision.
3181.2She	Workaround uses `brw' instead of `brb' instruction.
3191.3Sjdckcah
3201.3Sjdc
3211.3Sjdchack	specific knowledge of colours in curses code
3221.3Sjdccdate	Sun Apr  6 11:05:24 BST 2003
3231.3Sjdcwho	jdc
3241.3Sjdcport	all
3251.3Sjdcfile	lib/libcurses/color.c : r1.24
3261.3Sjdcdescr
3271.3Sjdc	Swap red/blue and yellow/cyan colours for COLOR_OTHER.
3281.3Sjdc	Fix is to enhance libtermcap to understand terminfo-style % sequences.
3291.3Sjdc	See also:
3301.3Sjdc	    http://mail-index.netbsd.org/tech-userlevel/2003/04/06/0000.html
3311.1Slukemkcah
332