From owner-freebsd-bugs@FreeBSD.ORG Fri Apr 28 16:40:19 2006 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DDE3916A40A for ; Fri, 28 Apr 2006 16:40:18 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 67FBE43D6D for ; Fri, 28 Apr 2006 16:40:13 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id k3SGeD4o063174 for ; Fri, 28 Apr 2006 16:40:13 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id k3SGeDrR063173; Fri, 28 Apr 2006 16:40:13 GMT (envelope-from gnats) Resent-Date: Fri, 28 Apr 2006 16:40:13 GMT Resent-Message-Id: <200604281640.k3SGeDrR063173@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Thomas Quinot Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 21EE916A402 for ; Fri, 28 Apr 2006 16:33:38 +0000 (UTC) (envelope-from thomas@FreeBSD.ORG) Received: from melamine.cuivre.fr.eu.org (melusine.cuivre.fr.eu.org [82.225.155.84]) by mx1.FreeBSD.org (Postfix) with ESMTP id 90C2443D53 for ; Fri, 28 Apr 2006 16:33:37 +0000 (GMT) (envelope-from thomas@FreeBSD.ORG) Received: by melamine.cuivre.fr.eu.org (Postfix, from userid 1000) id F2BDA5C493; Fri, 28 Apr 2006 18:33:35 +0200 (CEST) Message-Id: <20060428163335.GA72671@melamine.cuivre.fr.eu.org> Date: Fri, 28 Apr 2006 18:33:35 +0200 From: Thomas Quinot To: FreeBSD-gnats-submit@FreeBSD.org Cc: Subject: gnu/96481: native ld(1) does not look for shared libs in LD_LIBRARY_PATH X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Apr 2006 16:40:19 -0000 >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: