[Bug 1271468] Re: collect2 --as-needed option causes build failure
    Matthias Klose 
    doko at ubuntu.com
       
    Wed Jan 22 11:15:29 UTC 2014
    
    
  
see https://wiki.ubuntu.com/ToolChain and
https://wiki.ubuntu.com/ToolChain/CompilerFlags
** Changed in: gcc-4.8 (Ubuntu)
       Status: New => Invalid
-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to gcc-4.8 in Ubuntu.
https://bugs.launchpad.net/bugs/1271468
Title:
  collect2 --as-needed option causes build failure
Status in “gcc-4.8” package in Ubuntu:
  Invalid
Bug description:
  Testing a package build on upcoming trusty, I encountered a rather
  strange issue.
  Given this simple program:
  #include <amqp_tcp_socket.h>
  int main () {
    return amqp_tcp_socket_new (0);
  }
  I installed "librabbitmq-dev" which provides amqp_tcp_socket.h, and
  then ran "gcc -o /tmp/test -g -O2 -lrabbitmq -ldl amqp.c", which fails
  with:
  /tmp/amqp.c:2: undefined reference to `amqp_tcp_socket_new'
  collect2: error: ld returned 1 exit status
  Using "gcc -v", I discovered that if /usr/lib/gcc/x86_64-linux-
  gnu/4.8/collect2 was called without the --as-needed option, the
  program builds fine.
  I'm actually opening this bug against gcc and not librabbitmq-dev for
  a reason: this simple C program builds perfectly on debian jessie/sid.
  librabbitmq-dev/librabbitmq1 are exactly identical between trusty and
  debian unstable. The problem also occurs when manually building
  librabbitmq from the upstream source tarball.
  Also, it's not just a matter of fixing my broken program or calling
  gcc with some other option. This program actually is a stripped down
  version of what is generated by autoconf (also same version and output
  on sid and trusty, BTW) with this macro:
  AC_CHECK_FUNC(amqp_tcp_socket_new, [with_amqp_tcp_socket="yes"],
  [with_amqp_tcp_socket="no"])
  Attaching the output of "gcc -v" on both trusty and jessie. Apart from
  a couple of paths and version strings, collect2 is called with "--as-
  needed" and "-z relro" on trusty but not on debian jessie.
  "--as-needed" is what makes the difference between failing to build
  (on trusty) or not (on jessie).
  Thanks for taking a look at this !
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gcc-4.8/+bug/1271468/+subscriptions
    
    
More information about the foundations-bugs
mailing list