HACKS revision 1.52
1# $NetBSD: HACKS,v 1.52 2005/12/13 05:56:23 jmc 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 30hack netstat ieee1394 address printing. 31mdate 14 Nov 2000 32who matt 33file lib/libc/net/getnameinfo.c : 1.32 : 497 : 503 34descr 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. 38kcah 39 40hack xterm vs. libterm 41mdate 01 Aug 2000 42who jdc 43file xsrc/xc/programs/xterm/main.c : 1.2 : 3609 : 3614 44pr 10383 45descr 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. 51kcah 52 53hack wi-at-big-endian-bus 54cdate 15 Mar 2002 55who martin 56file dev/ic/wireg.h 57descr 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. 61kcah 62 63hack specific knowledge of colours in curses code 64cdate Sun Apr 6 11:05:24 BST 2003 65who jdc 66file lib/libcurses/color.c : r1.24 67descr 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 72kcah 73 74hack Compensation for differing types of LINUX_USRSTACK and USRSTACK 75cdate 21 Aug 2003 76who he 77file sys/miscfs/procfs/procfs_linux.c : 1.14 78descr 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. 85kcah 86 87hack GCC2 isn't C99 88cdate 5 December 2003 89who mrg 90file gnu/dist/binutils/ld/ldlex.c: r1.2 91descr 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. 97kcah 98 99hack gcc-strict-aliasing 100cdate 6 August 2004 101who junyoung 102pr 26516 103file src/usr.sbin/racoon/racoon/Makefile : 1.21 104descr 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. 111kcah 112 113 114port vax 115 116 hack gcc 2.95/vax doesn't like abort being used as function pointer 117 cdate Tue Dec 13 05:54:50 GMT 2005 118 who jmc 119 file lib/libc/rpc/svc_vc.c 1.15 120 descr 121 Provide a local definition for abort which doesn't include 122 the noreturn attribute which trips up gcc 2.95 on vax. 123 124 hack gcc 2.95/vax doesn't have stdbool.h and gettext needs it 125 cdate Mon May 9 12:16:22 CDT 2005 126 who jmc 127 file gnu/usr.bin/gettext/Makefile.inc.prog 1.5 128 gnu/usr.bin/gettext/libgrep/Makefile 1.3 129 gnu/usr.bin/gettext/libnlspr/Makefile 1.5 130 gnu/usr.bin/gettext/libnlsut/Makefile 1.3 131 descr 132 The latest gettext assumes a C99 environment or at least 133 configure checks to work around this. As we don't use configure 134 provide a stdbool.h for vax builds locally in directories from 135 the template provided by the gettext code. 136 137 hack gcc 2.95/vax can't handle __used__ in mcount.c 138 cdate Fri May 6 14:30:53 CDT 2005 139 who jmc 140 file src/lib/libc/gmon/mcount.c 1.17 141 descr 142 Recent changes to mark this as __used__ to prevent optimization 143 away on sparc64 don't work on 2.95 vax. Ifdef'd back in the 144 old __unused__ if on vax. 145 146 hack gcc 2.95/vax cannot handle __builtin_ffs() 147 cdate Fri Aug 23 21:31:15 CEST 2002 148 who ragge 149 file sys/lib/libkern/libkern.h : 1.42 150 descr 151 __builtin_ffs() is ifdef'd away if __vax__. Matt Thomas has 152 added this feature to GCC 3 so it can be removed when switching. 153 154 155 hack gcc-vax-libbz2 156 mdate 27 Jun 2002 157 who thorpej 158 file lib/libbz2/Makefile 159 descr 160 libbz2 is mis-compiled with optimization with GCC 2.95.3 161 on VAX. -O0 works around this problem. 162 kcah 163 164 hack gawk 165 mdate 8 Nov 2003 166 who ragge 167 file gnu/usr.bin/gawk/Makefile 168 descr 169 gawk is mis-compiled with optimization with GCC 2.95.3 170 on VAX. -O0 works around this problem. 171 kcah 172 173 hack vax Toolchain bug 174 cdate 28 Mar 2003 175 who he 176 file sys/arch/vax/vax/intvec.S : 1.5 177 descr 178 Workaround for PR toolchain/20924. The assembler apparently 179 tries to range-check byte offsets when it doesn't have 180 sufficient information to make that decision. 181 Workaround uses `brw' instead of `brb' instruction. 182 kcah 183 184 hack vax gcc 2.95.3 -Wuninitialized workarounds 185 cdate 6 Nov 2003 186 who he 187 file sys/dev/bi/if_ni.c : 1.22 188 file sys/arch/vax/vax/ctu.c : 1.20 189 descr 190 Workaround for gcc 2.95.3 failing to detect that certain 191 variables will be initialized; so that this code compiles 192 with -Wuninitialized. Should be reviewed and possibly 193 reverted when gcc 3.3.2 is ready for vax. 194 kcah 195 196 hack vax gcc 2.95.3 structure initialization 197 cdat 13 May 2004 198 who cl 199 file sys/miscfs/kernfs/kernfs_vnops.c : 1.104 200 descr 201 Workaround for gcc 2.95.3 failing to initialize structures 202 and/or unions inside structures using nested designators. 203 Should be reverted when gcc >=3.3.3 is ready for vax. 204 kcah 205 206 hack vax gcc 2.95.3 needs -I. to build nslexer.c 207 cdat 6 Jun 2004 208 who mhitch 209 file lib/libc/arch/vax/Makefile.inc : 1.6 210 descr 211 It appears necessary to add -I. to CPPFLAGS when building 212 nslesxer.c. This may be caused by gcc 2.95.3 being used. 213 Should be reverted when a newer gcc is ready for vax. 214 kcah 215 216 hack vax gcc 2.95.3 doesn't understand "-std=c99" 217 cdat 5 April 2005 218 who tron 219 file src/share/mk/bsd.sys.mk 220 descr 221 We cannot use "-std=c99" for compiler warning level 4 and above 222 because gcc 2.95.3 doesn't support that option. 223 kcah 224 225port sparc64 226 227 hack binutil-2.11-sparc64-pltrela 228 mdate 14 Aug 2001 229 who eeh 230 file libexec/ld.elf_so/arch/sparc64/mdreloc.c 231 descr 232 The first four PLT entries are reserved. There is some 233 disagreement whether they should have associated relocation 234 entries. Both the SPARC 32-bit and 64-bit ELF specifications 235 say that they should have relocation entries, but the 32-bit 236 SPARC binutils do not generate them, and now the 64-bit SPARC 237 binutils have stopped generating them too. 238 239 To provide binary compatibility, we will check the first entry, 240 if it is reserved it should not be of the type JMP_SLOT. If it 241 is JMP_SLOT, then the 4 reserved entries were not generated and 242 our index is 4 entries too far, so we frob the rela pointer. 243 kcah 244 245 246port arm 247 248 hack gcc-unsigned-compare 249 cdate 09 Mar 2002 250 mdate 18 Mar 2002 251 who bjh21 252 file dist/bind/lib/nameser/ns_parse.c : 1.3 253 file dist/dhcp/minires/ns_parse.c : 1.3 254 file dist/dhcp/omapip/result.c : 1.2 255 file dist/dhcp/server/failover.c : 1.3 256 file gnu/dist/gawk/eval.c : 1.4 257 file gnu/dist/toolchain/bfd/bfd.c : 1.2 258 file gnu/dist/toolchain/bfd/format.c : 1.2 259 file gnu/dist/toolchain/gdb/target.c : 1.2 260 file sys/kern/vfs_subr.c : 1.172 261 descr When checking that a potentially-unsigned enum is >= 0, assign 262 it to an int first. This is necessary to avoid "comparison is 263 always true" warnings with -fshort-enums. Casting to an int 264 really should be enough, but turns out not to be. 265 kcah 266 267 hack gcc 3.3.2/arm sys/kern/uipc_socket.c 268 cdate Tue Oct 28 18:02:16 GMT 2003 269 who skrll 270 pr 23044 271 file sys/arch/arm/conf/Makefile.arm : 1.19 272 descr 273 Performing a build.sh tools on a CATS with NFS mounted 274 obj and src directories results in "panic: receive 1" 275 The hack is to compile sys/kern/uipc_socket.c with 276 -fno-strict-aliasing 277 kcah 278 279 280port pc532 281 282 hack egcs-pc532-ip6_mroute 283 cdate 09 Jul 2002 284 who simonb 285 file sys/arch/pc532/conf/Makefile.pc532 : 1.70 286 file sys/arch/pc532/conf/files.pc532 : 1.47 287 descr 288 egcs 1.1.2 gets an "internal error--insn does not satisfy its 289 constraints" error compiling ip6_mroute.c with -O2 or greater. 290 -O1 works around this problem. 291 kcah 292 293 hack gcc-pc532-duffs_device 294 cdate Mon Oct 27 07:23:05 UTC 2003 295 who simonb 296 file sys/arch/pc532/conf/Makefile.pc532 : 1.71 297 file sys/arch/pc532/conf/files.pc532 : 1.52 298 pr GCC PR optimization/5230 299 descr 300 gcc incorrectly gives an "unreachable code at beginning of 301 switch statement" for a Duff's device construct in 302 arch/pc532/dev/ncr.c. There is no way to disable just this 303 warning, so -Wno-error is turned on for this file. 304 kcah 305 306 hack gcc332-cppmacro-ice 307 cdate Sun Dec 7 12:48:33 UTC 2003 308 who simonb 309 file gnu/usr.bin/gcc3/libcpp/Makefile : 1.2 310 descr 311 gcc 3.3.2 gets an ICE when compiling cppmacro.c with -O2. 312 The hack is to use -O1 for this file. Fixed in gcc 313 -current mainline, unable to work out where the fix is 314 right now. 315 kcah 316 317 318port sh3 319 320 hack gcc-sh3-sed 321 mdate 23 Apr 2002 322 who thorpej 323 file usr.bin/sed/Makefile : 1.9 : 9 : 13 324 descr 325 The in-tree GCC 2.95.3-based compiler ICEs when building 326 with optimization for SuperH. Hack is to build with -O0. 327 kcah 328 329 330port sh5 331 332 hack SuperH SH5 Toolchain Bugs 333 cdate 11 Jul 2002 334 who scw 335 file usr.sbin/ndbootd/ndbootd.c : 1.6 336 file usr.sbin/traceroute/traceroute.c : 1.48 337 descr 338 The SuperH SH5 toolchain (2.97-sh5-010522) gets an internal 339 compiler error when assigning a bit-wise inverted value 340 under some circumstances. 341 Work around it by splitting the statement into two. 342 kcah 343 344 hack SuperH SH5 Toolchain Bugs 345 cdate 17 May 2003 346 who scw 347 file lib/libpthread/pthread_lock.c : 1.7 348 descr 349 The SuperH SH5 toolchain generates incorrect PIC code when 350 faced with a symbol which is declared extern, but has local 351 scope due to being defined within an asm() statement (without 352 being declared .globl in that statement). Work around it by 353 adding the .globl. 354 kcah 355 356 hack gcc 3.3.2 on sh5 - ICE compiling reload1.c at -O2 357 cdate Sun Dec 7 19:44:05 GMT 2003 358 who scw 359 file gnu/usr.bin/gcc3/backend/Makefile : 1.13 360 descr 361 Gcc3 for sh5 gets an ICE compiling reload1.c at -O2. 362 Drop to -O1 for now when building for sh5. 363 kcah 364 365 hack gcc 3.3.2 on sh5 - ICE compiling elf32.c/elf64.c at -O2 366 cdate Sun Dec 7 21:10:46 GMT 2003 367 who scw 368 file gnu/lib/libbfd/Makefile : 1.39 369 descr 370 Gcc3 for sh5 gets an ICE compiling libbfd's elf32.c 371 and elf64.c at -O2. 372 Drop to -O1 for now when building for sh5. 373 kcah 374 375 376 hack gcc 3.3.2 on sh5 - fatal warning compiling function.c 377 cdate Sun Dec 7 19:44:05 GMT 2003 378 who scw 379 file gnu/usr.bin/gcc3/backend/Makefile : 1.13 380 descr 381 Gcc3 for sh5 issues a warning: 382 .../gnu/dist/gcc/gcc/function.c:4742: warning: `and' of 383 mutually exclusive equal-tests is always 0. 384 This causes the build to fail because of -Werror. 385 Work-around by defining NOGCCERROR when building for sh5. 386 kcah 387 388 hack gcc 3.3.3 on sh5 - ICE compiling rbtdb.c and rbtdb64.c 389 cdate Thu Nov 11 00:35:33 UTC 2004 390 who he 391 file usr.sbin/bind/libdns/Makefile/1.2 392 descr 393 Gcc3 for sh5 gets an ICE compiling these files at -O2. 394 Drop to -O1 for now when building for sh5. 395 kcah 396 397 hack gcc 3.3.3 nb3 on sh5 - ICE compiling bsd-comp.c 398 cdate Thu May 25 23:05:20 UTC 2005 399 who he 400 file sys/lkm/net/bsdcomp/Makefile : 1.3 401 descr 402 Gcc3 for sh5 gets an ICE compiling this at -O2, 403 "could not split insn". Drop to -O1 for sh5. 404 kcah 405 406port sun2 407 408 hack gcc 3.3.2/mdsetimage 409 cdate Tue Oct 28 18:43:05 EST 2003 410 who fredette 411 file gnu/usr.sbin/mdsetimage/Makefile : 1.15 412 descr 413 mdsetimage.c causes cc1 to barf for as-yet unknown reasons. 414 this hack uses -O0 to avoid the problem. 415 kcah 416 417 hack gcc 3.3.2/installboot/ffs.c 418 cdate Tue Oct 28 18:43:05 EST 2003 419 who fredette 420 file usr.sbin/installboot/Makefile : 1.26 421 descr 422 ffs.c causes cc1 to barf for as-yet unknown reasons. this 423 hack uses -O0 to avoid the problem. 424 kcah 425 426 427port sun2 m68k 428 429 hack gcc 3.3.2/gcc/ra-colorize.c 430 cdate Wed Nov 5 11:03:13 EST 2003 431 who mrg 432 file gnu/usr.bin/gcc3/backend/Makefile : 1.11 433 descr 434 ra-colorize.c causes a whole spew of unreferenced .L* local 435 symbols. using -O0 (or even -O2 reportedly) avoids the problem. 436 kcah 437 438port sparc64 439 440 hack disable optimzations for uvm_bio.c on 32 bit kernels 441 cdate Sun Mar 21 14:14:04 MET 2004 442 who martin 443 file sys/arch/sparc64/conf/Makefile.sparc64 : 1.53-1.54 444 file sys/arch/sparc64/conf/files.sparc64 : 1.93 445 descr 446 The sparc compiler miscompiles uvm_bio.c when using 447 any optimization. This results in ubc_release panics. 448 kcah 449 450port macppc 451 452 hack remove inline from rotate_{left,right} 453 cdate Tue Feb 22 13:43:25 EST 2005 454 who christos 455 file src/dist/bind/lib/dns/rbt.c 456 descr 457 The macppc gcc-3.3 compiler miscompiles rbt.c when these 458 functions are inlined. The error is: 459 .* named[368]: rbt.c:1584: INSIST(child != (void *)0) >failed 460 .* named[368]: exiting (due to assertion failure) 461 This is reportedly fixed in gcc-3.4 462 kcah 463 464port hppa 465 466 hack hppa-gcc-3.3.3/grep/dfa.c 467 cdate Sun Aug 8 08:34:32 PDT 2004 468 who chs 469 file gnu/usr.bin/grep/grep/Makefile : 1.4 470 descr 471 gcc 3.3.3 generates bad code for dfa.c with -O2, 472 reduce optimization to -O1 to avoid the bug. 473 kcah 474 475 hack hppa boot-from-disk memory corruption 476 cdate Wed May 18 06:56:07 PDT 2005 477 who chs 478 file src/sys/dev/scsipi/scsipiconf.h : 1.98 479 descr 480 There is some bug with DMA on hppa that corrupts scsipi_xfer 481 structures, but it only shows up when booting from disk. 482 For now, we'll add some padding to scsipi_xfer so that 483 the corrupted memory is not otherwise used. 484 kcah 485 486port mips 487 488 hack mips-shared-linker-load-address 489 cdate Fri Oct 7 08:33:10 UTC 2005 490 who simonb 491 file src/sys/kern/exec_elf32.c : 1.107 492 descr 493 With COMPAT_16 or previous enabled (which enables 494 ELF_INTERP_NON_RELOCATABLE) a recent ld.elf_so will 495 load and run at address 0. The check to fix this in 496 rev 1.107 only checks the first psection of the ELF 497 executable, which may not be loadable. A more correct 498 fix is to check the first loadable psection instead of 499 just the first psection. 500 kcah 501