This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/39785] New: LD_RUN_PATH ignored


When compiling an application on Solaris (and AIX) gcc does add implicit -L
options to the linker to point to the location of where libgcc_s.so.1 etc.  (I
imagine it does this when a prefix was used that is not in the default ld.so
search path).  This results in the LD_RUN_PATH being silently ignored (LIBPATH
on AIX) which is very confusing and can take a long time to find.

It can be easily demonstrated:

flub@neptune:~/gccbug$ gcc -v
Reading specs from /opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/specs
Target: sparc-sun-solaris2.8
Configured with: ../sources/gcc-4.0.2/configure --prefix=/opt/csw/gcc4
--with-local-prefix=/opt/csw --without-gnu-as --with-as=/usr/ccs/bin/as
--without-gnu-ld --with-ld=/usr/ccs/bin/ld --enable-threads=posix
--enable-shared --enable-multilib --enable-nls --with-included-gettext
--with-libiconv-prefix=/opt/csw --with-x --enable-java-awt=xlib
--with-system-zlib --enable-languages=c,c++,f95,java,objc,ada
Thread model: posix
gcc version 4.0.2
flub@neptune:~/gccbug$ cat test.c 
int main(void) {
        return 0;
}
flub@neptune:~/gccbug$ LD_RUN_PATH=/opt/example.com/lib truss -af -t execve gcc
test.c 
1563:   execve("/opt/csw/gcc4/bin/gcc", 0xFFBFFBE4, 0xFFBFFBF0)  argc = 2
1563:    argv: gcc test.c
1564:   execve("/opt/csw/gcc4/libexec/gcc/sparc-sun-solaris2.8/4.0.2/cc1",
0x0004CE20, 0x00045958)  argc = 11
1564:    argv: /opt/csw/gcc4/libexec/gcc/sparc-sun-solaris2.8/4.0.2/cc1
1564:     -quiet test.c -quiet -dumpbase test.c -mcpu=v7 -auxbase test
1564:     -o /var/tmp//cc1uw7s1.s
1566:   execve("/usr/ccs/bin/as", 0x0004CE20, 0x00045958)  argc = 7
1566:    argv: /usr/ccs/bin/as -Qy -s -xarch=v8 -o /var/tmp//ccqjNacX.o
1566:     /var/tmp//cc1uw7s1.s
1568:   execve("/opt/csw/gcc4/libexec/gcc/sparc-sun-solaris2.8/4.0.2/collect2",
0x0004E248, 0x00045950)  argc = 23
1568:    argv:
1568:     /opt/csw/gcc4/libexec/gcc/sparc-sun-solaris2.8/4.0.2/collect2
1568:     -R /opt/csw/gcc4/lib -Y
1568:     P,/opt/csw/gcc4/lib:/usr/ccs/lib:/usr/lib -Qy
1568:     /opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/crt1.o
1568:     /opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/crti.o
1568:     /usr/ccs/lib/values-Xa.o
1568:     /opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/crtbegin.o
1568:     -L/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2
1568:     -L/usr/ccs/bin -L/usr/ccs/lib
1568:     -L/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/../../..
1568:     /var/tmp//ccqjNacX.o -lgcc -lgcc_eh -lc -lgcc -lgcc_eh -lc
1568:     /opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/crtend.o
1568:     /opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/crtn.o
1570:   execve("/usr/ccs/bin/ld", 0x0004BE80, 0x0004A44C)  argc = 23
1570:    argv: /usr/ccs/bin/ld -R /opt/csw/gcc4/lib -Y
1570:     P,/opt/csw/gcc4/lib:/usr/ccs/lib:/usr/lib -Qy
1570:     /opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/crt1.o
1570:     /opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/crti.o
1570:     /usr/ccs/lib/values-Xa.o
1570:     /opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/crtbegin.o
1570:     -L/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2
1570:     -L/usr/ccs/bin -L/usr/ccs/lib
1570:     -L/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/../../..
1570:     /var/tmp//ccqjNacX.o -lgcc -lgcc_eh -lc -lgcc -lgcc_eh -lc
1570:     /opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/crtend.o
1570:     /opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/crtn.o
flub@neptune:~/gccbug$ elfdump -d a.out 

Dynamic Section:  .dynamic
     index  tag                value
       [0]  NEEDED            0xd7                libc.so.1
       [1]  INIT              0x106b4             
       [2]  FINI              0x106d0             
       [3]  RUNPATH           0xed                /opt/csw/gcc4/lib
       [4]  RPATH             0xed                /opt/csw/gcc4/lib
       [5]  HASH              0x100e8             
       [6]  STRTAB            0x102f0             
       [7]  STRSZ             0xff                
       [8]  SYMTAB            0x101a0             
       [9]  SYMENT            0x10                
      [10]  CHECKSUM          0x4a7a              
      [11]  VERNEED           0x103f0             
      [12]  VERNEEDNUM        0x1                 
      [13]  PLTRELSZ          0x3c                
      [14]  PLTREL            0x7                 
      [15]  JMPREL            0x10440             
      [16]  RELA              0x10410             
      [17]  RELASZ            0x6c                
      [18]  RELAENT           0xc                 
      [19]  DEBUG             0                   
      [20]  FEATURE_1         0x1                 [ PARINIT ]
      [21]  FLAGS             0                   0
      [22]  FLAGS_1           0                   0
      [23]  PLTGOT            0x20710             
      [24]  NULL              0                   
flub@neptune:~/gccbug$ truss -af -t execve gcc test.c -R /opt/example.com/lib
1598:   execve("/opt/csw/gcc4/bin/gcc", 0xFFBFFBDC, 0xFFBFFBF0)  argc = 4
1598:    argv: gcc test.c -R /opt/example.com/lib
1599:   execve("/opt/csw/gcc4/libexec/gcc/sparc-sun-solaris2.8/4.0.2/cc1",
0x0004CEC8, 0x0004595C)  argc = 11
1599:    argv: /opt/csw/gcc4/libexec/gcc/sparc-sun-solaris2.8/4.0.2/cc1
1599:     -quiet test.c -quiet -dumpbase test.c -mcpu=v7 -auxbase test
1599:     -o /var/tmp//cciFstFw.s
1601:   execve("/usr/ccs/bin/as", 0x0004CEC8, 0x0004595C)  argc = 7
1601:    argv: /usr/ccs/bin/as -Qy -s -xarch=v8 -o /var/tmp//ccK8MMUX.o
1601:     /var/tmp//cciFstFw.s
1603:   execve("/opt/csw/gcc4/libexec/gcc/sparc-sun-solaris2.8/4.0.2/collect2",
0x0004E1C8, 0x00045954)  argc = 25
1603:    argv:
1603:     /opt/csw/gcc4/libexec/gcc/sparc-sun-solaris2.8/4.0.2/collect2
1603:     -R /opt/example.com/lib -R /opt/csw/gcc4/lib -Y
1603:     P,/opt/csw/gcc4/lib:/usr/ccs/lib:/usr/lib -Qy
1603:     /opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/crt1.o
1603:     /opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/crti.o
1603:     /usr/ccs/lib/values-Xa.o
1603:     /opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/crtbegin.o
1603:     -L/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2
1603:     -L/usr/ccs/bin -L/usr/ccs/lib
1603:     -L/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/../../..
1603:     /var/tmp//ccK8MMUX.o -lgcc -lgcc_eh -lc -lgcc -lgcc_eh -lc
1603:     /opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/crtend.o
1603:     /opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/crtn.o
1605:   execve("/usr/ccs/bin/ld", 0x0004BE80, 0x0004A450)  argc = 25
1605:    argv: /usr/ccs/bin/ld -R /opt/example.com/lib -R
1605:     /opt/csw/gcc4/lib -Y
1605:     P,/opt/csw/gcc4/lib:/usr/ccs/lib:/usr/lib -Qy
1605:     /opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/crt1.o
1605:     /opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/crti.o
1605:     /usr/ccs/lib/values-Xa.o
1605:     /opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/crtbegin.o
1605:     -L/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2
1605:     -L/usr/ccs/bin -L/usr/ccs/lib
1605:     -L/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/../../..
1605:     /var/tmp//ccK8MMUX.o -lgcc -lgcc_eh -lc -lgcc -lgcc_eh -lc
1605:     /opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/crtend.o
1605:     /opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/crtn.o
flub@neptune:~/gccbug$ elfdump -d a.out 

Dynamic Section:  .dynamic
     index  tag                value
       [0]  NEEDED            0xd7                libc.so.1
       [1]  INIT              0x106c8             
       [2]  FINI              0x106e4             
       [3]  RUNPATH           0xed               
/opt/example.com/lib:/opt/csw/gcc4/lib
       [4]  RPATH             0xed               
/opt/example.com/lib:/opt/csw/gcc4/lib
       [5]  HASH              0x100e8             
       [6]  STRTAB            0x102f0             
       [7]  STRSZ             0x114               
       [8]  SYMTAB            0x101a0             
       [9]  SYMENT            0x10                
      [10]  CHECKSUM          0x53a0              
      [11]  VERNEED           0x10404             
      [12]  VERNEEDNUM        0x1                 
      [13]  PLTRELSZ          0x3c                
      [14]  PLTREL            0x7                 
      [15]  JMPREL            0x10454             
      [16]  RELA              0x10424             
      [17]  RELASZ            0x6c                
      [18]  RELAENT           0xc                 
      [19]  DEBUG             0                   
      [20]  FEATURE_1         0x1                 [ PARINIT ]
      [21]  FLAGS             0                   0
      [22]  FLAGS_1           0                   0
      [23]  PLTGOT            0x20724             
      [24]  NULL              0                   


Just like when gcc detect you explicitly pass in -R gcc itself will start using
-R to ld for /opt/csw/gcc4/lib (in this case) it should detect that no -L or -R
option is used by the user and add /opt/csw/gcc4/lib to the LD_RUN_PATH
environment variable instead of using -L and rendering LD_RUN_PATH useless.


-- 
           Summary: LD_RUN_PATH ignored
           Product: gcc
           Version: 4.0.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: floris dot bruynooghe at gmail dot com
 GCC build triplet: sparc-sun-solaris2.8
  GCC host triplet: sparc-sun-solaris2.8
GCC target triplet: sparc-sun-solaris2.8


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39785


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]