[libunwind] r362048 - [runtimes] Support ELF dependent libraries feature

Petr Hosek via cfe-commits cfe-commits at lists.llvm.org
Wed May 29 18:34:42 PDT 2019


Author: phosek
Date: Wed May 29 18:34:41 2019
New Revision: 362048

URL: http://llvm.org/viewvc/llvm-project?rev=362048&view=rev
Log:
[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

Modified:
    libunwind/trunk/src/AddressSpace.hpp
    libunwind/trunk/src/RWMutex.hpp

Modified: libunwind/trunk/src/AddressSpace.hpp
URL: http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/AddressSpace.hpp?rev=362048&r1=362047&r2=362048&view=diff
==============================================================================
--- libunwind/trunk/src/AddressSpace.hpp (original)
+++ libunwind/trunk/src/AddressSpace.hpp Wed May 29 18:34:41 2019
@@ -27,6 +27,9 @@
 
 #if _LIBUNWIND_USE_DLADDR
 #include <dlfcn.h>
+#if defined(__unix__) &&  defined(__ELF__) && defined(__clang__)
+#pragma comment(lib, "dl")
+#endif
 #endif
 
 #ifdef __APPLE__

Modified: libunwind/trunk/src/RWMutex.hpp
URL: http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/RWMutex.hpp?rev=362048&r1=362047&r2=362048&view=diff
==============================================================================
--- libunwind/trunk/src/RWMutex.hpp (original)
+++ libunwind/trunk/src/RWMutex.hpp Wed May 29 18:34:41 2019
@@ -17,6 +17,9 @@
 #include <windows.h>
 #elif !defined(_LIBUNWIND_HAS_NO_THREADS)
 #include <pthread.h>
+#if defined(__unix__) &&  defined(__ELF__) && defined(__clang__)
+#pragma comment(lib, "pthread")
+#endif
 #endif
 
 namespace libunwind {




More information about the cfe-commits mailing list