<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - libc++abi dependency on pthread when -fuse-ld=gold used"
   href="http://llvm.org/bugs/show_bug.cgi?id=20287">20287</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>libc++abi dependency on pthread when -fuse-ld=gold used
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libc++abi
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>All Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>oroppas@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu, mclow.lists@gmail.com
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>libc++abi can be happily linked by ld but ld.gold complains:

ryuta@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})</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>