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