[libcxx-commits] [PATCH] D62090: [libcxx][libunwind] Support ELF dependent libraries feature on Linux
Petr Hosek via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Fri May 17 16:46:11 PDT 2019
phosek created this revision.
phosek added reviewers: ldionne, EricWF, bd1976llvm.
Herald added subscribers: libcxx-commits, jfb, dexonsmith, christof, krytarowski.
Herald added a project: libc++.
As of r360984, LLD supports dependent libraries feature for ELF.
libunwind and libc++ have library dependencies: libdl and libpthread
respectively, 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 them up automatically. We only support this feature
on Linux for now, additional platforms can be added in the future.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D62090
Files:
libcxx/include/__threading_support
libunwind/src/AddressSpace.hpp
Index: libunwind/src/AddressSpace.hpp
===================================================================
--- libunwind/src/AddressSpace.hpp
+++ libunwind/src/AddressSpace.hpp
@@ -27,6 +27,9 @@
#if _LIBUNWIND_USE_DLADDR
#include <dlfcn.h>
+#if defined(__ELF__) && defined(__linux__)
+#pragma comment(lib, "dl")
+#endif
#endif
#ifdef __APPLE__
Index: libcxx/include/__threading_support
===================================================================
--- libcxx/include/__threading_support
+++ libcxx/include/__threading_support
@@ -25,6 +25,9 @@
#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
# include <pthread.h>
# include <sched.h>
+#if defined(__ELF__) && defined(__linux__)
+#pragma comment(lib, "pthread")
+#endif
#endif
_LIBCPP_PUSH_MACROS
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62090.200120.patch
Type: text/x-patch
Size: 762 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20190517/19ef66d7/attachment.bin>
More information about the libcxx-commits
mailing list