From 996e62eef750942e174c4b80892b28e198e3a8d0 Mon Sep 17 00:00:00 2001 From: Petr Hosek Date: Thu, 30 May 2019 01:34:41 +0000 Subject: [runtimes] Support ELF dependent libraries feature As of r360984, LLD supports dependent libraries feature for ELF. libunwind, libc++abi and libc++ have library dependencies: libdl librt and libpthread, which means that when libunwind and libc++ are being statically linked (using -static-libstdc++ flag), user has to manually specify -ldl -lpthread which is onerous. This change includes the lib pragma to specify the library dependencies directly in the source that uses those libraries. This doesn't make any difference when using linkers that don't support dependent libraries. However, when using LLD that has dependent libraries feature, users no longer have to manually specifying library dependencies when using static linking, linker will pick the library automatically. Differential Revision: https://reviews.llvm.org/D62090 llvm-svn: 362048 --- libcxx/src/algorithm.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'libcxx/src/algorithm.cpp') diff --git a/libcxx/src/algorithm.cpp b/libcxx/src/algorithm.cpp index 28e452f52df1..5ce2a23b464f 100644 --- a/libcxx/src/algorithm.cpp +++ b/libcxx/src/algorithm.cpp @@ -8,7 +8,12 @@ #include "algorithm" #include "random" +#ifndef _LIBCPP_HAS_NO_THREADS #include "mutex" +#if defined(__unix__) && defined(__ELF__) && defined(__clang__) +#pragma comment(lib, "pthread") +#endif +#endif _LIBCPP_BEGIN_NAMESPACE_STD -- cgit v1.2.3