tech-toolchain archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Build of NetBSD-6.1RC2/amd64 fails



On 2013-03-31, at 16:50, Greg Troxel <gdt%ir.bbn.com@localhost> wrote:

> 
> I'm out of ideas (except to read the compiler source about rpath), but
> please post when you figure it out.
> (I build on -5 and -6 and mac, not -current.)

Have not had chance to investigate the ld source code yet but I've found two 
ways that avoids the error.

For reference, here is the original compilation step that fails:

/usr/src/tooldir/bin/x86_64--netbsd-gcc 
--sysroot=/usr/src/obj.amd64/destdir.amd64 -o npfctl  npfctl.o npf_var.o 
npf_data.o npf_ncgen.o npf_build.o npf_extmod.o npf_disassemble.o npf_scan.o 
npf_parse.o -lnpf -lprop -lcrypto -lutil -ly 
-Wl,-dynamic-linker=/libexec/ld.elf_so -Wl,-rpath,/lib  -L=/lib

And the error message is:

/lib/libcrypt.so.1: undefined reference to `__explicit_bzero'
collect2: ld returned 1 exit status

The reason for the error is that ld uses /lib/libcrypt.so.1 (which is from 
NetBSD-current) rather than the netbsd-6 version in 
/usr/src/obj.amd64/destdir.amd64/lib/libcrypt.so.1.

Either of the following two modifications will make ld pick the correct library:

1) Removing the "-Wl,-rpath,/lib" flag makes ld use the correct library 
(presumably because ld's default search paths /lib and /use/lib are not 
searched without the --sysroot path prefix). Also removing "-L=/lib" is OK 
(still works).

2) Replacing "-Wl,-rpath,/lib" with "-Wl,-rpath,lib" (without the initial /) 
similarly causes the /usr/src/obj.amd64/destdir.amd64/lib/libcrypt.so.1 to be 
used and avoids the error. Also replacing "-L=/lib "with "-L=lib" is OK. I note 
that ld looks for lib/libcrypt.so.1 (in the current directory) before adding 
the --sysroot path (from ktrace).

Based on this, it appears that ld only prepends the --sysroot path if the 
specified prefix fails, either because the lib file is not found or because it 
is the wrong type (as in my i386 cross compilation). This suggests the 
following changes to the library paths in the build makefiles:

Remove all -Wl,-rpath,/lib or -L=/lib flags. These are handled by the sysroot 
flag in combination with the default search paths.

Replace any non-standards search paths, e.g., "-Wl,-rpath,/usr/mylib" with 
"-Wl,-rpath,usr/mylib".


Regards,
Sverre

PS I'm copying tech-toochain as that seems like the better place for this.



Home | Main Index | Thread Index | Old Index