diff options
author | Michał Górny <mgorny@gentoo.org> | 2019-11-30 15:13:56 +0100 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2019-12-01 17:17:51 +0100 |
commit | 35bc5276ca31e3f0e8e87322153f410fa6224e59 (patch) | |
tree | 06623074e9c849a8fb35acf18dfd126c9fb2621c | |
parent | 89c47313c9b11c9f7b6ee1b6cbc7789fdb5e75ea (diff) | |
download | bcm5719-llvm-35bc5276ca31e3f0e8e87322153f410fa6224e59.tar.gz bcm5719-llvm-35bc5276ca31e3f0e8e87322153f410fa6224e59.zip |
[libunwind] Emit dependent libraries only when detected by CMake
996e62eef75 added Linux-specific dependent libraries to libunwind
sources. As a result, building libunwind with modern LLD on *BSD
started failing due to trying to link libdl. Instead, add those
libraries only if they were detected by CMake.
While technically we could create a long list of systems that need -ldl
and -lpthread, maintaining a duplicate list makes little sense when
CMake needs to detect it for non-LLD systems anyway. Remove existing
system exceptions since they should be covered by the CMake check
anyway.
Remove -D_LIBUNWIND_HAS_COMMENT_LIB_PRAGMA since it is no longer
explicitly needed, if we make the library-specific defines dependent
on presence of this pragma support.
Differential Revision: https://reviews.llvm.org/D70868
-rw-r--r-- | libunwind/CMakeLists.txt | 7 | ||||
-rw-r--r-- | libunwind/src/AddressSpace.hpp | 2 | ||||
-rw-r--r-- | libunwind/src/RWMutex.hpp | 2 |
3 files changed, 8 insertions, 3 deletions
diff --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt index 25dc95cf6ba..08095d1333a 100644 --- a/libunwind/CMakeLists.txt +++ b/libunwind/CMakeLists.txt @@ -352,7 +352,12 @@ if (WIN32 AND LIBUNWIND_ENABLE_STATIC AND NOT LIBUNWIND_ENABLE_SHARED) endif() if (LIBUNWIND_HAS_COMMENT_LIB_PRAGMA) - add_definitions(-D_LIBUNWIND_HAS_COMMENT_LIB_PRAGMA) + if (LIBUNWIND_HAS_DL_LIB) + add_definitions(-D_LIBUNWIND_LINK_DL_LIB) + endif() + if (LIBUNWIND_HAS_PTHREAD_LIB) + add_definitions(-D_LIBUNWIND_LINK_PTHREAD_LIB) + endif() endif() #=============================================================================== diff --git a/libunwind/src/AddressSpace.hpp b/libunwind/src/AddressSpace.hpp index db67df4dc80..7433476f911 100644 --- a/libunwind/src/AddressSpace.hpp +++ b/libunwind/src/AddressSpace.hpp @@ -27,7 +27,7 @@ #if _LIBUNWIND_USE_DLADDR #include <dlfcn.h> -#if defined(__unix__) && defined(__ELF__) && defined(_LIBUNWIND_HAS_COMMENT_LIB_PRAGMA) +#if defined(__ELF__) && defined(_LIBUNWIND_LINK_DL_LIB) #pragma comment(lib, "dl") #endif #endif diff --git a/libunwind/src/RWMutex.hpp b/libunwind/src/RWMutex.hpp index 954e94c322d..fcd3f4967d1 100644 --- a/libunwind/src/RWMutex.hpp +++ b/libunwind/src/RWMutex.hpp @@ -17,7 +17,7 @@ #include <windows.h> #elif !defined(_LIBUNWIND_HAS_NO_THREADS) #include <pthread.h> -#if defined(__unix__) && !defined(__ANDROID__) && defined(__ELF__) && defined(_LIBUNWIND_HAS_COMMENT_LIB_PRAGMA) +#if defined(__ELF__) && defined(_LIBUNWIND_LINK_PTHREAD_LIB) #pragma comment(lib, "pthread") #endif #endif |