HACKS revision 1.2
1# $NetBSD: HACKS,v 1.2 2003/03/28 21:15:20 he 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 specific knowledge of xterm escapes in curses code 31cdate Wed, 11 Sep 2002 18:23:25 +0300 32who jdc 33port all 34file lib/libcurses/setterm.c : 1.33 35descr 36 Recognise that "\E[m" will turn off all attributes for xterm-like 37 terminals. Without this hack, we can't tell when turning off one 38 attribute affects another (which we check by comparing sequences). 39kcah 40 41hack gcc 2.95/vax cannot handle __builtin_ffs() 42cdate Fri Aug 23 21:31:15 CEST 2002 43who ragge 44port vax 45file sys/lib/libkern/libkern.h : 1.42 46descr 47 __builtin_ffs() is ifdef'd away if __vax__. Matt Thomas has added 48 this feature to GCC 3 so it can be removed when switching. 49kcah 50 51hack gcc 2.95.3 -O2 bug 52cdate Sun Jan 6 23:17:28 UTC 2002 53who lukem 54port alpha 55file sbin/newfs/mkfs.c : (all?) 56pr 15156 57descr 58 newfs built with gcc -O2 dumps core part-way through. 59 using -O1 avoids the problem 60kcah 61 62hack binutil-2.11-sparc64-pltrela 63mdate 14 Aug 2001 64who eeh 65port sparc64 66file libexec/ld.elf_so/reloc.c: 1.41 : 597 : 619 67descr 68 The first for PLT entries are reserved. There is some disagreement 69 whether they should have associated relocation entries. Both the 70 SPARC 32-bit and 64-bit ELF specifications say that they should have 71 relocation entries, but the 32-bit SPARC binutils do not generate 72 them, and now the 64-bit SPARC binutils have stopped generating them 73 too. 74 75 To provide binary compatibility, we will check the first entry, if it 76 is reserved it should not be of the type JMP_SLOT. If it is JMP_SLOT, 77 then the 4 reserved entries were not generated and our index is 4 78 entries too far, so we frob the rela pointer. 79kcah 80 81hack gcc-arm32-schedule 82mdate 04 May 2000 83who is 84file lib/libc/stdlib/strtoull.c : 1.3 : 78 : 81 85file lib/libc/stdlib/strtouq.c : 1.15 : 73 : 76 86pr 9613 87descr 88 strtoull() was returning a wrong result for small numbers with bit 31 89 set. This is a gcc/arm32 compiler bug in gcc < 2.95.2. Adding 90 (void)&acc; works around it. 91kcah 92 93hack gcc-sparc64-memorysize 94mdate 17 Sep 2000 95who mrg 96port sparc64 97file lib/libc/hash/sha1.c : 1.6 : 78 : 129 : 162 : 189 98file sys/lib/libkern/sha1.c : 1.6 : 78 : 129 : 162 : 189 99file usr.sbin/bind/lib/Makefile : 1.14 : 87 : 91 100descr 101 the normal SHA1Transform() function causes the sparc64 compiler to 102 use excessive amounts of memory attempting to optimise this function. 103 using no optimisation allows the function to build. this hack 104 splits the mathematical functions inside SHA1Transform() into 4 105 separate functions, which avoids the optimiser explosion. 106kcah 107 108hack gcc-sparc64-double-arguments 109mdate 18 Sep 2000 110who mrg 111port sparc64 112file xsrc/xc/lib/fonts/Type1/type1.c : 1.2 : 1461 : 1507 : 1702 : 1709 113descr 114 in passing 17 "double" arguments to a function, gcc incorrectly tries 115 to use a register that doesn't exist, causing an internal error. this 116 hack changes the way arguments are passed to the function, such that 117 a pointer to a "double" (really an array) is passed, and the old 118 arguments are assigned within the function. 119kcah 120 121hack gcc-sparc64-gawk 122mdate 28 Oct 2000 123who mrg 124port sparc64 125file gnu/usr.bin/gawk/Makefile : 1.11 : 21 : 24 126descr 127 gcc fails to build gawk properly, due to double floating point bugs. 128 this simple test program will fail to print ``ab'': 129 BEGIN { f = "abc"; print substr(f, 1, 2); exit } 130 the work around is simple: use -msoft-quad-float. 131kcah 132 133hack gcc-sparc64-libgcc 134mdate 01 Dec 2001 135who jmc 136port sparc64 137file gnu/lib/libgcc/Makefile : 1.29 : 24 : 27 138descr 139 gcc fails to do double -> int conversions correctly without 140 soft-quad-float. Add it in there for the internal conversion 141 routines. This appears to be more than likely emulations bugs than 142 compiler bugs as the assembly looks correct on the surface. 143 144kcah 145 146hack gcc-sparc64-iostat-systat 147mdate 04 Feb 2001 148who mrg 149port sparc64 150file usr.sbin/iostat/Makefile : 1.17 : 7 : 10 151file usr.bin/systat/Makefile : 1.23 : 6 : 9 152descr 153 gcc fails to build iostat properly, due to double floating point bugs. 154 results will include "Inf" and other garbage. 155 the work around is simple: use -msoft-quad-float. 156kcah 157 158hack gcc-sparc64-nawk 159mdate 25 Oct 2001 160who martin 161port sparc64 162file usr.bin/awk/Makefile : 1.3 : 13 : 15 163descr 164 Don't use long double on sparc64. 165kcah 166 167hack gcc-sparc64-ntp 168mdate 12 Nov 2000 169who martin 170port sparc64 171file usr.sbin/ntp/Makefile.inc : 1.5 : 17 : 19 172descr 173 gcc fails to build ntpd properly, due to double floating point bugs. 174 Ntpd will fail to decode incoming packets; ntpdc -s will report 175 a delay, offset and dispersion of 0.0000 for all peers. 176 the work around is simple: use -msoft-quad-float. 177kcah 178 179hack gcc-sparc64-x_dhclient 180mdate 27 Dec 2000 181who mrg 182port sparc64 183file distrib/utils/x_dhclient/Makefile : 1.6 : 28 : 30 184descr 185 gcc fails with an ICE while building dhclient's parse.c with -O2 186 and -Os. the work around is simple: don't use -Os. 187kcah 188 189hack lint-no-long-double 190mdate 17 Aug 2001 191who eeh 192port sparc64 193file usr.bin/xlint/lint1/param.h: 1.14 : 194descr 195 Don't use long double on sparc64. 196kcah 197 198hack netstat ieee1394 address printing. 199mdate 14 Nov 2000 200who matt 201file lib/libc/net/getnameinfo.c : 1.32 : 497 : 503 202descr 203 Because the current implementation of IP over IEEE1394, the 204 fw device address contains more than just the IEEE1394 EUI-64. 205 So when printing out IEEE1394 addresses, ignore the extra stuff. 206kcah 207 208hack xterm vs. libterm 209mdate 01 Aug 2000 210who jdc 211file xsrc/xc/programs/xterm/main.c : 1.2 : 3609 : 3614 212pr 10383 213descr 214 In order to extend the termcap string over 1023 bytes, a ZZ entry was 215 introduced to point to a memory location containing the full entry. 216 Without this hack, xterm will export a termcap containing the ZZ 217 entry, which will then be ignored by libterm. As xterm modifies the 218 exported termcap, this would cause those modifications to be ignored. 219kcah 220 221hack gcc-3-libtelnet 222mdate 29 Jan 2002 223who thorpej 224file lib/libtelnet/Makefile : 1.14 : 14 : 17 225descr 226 GCC 3.x issues a spurious warning when compiling a Duff's Device 227 with optimization, even though it compiles the file correctly. 228 GCC PR optimization/5230. kerberos.c contains a Duff's Device 229 in the checksum routine. Hack is to build libtelnet w/o optimization 230 if HAVE_GCC3 is set. 231kcah 232 233hack gcc-sh3-sed 234mdate 23 Apr 2002 235who thorpej 236file usr.bin/sed/Makefile : 1.9 : 9 : 13 237descr 238 The in-tree GCC 2.95.3-based compiler ICEs when building 239 with optimization for SuperH. Hack is to biuld with -O0. 240kcah 241 242hack gcc-unsigned-compare 243cdate 09 Mar 2002 244mdate 18 Mar 2002 245who bjh21 246port arm 247file dist/bind/lib/nameser/ns_parse.c : 1.3 248file dist/dhcp/minires/ns_parse.c : 1.3 249file dist/dhcp/omapip/result.c : 1.2 250file dist/dhcp/server/failover.c : 1.3 251file gnu/dist/gawk/eval.c : 1.4 252file gnu/dist/toolchain/bfd/bfd.c : 1.2 253file gnu/dist/toolchain/bfd/format.c : 1.2 254file gnu/dist/toolchain/gdb/target.c : 1.2 255file sys/kern/vfs_subr.c : 1.172 256descr When checking that a potentially-unsigned enum is >= 0, assign it 257 to an int first. This is necessary to avoid "comparison is always 258 true" warnings with -fshort-enums. Casting to an int really should 259 be enough, but turns out not to be. 260kcah 261 262hack wi-at-big-endian-bus 263cdate 15 Mar 2002 264who martin 265file dev/ic/wireg.h 266descr Add an option to access the underlying bus in big endian byte order 267 to work around deficiencies in bus_space_{read,write}_* macros. 268 Those don't allow the implementation of a proper pcmcia bus space 269 tag. 270kcah 271 272hack gcc 2.95.3 -O2 (-fgcse) bug 273cdate Sun May 5 18:36:04 UTC 2002 274who tsutsui 275port macppc 276file sys/arch/macppc/dev/adb_direct.c: 1.24 : 1895 : 1896 277pr 16678 278descr 279 gcc-2.95.3 does generates wrong code on optimization 280 by gcc -O2 (-fgcse), and adb_read_date_time() returns 281 wrong value on cuda system. 282 A null asm statement has been added to avoid this for workaround. 283kcah 284 285hack gcc-vax-libbz2 286mdate 27 Jun 2002 287who thorpej 288port vax 289file lib/libbz2/Makefile 290descr 291 libbz2 is mis-compiled with optimization with GCC 2.95.3 292 on VAX. -O0 works around this problem. 293kcah 294 295hack egcs-pc532-ip6_mroute 296cdate 09 Jul 2002 297who simonb 298port pc532 299file sys/arch/pc532/conf/Makefile.pc532 : 1.70 300file sys/arch/pc532/conf/files.pc532 : 1.47 301descr 302 egcs 1.1.2 gets an "internal error--insn does not satisfy its 303 constraints" error compiling ip6_mroute.c with -O2 or greater. 304 -O1 works around this problem. 305kcah 306 307hack SuperH SH5 Toolchain Bugs 308cdate 11 Jul 2002 309who scw 310port sh5 311file usr.sbin/ndbootd/ndbootd.c : 1.6 312file usr.sbin/traceroute/traceroute.c : 1.48 313descr 314 The SuperH SH5 toolchain (2.97-sh5-010522) gets an internal 315 compiler error when assigning a bit-wise inverted value 316 under some circumstances. 317 Work around it by splitting the statement into two. 318kcah 319 320hack vax Toolchain bug 321cdate 28 Mar 2003 322who he 323port vax 324file sys/arch/vax/vax/intvec.S : 1.5 325descr 326 Workaround for PR toolchain/20924. The assembler apparently 327 tries to range-check byte offsets when it doesn't have 328 sufficient information to make that decision. 329 Workaround uses `brw' instead of `brb' instruction. 330kcah 331