This is the mail archive of the binutils@sourceware.org mailing list for the binutils 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]

test failures in the libstdc++ and glibc testsuites with ld --as-needed from binutils trunk


I see 71 test thread related test failures in libstdc++ [1], when building a GCC
configured to default to --as-needed [2] with the ld from trunk.  This works
fine with ld 2.23.2.  All test cases are built with -pthread, however libpthread
never shows up as a needed library for the resulting executable.

$ /scratch/packages/gcc/4.8/u/gcc-4.8-4.8.1/build/./gcc/collect2 --sysroot=/
--build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed
-dynamic-linker /lib64/ld-linux-x86-64.so.2 -z relro -o ./42819.exe
/usr/lib/x86_64-linux-gnu/crt1.o /usr/lib/x86_64-linux-gnu/crti.o
/scratch/packages/gcc/4.8/u/gcc-4.8-4.8.1/build/./gcc/crtbegin.o
-L/scratch/packages/gcc/4.8/u/gcc-4.8-4.8.1/build/x86_64-linux-gnu/libstdc++-v3/src
-L/scratch/packages/gcc/4.8/u/gcc-4.8-4.8.1/build/x86_64-linux-gnu/libstdc++-v3/src/.libs
-L/scratch/packages/gcc/4.8/u/gcc-4.8-4.8.1/build/./gcc
-L/scratch/packages/gcc/4.8/u/gcc-4.8-4.8.1/build/x86_64-linux-gnu/./libstdc++-v3/src/.libs
-L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu
-L/usr/lib/../lib 42819.o  ./libtestc++.a --gc-sections -lstdc++ -lm -lgcc_s
-lgcc -lpthread -lc -lgcc_s -lgcc
/scratch/packages/gcc/4.8/u/gcc-4.8-4.8.1/build/./gcc/crtend.o
/usr/lib/x86_64-linux-gnu/crtn.o
$ ./42819.exe
terminate called after throwing an instance of 'std::system_error'
  what():  Unknown error -1
Aborted

$ readelf -a 42819.o | grep 'WEAK.*pthread'
   479: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND __pthread_key_create
   480: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND pthread_mutex_unlock
   481: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND pthread_mutex_lock
   482: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND pthread_once
$ readelf -a libtestc++.a | grep 'WEAK.*pthread'
   220: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND __pthread_key_create
    90: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND __pthread_key_create
    65: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND __pthread_key_create

Relinking the test case with the --as-needed removed, or surrounding -lpthread
with --no-as-needed/--as-needed adds the NEEDED entry on libpthread again and
lets the test case succeed again.

Looking at the --as-needed documentation, this behaviour seems to be unexpected.
 Shouldn't this handling for weak symbols only be done when linking a shared
library, and not an executable?

Both the BFD linker and gold behave in the same way.

It looks like the tst-tls-atexit test in glibc 2.18 fails in a similar way with
this GCC configuration.

  Matthias

[1] search for "test-summary", in
https://launchpadlibrarian.net/147663264/buildlog_ubuntu-saucy-amd64.gcc-4.8_4.8.1-9ubuntu1_UPLOADING.txt.gz
[2]
http://anonscm.debian.org/viewvc/gcccvs/branches/sid/gcc-4.8/debian/patches/gcc-as-needed.diff?view=markup


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