Bug 1123714 - -Wl,--as-needed does not link to all needed libraries with gcc 4.9
Summary: -Wl,--as-needed does not link to all needed libraries with gcc 4.9
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: binutils
Version: rawhide
Hardware: x86_64
OS: Linux
high
high
Target Milestone: ---
Assignee: Nick Clifton
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-07-28 05:13 UTC by Mattias Ellert
Modified: 2014-10-12 17:49 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-10-12 17:49:40 UTC


Attachments (Terms of Use)
Test code explainig the problem (149 bytes, text/x-c++src)
2014-07-28 05:13 UTC, Mattias Ellert
no flags Details

Description Mattias Ellert 2014-07-28 05:13:38 UTC
Created attachment 921676 [details]
Test code explainig the problem

Description of problem:

Compiling a shared library using -Wl,--as-needed does not link to all needed libraries.

Version-Release number of selected component (if applicable):

gcc-c++-4.9.1-2.fc22.1.x86_64

How reproducible:

Always.

Steps to Reproduce:

g++ --shared -o libtest.so -fPIC -I/usr/include/libAfterImage asim.cpp -Wl,--as-needed `afterimage-libs`

(asim.cpp is attached to the report)

Actual results:

Even though -ltiff is part of `afterimage-libs`, libtest.so is not linked to it resulting in unresolved symbols.

Expected results:

The same as on F20, the same command line results in a shared library without unresolved symbols here. (gcc-c++-4.8.3-1.fc20.x86_64)

Comment 1 Jakub Jelinek 2014-07-28 07:42:49 UTC
gcc just passes the flags to the linker, reassigning.  Haven't verified it though.

Comment 2 Mattias Ellert 2014-08-20 19:06:24 UTC
Hi!

Any progress on this?

On F20 the libtest.so picks up freetype, tiff, X11 and GL:

$ readelf -a libtest.so | grep NEEDED
 0x0000000000000001 (NEEDED)             delat bibliotek: [libAfterImage.so.0]
 0x0000000000000001 (NEEDED)             delat bibliotek: [libfreetype.so.6]
 0x0000000000000001 (NEEDED)             delat bibliotek: [libtiff.so.5]
 0x0000000000000001 (NEEDED)             delat bibliotek: [libX11.so.6]
 0x0000000000000001 (NEEDED)             delat bibliotek: [libGL.so.1]
 0x0000000000000001 (NEEDED)             delat bibliotek: [libc.so.6]

and all symbols are resolved.

On F21 and rawhide, using the same command line to compile, tiff is missing:

$ readelf -a libtest.so | grep NEEDED
 0x0000000000000001 (NEEDED)             delat bibliotek: [libAfterImage.so.0]
 0x0000000000000001 (NEEDED)             delat bibliotek: [libfreetype.so.6]
 0x0000000000000001 (NEEDED)             delat bibliotek: [libX11.so.6]
 0x0000000000000001 (NEEDED)             delat bibliotek: [libGL.so.1]

and there are lots of unresolved symbols.

Comment 3 Nick Clifton 2014-08-21 09:23:20 UTC
Hi Mattias,

  Please try:  binutils-2.24-21.fc2

  Note - I have not backported the patch to F21 yet, because although it fixes the NEED for libtiff, it does not fix the NEED for libc.  It is not clear to me yet whether this is important, so please let me know how you get on.

Cheers
  Nick

Comment 4 Mattias Ellert 2014-08-23 14:24:27 UTC
Thank you. It works for me (I have tested -22.fc22). Having the fix in F21 too would be great.

Many thanks,
   Mattias

Comment 5 Nick Clifton 2014-08-26 11:13:05 UTC
Hi Matthias,

  binutils-2.24-20.fc21 now contains the patch as well.

Cheers
  Nick

Comment 6 Mattias Ellert 2014-09-07 06:20:03 UTC
root's libASImage is now linked correctly in root-5.34.20-2.fc21 and root-5.34.20-2.fc22.


Note You need to log in before you can comment on or make changes to this bug.