HACKS revision 1.44
1# $NetBSD: HACKS,v 1.44 2005/05/06 19:32:30 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 can't handle __used__ in mcount.c
117	cdate	Fri May  6 14:30:53 CDT 2005
118	who	jmc
119	file	src/lib/libc/gmon/mcount.c 1.17
120	descr
121                Recent changes to mark this as __used__ to prevent optimization
122                away on sparc64 don't work on 2.95 vax. Ifdef'd back in the
123                old __unused__ if on vax.
124	
125	hack	gcc 2.95/vax cannot handle __builtin_ffs()
126	cdate	Fri Aug 23 21:31:15 CEST 2002
127	who	ragge
128	file	sys/lib/libkern/libkern.h : 1.42
129	descr
130		__builtin_ffs() is ifdef'd away if __vax__. Matt Thomas has
131		added this feature to GCC 3 so it can be removed when switching.
132	
133
134	hack	gcc-vax-libbz2
135	mdate	27 Jun 2002
136	who	thorpej
137	file	lib/libbz2/Makefile
138	descr
139		libbz2 is mis-compiled with optimization with GCC 2.95.3
140		on VAX.  -O0 works around this problem.
141	kcah
142
143	hack	gawk
144	mdate	8 Nov 2003
145	who	ragge
146	file	gnu/usr.bin/gawk/Makefile
147	descr
148		gawk is mis-compiled with optimization with GCC 2.95.3
149		on VAX.  -O0 works around this problem.
150	kcah
151
152	hack	vax Toolchain bug
153	cdate	28 Mar 2003
154	who	he
155	file	sys/arch/vax/vax/intvec.S : 1.5
156	descr
157		Workaround for PR toolchain/20924.  The assembler apparently
158		tries to range-check byte offsets when it doesn't have
159		sufficient information to make that decision.
160		Workaround uses `brw' instead of `brb' instruction.
161	kcah
162
163	hack	vax gcc 2.95.3 -Wuninitialized workarounds
164	cdate	6 Nov 2003
165	who	he
166	file	sys/dev/bi/if_ni.c : 1.22
167	file	sys/arch/vax/vax/ctu.c : 1.20
168	descr
169		Workaround for gcc 2.95.3 failing to detect that certain
170		variables will be initialized; so that this code compiles
171		with -Wuninitialized.  Should be reviewed and possibly
172		reverted when gcc 3.3.2 is ready for vax.
173	kcah
174
175	hack	vax gcc 2.95.3 structure initialization
176	cdat	13 May 2004
177	who	cl
178	file	sys/miscfs/kernfs/kernfs_vnops.c : 1.104
179	descr
180		Workaround for gcc 2.95.3 failing to initialize structures
181		and/or unions inside structures using nested designators.
182		Should be reverted when gcc >=3.3.3 is ready for vax.
183	kcah
184
185	hack	vax gcc 2.95.3 needs -I. to build nslexer.c
186	cdat	6 Jun 2004
187	who	mhitch
188	file	lib/libc/arch/vax/Makefile.inc : 1.6
189	descr
190		It appears necessary to add -I. to CPPFLAGS when building
191		nslesxer.c.  This may be caused by gcc 2.95.3 being used.
192		Should be reverted when a newer gcc is ready for vax.
193	kcah
194
195	hack	vax gcc 2.95.3 doesn't understand "-std=c99"
196	cdat	5 April 2005
197	who	tron
198	file	src/share/mk/bsd.sys.mk
199	descr
200		We cannot use "-std=c99" for compiler warning level 4 and above
201		because gcc 2.95.3 doesn't support that option.
202	kcah
203
204port	sparc64
205
206	hack	binutil-2.11-sparc64-pltrela
207	mdate	14 Aug 2001
208	who	eeh
209	file	libexec/ld.elf_so/arch/sparc64/mdreloc.c
210	descr
211		The first four PLT entries are reserved.  There is some
212		disagreement whether they should have associated relocation
213		entries.  Both the SPARC 32-bit and 64-bit ELF specifications
214		say that they should have relocation entries, but the 32-bit
215		SPARC binutils do not generate them, and now the 64-bit SPARC
216		binutils have stopped generating them too.
217
218		To provide binary compatibility, we will check the first entry,
219		if it is reserved it should not be of the type JMP_SLOT.  If it
220		is JMP_SLOT, then the 4 reserved entries were not generated and
221		our index is 4 entries too far, so we frob the rela pointer.
222	kcah
223
224
225port	arm
226
227	hack	gcc-unsigned-compare
228	cdate	09 Mar 2002
229	mdate	18 Mar 2002
230	who	bjh21
231	file	dist/bind/lib/nameser/ns_parse.c : 1.3
232	file	dist/dhcp/minires/ns_parse.c : 1.3
233	file	dist/dhcp/omapip/result.c : 1.2
234	file	dist/dhcp/server/failover.c : 1.3
235	file	gnu/dist/gawk/eval.c : 1.4
236	file	gnu/dist/toolchain/bfd/bfd.c : 1.2
237	file	gnu/dist/toolchain/bfd/format.c : 1.2
238	file	gnu/dist/toolchain/gdb/target.c : 1.2
239	file	sys/kern/vfs_subr.c : 1.172
240	descr	When checking that a potentially-unsigned enum is >= 0, assign
241		it to an int first.  This is necessary to avoid "comparison is
242		always true" warnings with -fshort-enums.  Casting to an int
243		really should be enough, but turns out not to be.
244	kcah
245
246	hack	gcc 3.3.2/arm sys/kern/uipc_socket.c
247	cdate	Tue Oct 28 18:02:16 GMT 2003
248	who	skrll
249	pr	23044
250	file	sys/arch/arm/conf/Makefile.arm : 1.19
251	descr
252		Performing a build.sh tools on a CATS with NFS mounted 
253		obj and src directories results in "panic: receive 1"
254		The hack is to compile sys/kern/uipc_socket.c with
255		-fno-strict-aliasing
256	kcah
257
258
259port	pc532
260
261	hack	egcs-pc532-ip6_mroute
262	cdate	09 Jul 2002
263	who	simonb
264	file	sys/arch/pc532/conf/Makefile.pc532 : 1.70
265	file	sys/arch/pc532/conf/files.pc532 : 1.47
266	descr
267		egcs 1.1.2 gets an "internal error--insn does not satisfy its
268		constraints" error compiling ip6_mroute.c with -O2 or greater.
269		-O1 works around this problem.
270	kcah
271
272	hack	gcc-pc532-duffs_device
273	cdate	Mon Oct 27 07:23:05 UTC 2003
274	who	simonb
275	file	sys/arch/pc532/conf/Makefile.pc532 : 1.71
276	file	sys/arch/pc532/conf/files.pc532 : 1.52
277	pr	GCC PR optimization/5230
278	descr
279		gcc incorrectly gives an "unreachable code at beginning of
280		switch statement" for a Duff's device construct in
281		arch/pc532/dev/ncr.c.  There is no way to disable just this
282		warning, so -Wno-error is turned on for this file.
283	kcah
284
285	hack	gcc332-cppmacro-ice
286	cdate	Sun Dec  7 12:48:33 UTC 2003
287	who	simonb
288	file	gnu/usr.bin/gcc3/libcpp/Makefile : 1.2
289	descr
290		gcc 3.3.2 gets an ICE when compiling cppmacro.c with -O2.
291		The hack is to use -O1 for this file.  Fixed in gcc
292		-current mainline, unable to work out where the fix is
293		right now.
294	kcah
295
296
297port	sh3
298
299	hack	gcc-sh3-sed
300	mdate	23 Apr 2002
301	who	thorpej
302	file	usr.bin/sed/Makefile	: 1.9 : 9 : 13
303	descr
304		The in-tree GCC 2.95.3-based compiler ICEs when building
305		with optimization for SuperH.  Hack is to build with -O0.
306	kcah
307
308
309port	sh5
310
311	hack	SuperH SH5 Toolchain Bugs
312	cdate	11 Jul 2002
313	who	scw
314	file	usr.sbin/ndbootd/ndbootd.c : 1.6
315	file	usr.sbin/traceroute/traceroute.c : 1.48
316	descr
317		The SuperH SH5 toolchain (2.97-sh5-010522) gets an internal
318		compiler error when assigning a bit-wise inverted value
319		under some circumstances.
320		Work around it by splitting the statement into two.
321	kcah
322
323	hack	SuperH SH5 Toolchain Bugs
324	cdate	17 May 2003
325	who	scw
326	file	lib/libpthread/pthread_lock.c : 1.7
327	descr
328		The SuperH SH5 toolchain generates incorrect PIC code when
329		faced with a symbol which is declared extern, but has local
330		scope due to being defined within an asm() statement (without
331		being declared .globl in that statement). Work around it by
332		adding the .globl.
333	kcah
334
335	hack	gcc 3.3.2 on sh5 - ICE compiling reload1.c at -O2
336	cdate	Sun Dec  7 19:44:05 GMT 2003
337	who	scw
338	file	gnu/usr.bin/gcc3/backend/Makefile : 1.13
339	descr
340		Gcc3 for sh5 gets an ICE compiling reload1.c at -O2.
341		Drop to -O1 for now when building for sh5.
342	kcah
343
344	hack	gcc 3.3.2 on sh5 - ICE compiling elf32.c/elf64.c at -O2
345	cdate	Sun Dec  7 21:10:46 GMT 2003
346	who	scw
347	file	gnu/lib/libbfd/Makefile : 1.39
348	descr
349		Gcc3 for sh5 gets an ICE compiling libbfd's elf32.c
350		and elf64.c at -O2.
351		Drop to -O1 for now when building for sh5.
352	kcah
353
354
355	hack	gcc 3.3.2 on sh5 - fatal warning compiling function.c
356	cdate	Sun Dec  7 19:44:05 GMT 2003
357	who	scw
358	file	gnu/usr.bin/gcc3/backend/Makefile : 1.13
359	descr
360		Gcc3 for sh5 issues a warning:
361		.../gnu/dist/gcc/gcc/function.c:4742: warning: `and' of
362		    mutually exclusive equal-tests is always 0.
363		This causes the build to fail because of -Werror.
364		Work-around by defining NOGCCERROR when building for sh5.
365	kcah
366
367	hack	gcc 3.3.3 on sh5 - ICE compiling rbtdb.c and rbtdb64.c
368	cdate	Thu Nov 11 00:35:33 UTC 2004
369	who	he
370	file	usr.sbin/bind/libdns/Makefile/1.2
371	descr
372		Gcc3 for sh5 gets an ICE compiling these files at -O2.
373		Drop to -O1 for now when building for sh5.
374	kcah
375
376
377port	sun2
378
379	hack	gcc 3.3.2/mdsetimage
380	cdate	Tue Oct 28 18:43:05 EST 2003
381	who	fredette
382	file	gnu/usr.sbin/mdsetimage/Makefile : 1.15
383	descr
384		mdsetimage.c causes cc1 to barf for as-yet unknown reasons.
385		this hack uses -O0 to avoid the problem.
386	kcah
387
388	hack	gcc 3.3.2/installboot/ffs.c
389	cdate	Tue Oct 28 18:43:05 EST 2003
390	who	fredette
391	file	usr.sbin/installboot/Makefile : 1.26
392	descr
393		ffs.c causes cc1 to barf for as-yet unknown reasons.  this
394		hack uses -O0 to avoid the problem.
395	kcah
396
397
398port	sun2, m68k
399
400	hack	gcc 3.3.2/gcc/ra-colorize.c
401	cdate	Wed Nov  5 11:03:13 EST 2003
402	who	mrg
403	file	gnu/usr.bin/gcc/backend/Makefile : 1.11
404	descr
405		ra-colorize.c causes a whole spew of unreferenced .L* local
406		symbols.  using -O0 (or even -O2 reportedly) avoids the problem.
407	kcah
408
409port	sparc64
410
411	hack	disable optimzations for uvm_bio.c on 32 bit kernels
412	cdate	Sun Mar 21 14:14:04 MET 2004
413	who	martin
414	file	sys/arch/sparc64/conf/Makefile.sparc64 : 1.53-1.54
415	file	sys/arch/sparc64/conf/files.sparc64 : 1.93
416	descr
417		The sparc compiler miscompiles uvm_bio.c when using
418		any optimization. This results in ubc_release panics.
419	kcah
420
421port	macppc
422
423	hack	remove inline from rotate_{left,right}
424	cdate	Tue Feb 22 13:43:25 EST 2005
425	who	christos
426	file	src/dist/bind/lib/dns/rbt.c
427	descr
428		The macppc gcc-3.3 compiler miscompiles rbt.c when these
429		functions are inlined. The error is:
430		.* named[368]: rbt.c:1584: INSIST(child != (void *)0) >failed
431		.* named[368]: exiting (due to assertion failure)
432		This is reportedly fixed in gcc-3.4
433	kcah
434