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.
-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.
Please could you mention it in documentation (manual page)?
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.