ports/142226: lang/gcc44 missing -rpath in generated executable.

Peter Jeremy peterjeremy at acm.org
Sat Jan 2 04:20:03 UTC 2010


>Number:         142226
>Category:       ports
>Synopsis:       lang/gcc44 missing -rpath in generated executable.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Jan 02 04:20:02 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator:     Peter Jeremy
>Release:        FreeBSD 8.0-STABLE amd64
>Organization:
>Environment:
System: FreeBSD server.vk2pj.dyndns.org 8.0-STABLE FreeBSD 8.0-STABLE #11: Mon Nov 30 16:36:34 EST 2009 root at server.vk2pj.dyndns.org:/var/obj/usr/src/sys/server amd64

gcc-4.4.3.20091222

>Description:
	When compiling with gcc44 or g++44, the compiler driver implicitly
	includes '-L/usr/local/lib/gcc44' but this directory is not part
	of the runtime search path, causing the wrong .so to be loaded.

>How-To-Repeat:

$ cat <<EOF > /tmp/x.C
#include <iostream>
#include <tr1/unordered_set>

typedef std::tr1::unordered_set<int> uset_i;

void print_unordered_set(const uset_i& s)
{
   for(uset_i::const_iterator it = s.begin();
       it != s.end();
       ++it)
   {
      std::cout << *it << " ";
   }
   std::cout << std::endl;
}

int main(void)
{
    uset_i s;

    s.insert(1);
    s.insert(2);
    s.insert(3);
    s.insert(1);
    s.insert(1);

    print_unordered_set(s);
}
EOF
$ g++ /tmp/x.C && ./a.out 
1 2 3 
$ g++44 -v /tmp/x.C 
Using built-in specs.
Target: x86_64-portbld-freebsd8.0
Configured with: ./../gcc-4.4-20091222/configure --disable-nls --with-system-zlib --with-libiconv-prefix=/usr/local --with-gmp=/usr/local --program-suffix=44 --libdir=/usr/local/lib/gcc44 --libexecdir=/usr/local/libexec/gcc44 --with-gxx-include-dir=/usr/local/lib/gcc44/include/c++/ --disable-libgcj --prefix=/usr/local --mandir=/usr/local/man --infodir=/usr/local/info/gcc44 --build=x86_64-portbld-freebsd8.0
Thread model: posix
gcc version 4.4.3 20091222 (prerelease) (GCC) 
COLLECT_GCC_OPTIONS='-v' '-shared-libgcc' '-mtune=generic'
 /usr/local/libexec/gcc44/gcc/x86_64-portbld-freebsd8.0/4.4.3/cc1plus -quiet -v /tmp/x.C -quiet -dumpbase x.C -mtune=generic -auxbase x -version -o /tmp/ccilzrcX.s
ignoring nonexistent directory "/usr/local/lib/gcc44/gcc/x86_64-portbld-freebsd8.0/4.4.3/../../../../../x86_64-portbld-freebsd8.0/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/lib/gcc44/include/c++/
 /usr/local/lib/gcc44/include/c++//x86_64-portbld-freebsd8.0
 /usr/local/lib/gcc44/include/c++//backward
 /usr/local/include
 /usr/local/lib/gcc44/gcc/x86_64-portbld-freebsd8.0/4.4.3/include
 /usr/local/lib/gcc44/gcc/x86_64-portbld-freebsd8.0/4.4.3/include-fixed
 /usr/include
End of search list.
GNU C++ (GCC) version 4.4.3 20091222 (prerelease) (x86_64-portbld-freebsd8.0)
        compiled by GNU C version 4.4.3 20091222 (prerelease), GMP version 4.3.1, MPFR version 2.4.2.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 6a11e2181b659c578893cdc3345cf0a1
COLLECT_GCC_OPTIONS='-v' '-shared-libgcc' '-mtune=generic'
 as -V -Qy -o /tmp/ccRzy5Qe.o /tmp/ccilzrcX.s
GNU assembler version 2.15 [FreeBSD] 2004-05-23 (x86_64-obrien-freebsd) using BFD version 2.15 [FreeBSD] 2004-05-23
COMPILER_PATH=/usr/local/libexec/gcc44/gcc/x86_64-portbld-freebsd8.0/4.4.3/:/usr/local/libexec/gcc44/gcc/x86_64-portbld-freebsd8.0/4.4.3/:/usr/local/libexec/gcc44/gcc/x86_64-portbld-freebsd8.0/:/usr/local/lib/gcc44/gcc/x86_64-portbld-freebsd8.0/4.4.3/:/usr/local/lib/gcc44/gcc/x86_64-portbld-freebsd8.0/
LIBRARY_PATH=/usr/local/lib/gcc44/gcc/x86_64-portbld-freebsd8.0/4.4.3/:/usr/local/lib/gcc44/gcc/x86_64-portbld-freebsd8.0/4.4.3/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-shared-libgcc' '-mtune=generic'
 /usr/local/libexec/gcc44/gcc/x86_64-portbld-freebsd8.0/4.4.3/collect2 -V -dynamic-linker /libexec/ld-elf.so.1 /usr/lib/crt1.o /usr/lib/crti.o /usr/local/lib/gcc44/gcc/x86_64-portbld-freebsd8.0/4.4.3/crtbegin.o -L/usr/local/lib/gcc44/gcc/x86_64-portbld-freebsd8.0/4.4.3 -L/usr/local/lib/gcc44/gcc/x86_64-portbld-freebsd8.0/4.4.3/../../.. /tmp/ccRzy5Qe.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/local/lib/gcc44/gcc/x86_64-portbld-freebsd8.0/4.4.3/crtend.o /usr/lib/crtn.o
GNU ld version 2.15 [FreeBSD] 2004-05-23
  Supported emulations:
   elf_i386_fbsd
   elf_x86_64_fbsd
$ ./a.out
/libexec/ld-elf.so.1: /usr/lib/libstdc++.so.6: version GLIBCXX_3.4.10 required by /home/peter/gcc/a.out not found
$

>Fix:

The front end drivers should include
'-Wl,-rpath,/usr/local/lib/gcc44/gcc/x86_64-portbld-freebsd8.0/4.4.3/../../..'
or similar to ensure that the same directory is searched at runtime as
at linktime.
>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-ports-bugs mailing list