Subject: How symbol renaming / linker warnings can break thinks...
To: None <tech-toolchain@netbsd.org>
From: None <drochner@zel459.zel.kfa-juelich.de>
List: tech-toolchain
Date: 12/03/1998 18:01:45
I just tried to compile the new ddd (debugger) from the
package collection, which failed when it tried the GNU
"libiberty" because of conflicting definitions of sys_errlist
and sys_nerr. (on an -current system)
The reason this happens is somewhat subtle, and our library
and toolchain are not to blame in principle. But this is
existing and popular software, so it would be good to fix
it in one or the other way.

"libiberty" tries to figure out which of the functions
it is able to provide. Citing from the README:
> So needed-list is first made.  The needed-list rule compiles dummy.c.
> Because dummy.c includes functions.def, the resulting object file will
> contain a call to each of the optional functions (for simplicity
> assume each optional file defines a single function).  This object
> file will be linked against the standard libraries (as defined by
> using $(CC) and various flags).  Any function missing will causes the
> linker to emit an error message.  We assume the name of the missing
> function(s) are in the error message(s). The awk script
> find-needed.awk has been generated from functions.def.  It is used to
> search the linker output messages for words that match the functions
> listed in functions.def.  The list of functions found is written on a
> single line to the file needed-list. 

The actual linker output is:
> dummy.o: Undefined symbol `_insque' referenced from text segment
> dummy.o: warning: tmpnam() possibly used unsafely, use mkstemp() or
> mkdtemp() dummy.o: warning: reference to compatibility vfork();
> include <unistd.h> for correct reference dummy.o: warning: reference
> to compatibility sys_nerr; include <errno.h> for correct reference
> dummy.o: warning: reference to compatibility sys_errlist[]; include
> <errno.h> for correct reference dummy.o: warning: reference to
> compatibility sys_siglist[]; include <signal.h> or <unistd.h> for
> correct reference dummy.o: Undefined symbol `_on_exit' referenced from
> text segment collect2: ld returned 1 exit status 

The awk script doesn't get the difference between a warning
and an error, so it is concluded that there is neither sys_errlist
nor sys_nerr. So own declarations/definitions are switched on,
leading to the conflicts.

So, what now?

best regards
Matthias