Home | History | Annotate | Line # | Download | only in doc
HACKS revision 1.42
      1 # $NetBSD: HACKS,v 1.42 2005/02/22 18:47:09 christos Exp $
      2 #
      3 # This file is intended to document workarounds for currently unsolved
      4 # (mostly) compiler bugs.
      5 #
      6 # Format:
      7 #   hack		title
      8 #   cdate		creation date
      9 #   mdate		mod date
     10 #   who			responsible developer
     11 #   port		...
     12 #  	  affected ports, space separated, if not "all"
     13 #   file		affected file : revision : line from : line to
     14 #  	  affected files and revision and line numbers describing hack
     15 #  	  multiple lines if necessary.
     16 #   pr			NNNN ...
     17 #  	  problem reports this hack works around, if known. Space
     18 #  	  separated.
     19 #   regress		src/regress/directory/where/test/found
     20 #  	  regression test directories, if available.
     21 #   descr
     22 #  	  insert short informal description (multi-line). (Longer ones
     23 #  	  should be in the PR database. More formal descriptions might
     24 #  	  be in the regress tree. See above).
     25 #   kcah
     26 #  	  closing bracket.
     27 #
     28 # this is a comment.
     29 
     30 hack	netstat ieee1394 address printing.
     31 mdate	14 Nov 2000
     32 who	matt
     33 file	lib/libc/net/getnameinfo.c	: 1.32 : 497 : 503
     34 descr
     35 	Because the current implementation of IP over IEEE1394, the
     36 	fw device address contains more than just the IEEE1394 EUI-64.
     37 	So when printing out IEEE1394 addresses, ignore the extra stuff.
     38 kcah
     39 
     40 hack	xterm vs. libterm
     41 mdate	01 Aug 2000
     42 who	jdc
     43 file	xsrc/xc/programs/xterm/main.c	: 1.2 : 3609 : 3614
     44 pr	10383
     45 descr
     46 	In order to extend the termcap string over 1023 bytes, a ZZ entry was
     47 	introduced to point to a memory location containing the full entry.
     48 	Without this hack, xterm will export a termcap containing the ZZ
     49 	entry, which will then be ignored by libterm.  As xterm modifies the
     50 	exported termcap, this would cause those modifications to be ignored.
     51 kcah
     52 
     53 hack	wi-at-big-endian-bus
     54 cdate	15 Mar 2002
     55 who	martin
     56 file	dev/ic/wireg.h
     57 descr	Add an option to access the underlying bus in big endian byte order
     58 	to work around deficiencies in bus_space_{read,write}_* macros.
     59 	Those don't allow the implementation of a proper pcmcia bus space
     60 	tag.
     61 kcah
     62 
     63 hack	specific knowledge of colours in curses code
     64 cdate	Sun Apr  6 11:05:24 BST 2003
     65 who	jdc
     66 file	lib/libcurses/color.c : r1.24
     67 descr
     68 	Swap red/blue and yellow/cyan colours for COLOR_OTHER.
     69 	Fix is to enhance libtermcap to understand terminfo-style % sequences.
     70 	See also:
     71 	    http://mail-index.NetBSD.org/tech-userlevel/2003/04/06/0000.html
     72 kcah
     73 
     74 hack	Compensation for differing types of LINUX_USRSTACK and USRSTACK
     75 cdate	21 Aug 2003
     76 who	he
     77 file	sys/miscfs/procfs/procfs_linux.c : 1.14
     78 descr
     79 	Not all ports have LINUX_USRSTACK and/or USRSTACK defined as
     80 	literals/constants, but refer to variables of a type which is
     81 	not "unsigned long", causing compilation of procfs_linux.c to
     82 	fail with "makes integer from pointer without a cast".  This
     83 	is observed on e.g. the sun3 port.  Ideally the "types" for
     84 	symbols should be consistent across all ports.
     85 kcah
     86 
     87 hack	GCC2 isn't C99
     88 cdate	5 December 2003
     89 who	mrg
     90 file	gnu/dist/binutils/ld/ldlex.c: r1.2
     91 descr
     92 	ldlex.c is generated from ldlex.l and we get macro redefinition
     93 	errors from it if __STDC_VERSION__ is not C99 compliant.  This
     94 	hack forces NetBSD 1.6 and later systems to also include <stdint.h>
     95 	to get the relevant definitions.  This hack should be backed out
     96 	when all platforms have switched away from GCC2.
     97 kcah
     98 
     99 hack	gcc-strict-aliasing
    100 cdate	6 August 2004
    101 who	junyoung
    102 pr	26516
    103 file	src/usr.sbin/racoon/racoon/Makefile : 1.21
    104 descr
    105 	GCC issues a warning "dereferencing type-punned pointer will break
    106 	strict-aliasing rules" when compiling
    107 	crypto/dist/kame/racoon/crypto/openssl.c with -O[23s]. Note that this
    108 	is due to use of type casting in a non-standard way in the code and
    109 	not a compiler bug. Once a new release of KAME with a proper fix
    110 	applied is imported this should be backed out.
    111 kcah
    112 
    113 
    114 port	vax
    115 
    116 	hack	gcc 2.95/vax cannot handle __builtin_ffs()
    117 	cdate	Fri Aug 23 21:31:15 CEST 2002
    118 	who	ragge
    119 	file	sys/lib/libkern/libkern.h : 1.42
    120 	descr
    121 		__builtin_ffs() is ifdef'd away if __vax__. Matt Thomas has
    122 		added this feature to GCC 3 so it can be removed when switching.
    123 	kcah
    124 
    125 	hack	gcc-vax-libbz2
    126 	mdate	27 Jun 2002
    127 	who	thorpej
    128 	file	lib/libbz2/Makefile
    129 	descr
    130 		libbz2 is mis-compiled with optimization with GCC 2.95.3
    131 		on VAX.  -O0 works around this problem.
    132 	kcah
    133 
    134 	hack	gawk
    135 	mdate	8 Nov 2003
    136 	who	ragge
    137 	file	gnu/usr.bin/gawk/Makefile
    138 	descr
    139 		gawk is mis-compiled with optimization with GCC 2.95.3
    140 		on VAX.  -O0 works around this problem.
    141 	kcah
    142 
    143 	hack	vax Toolchain bug
    144 	cdate	28 Mar 2003
    145 	who	he
    146 	file	sys/arch/vax/vax/intvec.S : 1.5
    147 	descr
    148 		Workaround for PR toolchain/20924.  The assembler apparently
    149 		tries to range-check byte offsets when it doesn't have
    150 		sufficient information to make that decision.
    151 		Workaround uses `brw' instead of `brb' instruction.
    152 	kcah
    153 
    154 	hack	vax gcc 2.95.3 -Wuninitialized workarounds
    155 	cdate	6 Nov 2003
    156 	who	he
    157 	file	sys/dev/bi/if_ni.c : 1.22
    158 	file	sys/arch/vax/vax/ctu.c : 1.20
    159 	descr
    160 		Workaround for gcc 2.95.3 failing to detect that certain
    161 		variables will be initialized; so that this code compiles
    162 		with -Wuninitialized.  Should be reviewed and possibly
    163 		reverted when gcc 3.3.2 is ready for vax.
    164 	kcah
    165 
    166 	hack	vax gcc 2.95.3 structure initialization
    167 	cdat	13 May 2004
    168 	who	cl
    169 	file	sys/miscfs/kernfs/kernfs_vnops.c : 1.104
    170 	descr
    171 		Workaround for gcc 2.95.3 failing to initialize structures
    172 		and/or unions inside structures using nested designators.
    173 		Should be reverted when gcc >=3.3.3 is ready for vax.
    174 	kcah
    175 
    176 	hack	vax gcc 2.95.3 needs -I. to build nslexer.c
    177 	cdat	6 Jun 2004
    178 	who	mhitch
    179 	file	lib/libc/arch/vax/Makefile.inc : 1.6
    180 	descr
    181 		It appears necessary to add -I. to CPPFLAGS when building
    182 		nslesxer.c.  This may be caused by gcc 2.95.3 being used.
    183 		Should be reverted when a newer gcc is ready for vax.
    184 	kcah
    185 
    186 port	sparc64
    187 
    188 	hack	binutil-2.11-sparc64-pltrela
    189 	mdate	14 Aug 2001
    190 	who	eeh
    191 	file	libexec/ld.elf_so/arch/sparc64/mdreloc.c
    192 	descr
    193 		The first four PLT entries are reserved.  There is some
    194 		disagreement whether they should have associated relocation
    195 		entries.  Both the SPARC 32-bit and 64-bit ELF specifications
    196 		say that they should have relocation entries, but the 32-bit
    197 		SPARC binutils do not generate them, and now the 64-bit SPARC
    198 		binutils have stopped generating them too.
    199 
    200 		To provide binary compatibility, we will check the first entry,
    201 		if it is reserved it should not be of the type JMP_SLOT.  If it
    202 		is JMP_SLOT, then the 4 reserved entries were not generated and
    203 		our index is 4 entries too far, so we frob the rela pointer.
    204 	kcah
    205 
    206 
    207 port	arm
    208 
    209 	hack	gcc-unsigned-compare
    210 	cdate	09 Mar 2002
    211 	mdate	18 Mar 2002
    212 	who	bjh21
    213 	file	dist/bind/lib/nameser/ns_parse.c : 1.3
    214 	file	dist/dhcp/minires/ns_parse.c : 1.3
    215 	file	dist/dhcp/omapip/result.c : 1.2
    216 	file	dist/dhcp/server/failover.c : 1.3
    217 	file	gnu/dist/gawk/eval.c : 1.4
    218 	file	gnu/dist/toolchain/bfd/bfd.c : 1.2
    219 	file	gnu/dist/toolchain/bfd/format.c : 1.2
    220 	file	gnu/dist/toolchain/gdb/target.c : 1.2
    221 	file	sys/kern/vfs_subr.c : 1.172
    222 	descr	When checking that a potentially-unsigned enum is >= 0, assign
    223 		it to an int first.  This is necessary to avoid "comparison is
    224 		always true" warnings with -fshort-enums.  Casting to an int
    225 		really should be enough, but turns out not to be.
    226 	kcah
    227 
    228 	hack	gcc 3.3.2/arm sys/kern/uipc_socket.c
    229 	cdate	Tue Oct 28 18:02:16 GMT 2003
    230 	who	skrll
    231 	pr	23044
    232 	file	sys/arch/arm/conf/Makefile.arm : 1.19
    233 	descr
    234 		Performing a build.sh tools on a CATS with NFS mounted 
    235 		obj and src directories results in "panic: receive 1"
    236 		The hack is to compile sys/kern/uipc_socket.c with
    237 		-fno-strict-aliasing
    238 	kcah
    239 
    240 
    241 port	pc532
    242 
    243 	hack	egcs-pc532-ip6_mroute
    244 	cdate	09 Jul 2002
    245 	who	simonb
    246 	file	sys/arch/pc532/conf/Makefile.pc532 : 1.70
    247 	file	sys/arch/pc532/conf/files.pc532 : 1.47
    248 	descr
    249 		egcs 1.1.2 gets an "internal error--insn does not satisfy its
    250 		constraints" error compiling ip6_mroute.c with -O2 or greater.
    251 		-O1 works around this problem.
    252 	kcah
    253 
    254 	hack	gcc-pc532-duffs_device
    255 	cdate	Mon Oct 27 07:23:05 UTC 2003
    256 	who	simonb
    257 	file	sys/arch/pc532/conf/Makefile.pc532 : 1.71
    258 	file	sys/arch/pc532/conf/files.pc532 : 1.52
    259 	pr	GCC PR optimization/5230
    260 	descr
    261 		gcc incorrectly gives an "unreachable code at beginning of
    262 		switch statement" for a Duff's device construct in
    263 		arch/pc532/dev/ncr.c.  There is no way to disable just this
    264 		warning, so -Wno-error is turned on for this file.
    265 	kcah
    266 
    267 	hack	gcc332-cppmacro-ice
    268 	cdate	Sun Dec  7 12:48:33 UTC 2003
    269 	who	simonb
    270 	file	gnu/usr.bin/gcc3/libcpp/Makefile : 1.2
    271 	descr
    272 		gcc 3.3.2 gets an ICE when compiling cppmacro.c with -O2.
    273 		The hack is to use -O1 for this file.  Fixed in gcc
    274 		-current mainline, unable to work out where the fix is
    275 		right now.
    276 	kcah
    277 
    278 
    279 port	sh3
    280 
    281 	hack	gcc-sh3-sed
    282 	mdate	23 Apr 2002
    283 	who	thorpej
    284 	file	usr.bin/sed/Makefile	: 1.9 : 9 : 13
    285 	descr
    286 		The in-tree GCC 2.95.3-based compiler ICEs when building
    287 		with optimization for SuperH.  Hack is to build with -O0.
    288 	kcah
    289 
    290 
    291 port	sh5
    292 
    293 	hack	SuperH SH5 Toolchain Bugs
    294 	cdate	11 Jul 2002
    295 	who	scw
    296 	file	usr.sbin/ndbootd/ndbootd.c : 1.6
    297 	file	usr.sbin/traceroute/traceroute.c : 1.48
    298 	descr
    299 		The SuperH SH5 toolchain (2.97-sh5-010522) gets an internal
    300 		compiler error when assigning a bit-wise inverted value
    301 		under some circumstances.
    302 		Work around it by splitting the statement into two.
    303 	kcah
    304 
    305 	hack	SuperH SH5 Toolchain Bugs
    306 	cdate	17 May 2003
    307 	who	scw
    308 	file	lib/libpthread/pthread_lock.c : 1.7
    309 	descr
    310 		The SuperH SH5 toolchain generates incorrect PIC code when
    311 		faced with a symbol which is declared extern, but has local
    312 		scope due to being defined within an asm() statement (without
    313 		being declared .globl in that statement). Work around it by
    314 		adding the .globl.
    315 	kcah
    316 
    317 	hack	gcc 3.3.2 on sh5 - ICE compiling reload1.c at -O2
    318 	cdate	Sun Dec  7 19:44:05 GMT 2003
    319 	who	scw
    320 	file	gnu/usr.bin/gcc3/backend/Makefile : 1.13
    321 	descr
    322 		Gcc3 for sh5 gets an ICE compiling reload1.c at -O2.
    323 		Drop to -O1 for now when building for sh5.
    324 	kcah
    325 
    326 	hack	gcc 3.3.2 on sh5 - ICE compiling elf32.c/elf64.c at -O2
    327 	cdate	Sun Dec  7 21:10:46 GMT 2003
    328 	who	scw
    329 	file	gnu/lib/libbfd/Makefile : 1.39
    330 	descr
    331 		Gcc3 for sh5 gets an ICE compiling libbfd's elf32.c
    332 		and elf64.c at -O2.
    333 		Drop to -O1 for now when building for sh5.
    334 	kcah
    335 
    336 
    337 	hack	gcc 3.3.2 on sh5 - fatal warning compiling function.c
    338 	cdate	Sun Dec  7 19:44:05 GMT 2003
    339 	who	scw
    340 	file	gnu/usr.bin/gcc3/backend/Makefile : 1.13
    341 	descr
    342 		Gcc3 for sh5 issues a warning:
    343 		.../gnu/dist/gcc/gcc/function.c:4742: warning: `and' of
    344 		    mutually exclusive equal-tests is always 0.
    345 		This causes the build to fail because of -Werror.
    346 		Work-around by defining NOGCCERROR when building for sh5.
    347 	kcah
    348 
    349 	hack	gcc 3.3.3 on sh5 - ICE compiling rbtdb.c and rbtdb64.c
    350 	cdate	Thu Nov 11 00:35:33 UTC 2004
    351 	who	he
    352 	file	usr.sbin/bind/libdns/Makefile/1.2
    353 	descr
    354 		Gcc3 for sh5 gets an ICE compiling these files at -O2.
    355 		Drop to -O1 for now when building for sh5.
    356 	kcah
    357 
    358 
    359 port	sun2
    360 
    361 	hack	gcc 3.3.2/mdsetimage
    362 	cdate	Tue Oct 28 18:43:05 EST 2003
    363 	who	fredette
    364 	file	gnu/usr.sbin/mdsetimage/Makefile : 1.15
    365 	descr
    366 		mdsetimage.c causes cc1 to barf for as-yet unknown reasons.
    367 		this hack uses -O0 to avoid the problem.
    368 	kcah
    369 
    370 	hack	gcc 3.3.2/installboot/ffs.c
    371 	cdate	Tue Oct 28 18:43:05 EST 2003
    372 	who	fredette
    373 	file	usr.sbin/installboot/Makefile : 1.26
    374 	descr
    375 		ffs.c causes cc1 to barf for as-yet unknown reasons.  this
    376 		hack uses -O0 to avoid the problem.
    377 	kcah
    378 
    379 
    380 port	sun2, m68k
    381 
    382 	hack	gcc 3.3.2/gcc/ra-colorize.c
    383 	cdate	Wed Nov  5 11:03:13 EST 2003
    384 	who	mrg
    385 	file	gnu/usr.bin/gcc/backend/Makefile : 1.11
    386 	descr
    387 		ra-colorize.c causes a whole spew of unreferenced .L* local
    388 		symbols.  using -O0 (or even -O2 reportedly) avoids the problem.
    389 	kcah
    390 
    391 port	sparc64
    392 
    393 	hack	disable optimzations for uvm_bio.c on 32 bit kernels
    394 	cdate	Sun Mar 21 14:14:04 MET 2004
    395 	who	martin
    396 	file	sys/arch/sparc64/conf/Makefile.sparc64 : 1.53-1.54
    397 	file	sys/arch/sparc64/conf/files.sparc64 : 1.93
    398 	descr
    399 		The sparc compiler miscompiles uvm_bio.c when using
    400 		any optimization. This results in ubc_release panics.
    401 	kcah
    402 
    403 port	macppc
    404 
    405 	hack	remove inline from rotate_{left,right}
    406 	cdate	Tue Feb 22 13:43:25 EST 2005
    407 	who	christos
    408 	file	src/dist/bind/lib/dns/rbt.c
    409 	descr
    410 		The macppc gcc-3.3 compiler miscompiles rbt.c when these
    411 		functions are inlined. The error is:
    412 		.* named[368]: rbt.c:1584: INSIST(child != (void *)0) >failed
    413 		.* named[368]: exiting (due to assertion failure)
    414 		This is reportedly fixed in gcc-3.4
    415 	kcah
    416