Package: g++-4.4 Version: 4.4.4-7 Severity: normal [ First of all, this bug seems to be the same as bugs #577961 and #578831, only they cover gcc-4.5, where afaik -Wl,-no-add-needed is default ]
I'm trying to build my libraries with -Wl,-no-add-needed and got an issue wrt weak symbols handling. Here is the testcase (based on #577961): ---- 8< Makefile ---- CXXLD=$(CXX) -Wl,-no-add-needed CXXFLAGS=-Wall -fPIC -std=gnu++0x CPPFLAGS=-I. all: mymain2 mymain libkapi.so.0 mymain: mymain.o libkapi.so $(CXXLD) -o $@ $(CXXFLAGS) mymain.o -L. -lkapi mymain2: mymain.o $(CXXLD) -o $@ $(CXXFLAGS) mymain.o libkapi.so: libkapi.so.0 ln -fs $...@.0 $@ kapi.cc: touch $@ kapi.o: kapi.cc libkapi.so.0: kapi.o $(CXXLD) $(CXXFLAGS) -shared -Wl,-soname -Wl,$@ -o $@ $^ -pthread clean: $(RM) *.o libkapi.so.0 mymain kapi.cc libkapi.so mymain2 ---- 8< mymain.cc ---- #include <iostream> #include <memory> #include <string> using namespace std; int main () { string numbers[] ={"one","two","three"}; // get block of uninitialized memory: pair <string*,ptrdiff_t> result = get_temporary_buffer<string>(3); if (result.second>0) { uninitialized_copy ( numbers, numbers+result.second, result.first ); for (int i=0; i<result.second; i++) cout << result.first[i] << " "; cout << endl; return_temporary_buffer(result.first); } return 0; } $ make g++ -Wall -fPIC -std=gnu++0x -I. -c -o mymain.o mymain.cc g++ -Wl,-no-add-needed -o mymain2 -Wall -fPIC -std=gnu++0x mymain.o touch kapi.cc g++ -Wall -fPIC -std=gnu++0x -I. -c -o kapi.o kapi.cc g++ -Wl,-no-add-needed -Wall -fPIC -std=gnu++0x -shared -Wl,-soname -Wl,libkapi.so.0 -o libkapi.so.0 kapi.o -pthread ln -fs libkapi.so.0 libkapi.so g++ -Wl,-no-add-needed -o mymain -Wall -fPIC -std=gnu++0x mymain.o -L. -lkapi /usr/bin/ld: :: invalid DSO for symbol `pthread_cancel@@GLIBC_2.0' definition /lib/libpthread.so.0: could not read symbols: Bad value collect2: ld returned 1 exit status If CXXLD is changed back to just $(CXX) it builds ok. As I can tell this is related to libstdc++ weakly pulling in libpthread.so, but if then another library (libkapi.so) links explicitely to libpthread, when linking mymain, linker wrongly decides we need pthread_cancel non-weakly. See e.g. this thread: http://www.mail-archive.com/de...@lists.fedoraproject.org/msg00042.html Probably a linker issue too, so $ ld -v GNU ld (GNU Binutils for Debian) 2.20.1-system.20100303 Thanks, Kirill -- System Information: Debian Release: squeeze/sid APT prefers testing APT policy: (500, 'testing') Architecture: i386 (i686) Kernel: Linux 2.6.33.6-roro-00002-gf825b2a-dirty (SMP w/2 CPU cores; PREEMPT) Locale: LANG=ru_RU.UTF-8, LC_CTYPE=ru_RU.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/bash Versions of packages g++-4.4 depends on: ii gcc-4.4 4.4.4-7 The GNU C compiler ii gcc-4.4-base 4.4.4-7 The GNU Compiler Collection (base ii libc6 2.11.2-2 Embedded GNU C Library: Shared lib ii libgmp3c2 2:4.3.2+dfsg-1 Multiprecision arithmetic library ii libmpfr1ldbl 2.4.2-3 multiple precision floating-point ii libstdc++6-4.4-dev 4.4.4-7 The GNU Standard C++ Library v3 (d g++-4.4 recommends no packages. Versions of packages g++-4.4 suggests: pn g++-4.4-multilib <none> (no description available) ii gcc-4.4-doc 4.4.4.nf1-1 documentation for the GNU compiler ii libstdc++6-4.4-dbg 4.4.4-7 The GNU Standard C++ Library v3 (d -- no debconf information -- To UNSUBSCRIBE, email to debian-gcc-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/20100802200552.6349.59501.report...@roro3.zxlink