Bug 1287805 - -Wl,--as-needed ignored for -pthread
Summary: -Wl,--as-needed ignored for -pthread
Keywords:
Status: CLOSED EOL
Alias: None
Product: Fedora
Classification: Fedora
Component: gcc
Version: 22
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-12-02 17:48 UTC by Jaroslav Škarvada
Modified: 2016-07-19 18:33 UTC (History)
5 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2016-07-19 18:33:29 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Jaroslav Škarvada 2015-12-02 17:48:03 UTC
Description of problem:
If gcc called as linker with -Wl,--as-needed followed by -pthread, the libpthread is added as unused direct dependency.

Version-Release number of selected component (if applicable):
gcc-5.1.1-4.fc22.x86_64

How reproducible:
Always

Steps to Reproduce:
1. gcc -Wl,--as-needed -shared -fPIC OBJ1 OBJ2 libtest.so
2. ldd -u ./libtest.so
3. gcc -Wl,--as-needed -shared -fPIC OBJ1 OBJ2 -pthread libtest.so
4. ldd -u ./libtest.so

Actual results:
Unused direct dependencies:
	/lib64/libpthread.so.0

Expected results:
No unused direct dependencies

Additional info:
I checked manual page, but it doesn't seem there is written that this shouldn't work.

Comment 1 Jonathan Wakely 2015-12-02 19:49:24 UTC
-pthread is not simply equivalent to -lpthread, so I wouldn't have expected it to work like that anyway.

If you want to link with "--as-needed -lpthread" then you can use that (in addition to -pthread if you want).

Note that for the C++ runtime library the current behaviour is useful, because the pthread symbols are only referenced through weak symbols, so --as-needed -pthread would fail to consider the symbols "needed" and would fail to link libpthread.so even when the code uses e.g std::mutex and libpthread is definitely needed.

Comment 2 Jaroslav Škarvada 2015-12-03 09:14:06 UTC
Please could you mention it in documentation (manual page)?

Comment 3 Fedora End Of Life 2016-07-19 18:33:29 UTC
Fedora 22 changed to end-of-life (EOL) status on 2016-07-19. Fedora 22 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.


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