Date: Fri, 28 Apr 2006 18:33:35 +0200 From: Thomas Quinot <thomas@FreeBSD.org> To: FreeBSD-gnats-submit@FreeBSD.org Subject: gnu/96481: native ld(1) does not look for shared libs in LD_LIBRARY_PATH Message-ID: <20060428163335.GA72671@melamine.cuivre.fr.eu.org> Resent-Message-ID: <200604281640.k3SGeDrR063173@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 96481 >Category: gnu >Synopsis: native ld(1) does not look for shared libs in LD_LIBRARY_PATH >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Apr 28 16:40:12 GMT 2006 >Closed-Date: >Last-Modified: >Originator: Thomas Quinot >Release: FreeBSD 6.1-RC i386 >Organization: >Environment: System: FreeBSD kani 6.1-RC FreeBSD 6.1-RC #0: Mon Apr 24 13:08:50 CEST 2006 root@kani:/usr/obj/usr/src/RELENG_6/sys/KANI i386 >Description: According to man ld: The linker uses the following search paths to locate required shared libraries. [...] 5. For a native linker, the contents of the environment variable "LD_LIBRARY_PATH". But actually this does not occur because the NATIVE variable is never set in genscripts.sh when we build ld. >How-To-Repeat: Unshar the below archive into a fresh directory. Run script 'doit.sh'. A working 'fred' binary should be produced. Currently we get a link error: /usr/bin/ld: warning: libfoo.so, needed by /var/tmp/bug/subbar/libbar.so, not found (try using -rpath or -rpath-link) fred.o(.text+0x1e): In function `main': : undefined reference to `foo' doit.sh: ./fred: not found # This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # fred.c # libbar.c # libfoo.c # doit.sh # echo x - fred.c sed 's/^X//' >fred.c << 'END-of-fred.c' Xint main (void) { return foo () + bar (); } END-of-fred.c echo x - libbar.c sed 's/^X//' >libbar.c << 'END-of-libbar.c' Xint bar (void) { return foo (); } END-of-libbar.c echo x - libfoo.c sed 's/^X//' >libfoo.c << 'END-of-libfoo.c' Xint foo (void) { return 0; } END-of-libfoo.c echo x - doit.sh sed 's/^X//' >doit.sh << 'END-of-doit.sh' Xmkdir subfoo subbar X Xgcc -c -fPIC libfoo.c Xgcc -shared -o subfoo/libfoo.so libfoo.o X Xgcc -c -fPIC libbar.c Xgcc -shared -o subbar/libbar.so -L`pwd`/subfoo libbar.o -lfoo X Xexport LD_LIBRARY_PATH=`pwd`/subfoo:`pwd`/subbar Xgcc -o fred fred.o -L`pwd`/subbar -lbar X X./fred END-of-doit.sh exit >Fix: Index: genscripts.sh =================================================================== RCS file: /usr/ncvs/src/gnu/usr.bin/binutils/ld/genscripts.sh,v retrieving revision 1.6 diff -u -r1.6 genscripts.sh --- genscripts.sh 16 Jun 2004 07:09:37 -0000 1.6 +++ genscripts.sh 28 Apr 2006 16:01:15 -0000 @@ -50,7 +50,10 @@ # Set some flags for the emultempl scripts. USE_LIBPATH will # be set for any libpath-using emulation. - USE_LIBPATH=yes + if [ "x${host}" = "x${target}" ] ; then + NATIVE=yes + fi + USE_LIBPATH=yes # Set the library search path, for libraries named by -lfoo. # If LIB_PATH is defined (e.g., by Makefile) and non-empty, it is used. >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060428163335.GA72671>