-fuse-ld=gold and -pthread vs -lpthread

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have a project where linking with "gcc -pthread -fuse-ld=gold ..." fails with errors about undefined pthread symbols, e.g.

gcc /opt/rh/devtoolset-6/root/usr/lib/gcc/x86_64-redhat-linux/6.2.1/crtend.o /usr/lib/../lib64/crtn.o
/opt/rh/devtoolset-6/root/usr/lib/gcc/x86_64-redhat-linux/6.2.1/libstdc++_nonshared.a(thread44.o):function std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)()): error: undefined reference to 'pthread_create'
/opt/rh/devtoolset-6/root/usr/lib/gcc/x86_64-redhat-linux/6.2.1/libstdc++_nonshared.a(thread44.o):function std::thread::_M_start_thread(std::shared_ptr<std::thread::_Impl_base>, void (*)()): error: undefined reference to 'pthread_create'

If I pass -lpthread instead of (or in addition to) -pthread, or don't use gold, it links.

If I pass -v on the command line, I can see that with -pthread, the collect2 command line includes both -plugin-opt=-pass-through=-lpthread and -lpthread. With -lpthread and no -pthread, I no longer have the -plugin-opt=-pass-through=-lpthread, but still have -lpthread (although much earlier on the command line).

It seems to me like something is broken, but I'm not sure what. -pthread should be sufficient, should it? Any ideas?

Sorry for not providing complete command lines, this is a sprawling proprietary project. So far I have not been successful in reducing it to a smaller testcase. Is it worth it?

I'm using Developer Toolset 6 on Centos6 ("(GCC) 6.2.1 20160916 (Red Hat 6.2.1-3)", "GNU gold (version 2.27-8.el6) 1.12"). This same build system worked fine with devtoolset 4 ("gcc (GCC) 5.2.1 20150902 (Red Hat 5.2.1-2)", "GNU gold (version 2.25-10.el6) 1.11".

Thanks,

John




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux