[LLVMbugs] [Bug 20287] New: libc++abi dependency on pthread when -fuse-ld=gold used

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Jul 11 23:11:13 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=20287

            Bug ID: 20287
           Summary: libc++abi dependency on pthread when -fuse-ld=gold
                    used
           Product: libc++abi
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: oroppas at gmail.com
                CC: llvmbugs at cs.uiuc.edu, mclow.lists at gmail.com
    Classification: Unclassified

libc++abi can be happily linked by ld but ld.gold complains:

ryuta at oroppas $ clang++ -v -std=c++1y -stdlib=libc++ -fuse-ld=gold
./van_der_pol_stiff.cpp 
clang version 3.5.0 (212793)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation:
/usr/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.9.0
Found candidate GCC installation:
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.0
Found candidate GCC installation: /usr/lib64/gcc/x86_64-unknown-linux-gnu/4.9.0
Selected GCC installation: /usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.0
Candidate multilib: .;@m64
Selected multilib: .;@m64
 "/usr/bin/clang-3.5" -cc1 -triple x86_64-unknown-linux-gnu -emit-obj
-mrelax-all -disable-free -disable-llvm-verifier -main-file-name
van_der_pol_stiff.cpp -mrelocation-model static -mdisable-fp-elim -fmath-errno
-masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array
-target-cpu x86-64 -v -dwarf-column-info -resource-dir
/usr/bin/../lib/clang/3.5.0 -internal-isystem /usr/bin/../include/c++/v1
-internal-isystem /usr/local/include -internal-isystem
/usr/bin/../lib/clang/3.5.0/include -internal-externc-isystem /include
-internal-externc-isystem /usr/include -std=c++1y -fdeprecated-macro
-fdebug-compilation-dir /home/ryuta/workspace/boost/odeint -ferror-limit 19
-fmessage-length 104 -mstackrealign -fobjc-runtime=gcc -fcxx-exceptions
-fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o
/tmp/van_der_pol_stiff-a0c35b.o -x c++ ./van_der_pol_stiff.cpp
clang -cc1 version 3.5.0 based upon LLVM 3.5.0svn default target
x86_64-unknown-linux-gnu
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/bin/../include/c++/v1
 /usr/local/include
 /usr/bin/../lib/clang/3.5.0/include
 /usr/include
End of search list.
 "/usr/bin/ld.gold" --eh-frame-hdr -m elf_x86_64 -dynamic-linker
/lib64/ld-linux-x86-64.so.2 -o a.out
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.0/../../../../lib64/crt1.o
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.0/../../../../lib64/crti.o
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.0/crtbegin.o
-L/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.0
-L/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.0/../../../../lib64
-L/usr/bin/../lib64 -L/lib/../lib64 -L/usr/lib/../lib64
-L/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.0/../../..
-L/usr/bin/../lib -L/lib -L/usr/lib /tmp/van_der_pol_stiff-a0c35b.o -lc++
-lc++abi -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.0/crtend.o
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.0/../../../../lib64/crtn.o
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.0/../../../../lib64/libc++abi.so:
error: undefined reference to 'pthread_getspecific'
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.0/../../../../lib64/libc++abi.so:
error: undefined reference to 'pthread_key_create'
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.0/../../../../lib64/libc++abi.so:
error: undefined reference to 'pthread_once'
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.0/../../../../lib64/libc++abi.so:
error: undefined reference to 'pthread_setspecific'
clang-3.5: error: linker command failed with exit code 1 (use -v to see
invocation)


The patch like the following fix the issue although I'm not sure why ld can
resolve reference but not ld.gold...

Index: llvm/projects/libcxxabi/CMakeLists.txt
===================================================================
--- llvm/projects/libcxxabi/CMakeLists.txt    (revision 212793)
+++ llvm/projects/libcxxabi/CMakeLists.txt    (working copy)
@@ -122,7 +122,7 @@
         ${LLVM_INCLUDE_DIR}/c++/v1
   )

-set(LIBCXXABI_LIBCXX_INCLUDES "${LIBCXXABI_LIBCXX_INCLUDES}" CACHE STRING
+set(LIBCXXABI_LIBCXX_INCLUDES "${LIBCXXABI_LIBCXX_INCLUDES}" CACHE PATH
     "Specify path to libc++ includes." FORCE)


#===============================================================================
Index: llvm/projects/libcxxabi/cmake/config-ix.cmake
===================================================================
--- llvm/projects/libcxxabi/cmake/config-ix.cmake    (revision 212793)
+++ llvm/projects/libcxxabi/cmake/config-ix.cmake    (working copy)
@@ -35,4 +35,5 @@
 check_cxx_compiler_flag(/GR-                  LIBCXXABI_HAS_NO_GR_FLAG)

 # Check libraries
+check_library_exists(pthread pthread_create "" LIBCXXABI_HAS_PTHREAD_LIB)
 check_library_exists(c printf "" LIBCXXABI_HAS_C_LIB)
Index: llvm/projects/libcxxabi/src/CMakeLists.txt
===================================================================
--- llvm/projects/libcxxabi/src/CMakeLists.txt    (revision 212793)
+++ llvm/projects/libcxxabi/src/CMakeLists.txt    (working copy)
@@ -52,6 +52,7 @@

 # Generate library list.
 set(libraries ${LIBCXXABI_CXX_ABI_LIBRARIES})
+append_if(libraries LIBCXXABI_HAS_PTHREAD_LIB pthread)
 append_if(libraries LIBCXXABI_HAS_C_LIB c)

 target_link_libraries(cxxabi ${libraries})

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140712/ba66989b/attachment.html>


More information about the llvm-bugs mailing list