Debian Bug report logs - #629866
gcc-4.6: --no-add-needed disturbs weak references

version graph

Package: gcc-4.6; Maintainer for gcc-4.6 is Debian GCC Maintainers <>; Source for gcc-4.6 is src:gcc-4.6.

Reported by: Samuel Thibault <>

Date: Thu, 9 Jun 2011 00:27:01 UTC

Severity: normal

Found in version gcc-4.6/4.6.0-10

Reply or subscribe to this bug.

Toggle useless messages

View this report as an mbox folder, status mbox, maintainer mbox

Report forwarded to, Debian GCC Maintainers <>:
Bug#629866; Package gcc-4.6. (Thu, 09 Jun 2011 00:27:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to Samuel Thibault <>:
New Bug report received and forwarded. Copy sent to Debian GCC Maintainers <>. (Thu, 09 Jun 2011 00:27:04 GMT) Full text and rfc822 format available.

Message #5 received at (full text, mbox):

From: Samuel Thibault <>
To: Debian Bug Tracking System <>
Subject: gcc-4.6: --no-add-needed disturbs weak references
Date: Thu, 9 Jun 2011 02:26:20 +0200
[Message part 1 (text/plain, inline)]
Package: gcc-4.6
Version: 4.6.0-10
Severity: normal


Since gcc started using --no-add-needed by default, there are issues
with weak references, see attached testcase:

- libthread represents a thread library, which here only provide the
  "cancel" symbol.
- libA is a library which uses the "cancel" symbol, and links against
  the thread library.
- foo.c is a file which detects whether the thread library is brought
  into the program by showing the value of a weak reference to cancel.
- main.c uses both libA and foo.

The result is this:

cc thread.c -o -shared -fPIC
cc libA.c -o -shared -fPIC -L. -lthread -Wl,-rpath=/tmp/tmp
cc -Wall -g   -c -o foo.o foo.c
cc  foo.o main.c -o main -L. -lA
/usr/bin/ld.bfd.real: ./ undefined reference to symbol 'cancel'
/usr/bin/ld.bfd.real: note: 'cancel' is defined in DSO /tmp/tmp/ so try adding it to the linker command line
/tmp/tmp/ could not read symbols: Invalid operation
collect2: ld returned 1 exit status
make: *** [main] Erreur 1

For some reason the linker doesn't manage to resolve the "cancel"
symbol, although it's supposed to be brought in by

In case you wonder where that testcast comes from, it's actually gcc
itself, the __gthread_active_p() function, which gets inlined into


-- System Information:
Debian Release: wheezy/sid
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable'), (500, 'stable'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.39 (SMP w/2 CPU cores)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages gcc-4.6 depends on:
ii  binutils     The GNU assembler, linker and bina
ii  cpp-4.6               4.6.0-10           The GNU C preprocessor
ii  gcc-4.6-base          4.6.0-10           The GNU Compiler Collection (base 
ii  libc6                 2.13-4             Embedded GNU C Library: Shared lib
ii  libcloog-ppl0         0.15.9-3           the Chunky Loop Generator (runtime
ii  libgcc1               1:4.6.0-10         GCC support library
ii  libgmp10              2:5.0.1+dfsg-7     Multiprecision arithmetic library
ii  libgmpxx4ldbl         2:5.0.1+dfsg-7     Multiprecision arithmetic library 
ii  libgomp1              4.6.0-10           GCC OpenMP (GOMP) support library
ii  libmpc2               0.9-3              multiple precision complex floatin
ii  libmpfr4              3.0.1-3            multiple precision floating-point 
ii  libppl-c4             0.11.2-3           Parma Polyhedra Library (C interfa
ii  libppl9               0.11.2-3           Parma Polyhedra Library (runtime l
ii  libquadmath0          4.6.0-10           GCC Quad-Precision Math Library
ii  zlib1g                1:   compression library - runtime

Versions of packages gcc-4.6 recommends:
ii  libc6-dev                     2.13-4     Embedded GNU C Library: Developmen

Versions of packages gcc-4.6 suggests:
pn  binutils-gold             <none>         (no description available)
ii  gcc-4.6-doc               4.6-20110123-1 Documentation for the GNU compiler
pn  gcc-4.6-locales           <none>         (no description available)
pn  gcc-4.6-multilib          <none>         (no description available)
ii  libgcc1-dbg               1:4.6.0-10     GCC support library (debug symbols
pn  libgomp1-dbg              <none>         (no description available)
pn  libmudflap0-4.6-dev       <none>         (no description available)
pn  libmudflap0-dbg           <none>         (no description available)
pn  libquadmath0-dbg          <none>         (no description available)

-- no debconf information
[test.tgz (application/x-tar-gz, attachment)]

Send a report that this bug log contains spam.

Debian bug tracking system administrator <>. Last modified: Sun Apr 20 16:31:52 2014; Machine Name:

Debian Bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.