Subject: toolchain/18858: toolchain build breaks due to bugs in Gcc/fortan host tool bug
To: None <gnats-bugs@gnats.netbsd.org>
From: None <rafal@netbsd.org>
List: netbsd-bugs
Date: 10/30/2002 03:02:15
>Number:         18858
>Category:       toolchain
>Synopsis:       toolchain build breaks due to bugs in Gcc/fortan host tool bug
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    toolchain-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Oct 30 00:03:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Rafal
>Release:        NetBSD 1.6J
>Organization:
Insomniac Hackers Anonymous: We don't need no steenkin' sleep
>Environment:
System: NetBSD groo-the-wanderer 1.6J NetBSD 1.6J (STINKPAD) #2: Tue Oct 29 22:10:04 EST 2002 rafal@groo-the-wanderer:/usr/rafal/netbsd-src/sys/arch/i386/compile/STINKPAD i386
Architecture: i386
Machine: i386
>Description:
	My toolchain build has been dying consistently in one spot, yet when
	I re-run things by hand, the build generally completes.  Here's the
	tail of my log:

[...]
cc -c -DCROSS_COMPILE -DIN_GCC    -O   -DHAVE_CONFIG_H  -I. -I.. -I/usr/rafal/netbsd-src/tools/toolchain/../../gnu/dist/toolchain/gcc/f -I/usr/rafal/netbsd-src/tools/toolchain/../../gnu/dist/toolchain/gcc/f/.. -I/usr/rafal/netbsd-src/tools/toolchain/../../gnu/dist/toolchain/gcc/f/../config -I/usr/rafal/netbsd-src/tools/toolchain/../../gnu/dist/toolchain/gcc/f/../../include  `echo /usr/rafal/netbsd-src/tools/toolchain/../../gnu/dist/toolchain/gcc/f/fini.c | sed 's,^\./,,'` -o fini.o
cc -c -DUSE_HCONFIG -DCROSS_COMPILE -DIN_GCC    -O   -DHAVE_CONFIG_H  -I. -I.. -I/usr/rafal/netbsd-src/tools/toolchain/../../gnu/dist/toolchain/gcc/f -I/usr/rafal/netbsd-src/tools/toolchain/../../gnu/dist/toolchain/gcc/f/.. -I/usr/rafal/netbsd-src/tools/toolchain/../../gnu/dist/toolchain/gcc/f/../config -I/usr/rafal/netbsd-src/tools/toolchain/../../gnu/dist/toolchain/gcc/f/../../include  `echo /usr/rafal/netbsd-src/tools/toolchain/../../gnu/dist/toolchain/gcc/f/proj.c | sed 's,^\./,,'` -o proj-h.o
cc -DCROSS_COMPILE -DIN_GCC    -O   -DHAVE_CONFIG_H  -o fini fini.o proj-h.o
./fini `echo /usr/rafal/netbsd-src/tools/toolchain/../../gnu/dist/toolchain/gcc/f/str-1t.fin | sed 's,^\./,,'` str-1t.j str-1t.h
./fini `echo /usr/rafal/netbsd-src/tools/toolchain/../../gnu/dist/toolchain/gcc/f/str-2t.fin | sed 's,^\./,,'` str-2t.j str-2t.h
./fini `echo /usr/rafal/netbsd-src/tools/toolchain/../../gnu/dist/toolchain/gcc/f/str-fo.fin | sed 's,^\./,,'` str-fo.j str-fo.h
/usr/rafal/netbsd-src/tools/toolchain/../../gnu/dist/toolchain/gcc/f/str-fo.fin: extraneous "$"
*** Error code 1

Stop.
nbmake: stopped in /usr/rafal/netbsd-src/tools/toolchain/obj/build/gcc/f
*** Error code 1
[...]

	The crux of the problem is that the `fini' tool plays fast-and-loose
	with its' list structures, assuming it can simply treat the head of
	the list as a node (which it isn't.. It only contains pointers to 
	the first and last entries, and none of the other info a "real"
	node contains).

	The tool doesn't make this distinction, and can in certain cases,
	attempt to compare the currently being processed string to a node
	pointer in the array of list heads rather than a name in a real
	node... Depending on the addesses returned by malloc(), this may
	actually match(!), esp. if the string being processed is only one
	character long.

>How-To-Repeat:
	On my system:
		cd $NETBSDSRCDIR
		./build.sh -t 

	This also appears to have bitten the autobuild system a while ago,
	see the following URL for the tail of that build log:
	http://releng.netbsd.org/ab/M_dreamcast/dreamcast.relse.1022198400.txt

>Fix:

Index: fini.c
===================================================================
RCS file: /cvsroot/gnusrc/gnu/dist/toolchain/gcc/f/fini.c,v
retrieving revision 1.1.1.1
diff -b -u -p -r1.1.1.1 fini.c
--- fini.c	2000/07/26 00:17:58	1.1.1.1
+++ fini.c	2002/10/30 07:42:23
@@ -418,7 +418,8 @@ main (int argc, char **argv)
       while ((n->next != (name) &names[len])
 	     && (strcmp (buf, n->next->name_uc) > 0))
 	n = n->next;
-      if (strcmp (buf, n->next->name_uc) == 0)
+      if (n->next != (name) &names[len] 
+	  && strcmp (buf, n->next->name_uc) == 0)
 	{
 	  fprintf (stderr, "%s: extraneous \"%s\"\n", input_name, buf);
 	  do_exit = TRUE;
>Release-Note:
>Audit-Trail:
>Unformatted:
 		(also bit me with a 1.6I source tree running 1.6I and 1.6E 
 		 kernels and 1.6E/1.6I userlands)