diff options
author | Michał Górny <mgorny@gentoo.org> | 2019-12-02 11:49:20 +0100 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2019-12-02 22:19:20 +0100 |
commit | a9b5fff591d462f1f22e44ab1a269b82b8f2a664 (patch) | |
tree | 6b8ca9fb84e454c2def732d1a6434c0b8e57778e | |
parent | 93f77617abba512d2861e2fc50ce385883f587b6 (diff) | |
download | bcm5719-llvm-a9b5fff591d462f1f22e44ab1a269b82b8f2a664.tar.gz bcm5719-llvm-a9b5fff591d462f1f22e44ab1a269b82b8f2a664.zip |
[libcxx{,abi}] Emit deplibs only when detected by CMake
This is a followup to 35bc5276ca3. It fixes the dependent libs usage
in libcxx and libcxxabi to link pthread and rt libraries only if CMake
detects them, rather than based on explicit platform blacklist.
Differential Revision: https://reviews.llvm.org/D70888
-rw-r--r-- | libcxx/CMakeLists.txt | 7 | ||||
-rw-r--r-- | libcxx/src/algorithm.cpp | 2 | ||||
-rw-r--r-- | libcxx/src/chrono.cpp | 2 | ||||
-rw-r--r-- | libcxx/src/condition_variable.cpp | 2 | ||||
-rw-r--r-- | libcxx/src/debug.cpp | 2 | ||||
-rw-r--r-- | libcxx/src/experimental/memory_resource.cpp | 2 | ||||
-rw-r--r-- | libcxx/src/filesystem/operations.cpp | 2 | ||||
-rw-r--r-- | libcxx/src/memory.cpp | 2 | ||||
-rw-r--r-- | libcxx/src/mutex.cpp | 2 | ||||
-rw-r--r-- | libcxx/src/shared_mutex.cpp | 2 | ||||
-rw-r--r-- | libcxx/src/thread.cpp | 2 | ||||
-rw-r--r-- | libcxxabi/CMakeLists.txt | 4 | ||||
-rw-r--r-- | libcxxabi/src/cxa_exception_storage.cpp | 2 | ||||
-rw-r--r-- | libcxxabi/src/cxa_guard_impl.h | 2 | ||||
-rw-r--r-- | libcxxabi/src/cxa_thread_atexit.cpp | 2 | ||||
-rw-r--r-- | libcxxabi/src/fallback_malloc.cpp | 2 |
16 files changed, 23 insertions, 16 deletions
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt index bfbba319d72..fa488da0885 100644 --- a/libcxx/CMakeLists.txt +++ b/libcxx/CMakeLists.txt @@ -565,7 +565,12 @@ function(cxx_add_basic_build_flags target) endif() if (LIBCXX_HAS_COMMENT_LIB_PRAGMA) - target_compile_definitions(${target} PRIVATE -D_LIBCPP_HAS_COMMENT_LIB_PRAGMA) + if (LIBCXX_HAS_PTHREAD_LIB) + target_compile_definitions(${target} PRIVATE -D_LIBCPP_LINK_PTHREAD_LIB) + endif() + if (LIBCXX_HAS_RT_LIB) + target_compile_definitions(${target} PRIVATE -D_LIBCPP_LINK_RT_LIB) + endif() endif() endfunction() diff --git a/libcxx/src/algorithm.cpp b/libcxx/src/algorithm.cpp index ffdcb5fccde..40669fb9e75 100644 --- a/libcxx/src/algorithm.cpp +++ b/libcxx/src/algorithm.cpp @@ -10,7 +10,7 @@ #include "random" #ifndef _LIBCPP_HAS_NO_THREADS #include "mutex" -#if defined(__unix__) && !defined(__ANDROID__) && defined(__ELF__) && defined(_LIBCPP_HAS_COMMENT_LIB_PRAGMA) +#if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB) #pragma comment(lib, "pthread") #endif #endif diff --git a/libcxx/src/chrono.cpp b/libcxx/src/chrono.cpp index 2d78caea61c..9d448b6a985 100644 --- a/libcxx/src/chrono.cpp +++ b/libcxx/src/chrono.cpp @@ -37,7 +37,7 @@ #endif #endif -#if defined(__unix__) && defined(__ELF__) && defined(_LIBCPP_HAS_COMMENT_LIB_PRAGMA) +#if defined(__ELF__) && defined(_LIBCPP_LINK_RT_LIB) #pragma comment(lib, "rt") #endif diff --git a/libcxx/src/condition_variable.cpp b/libcxx/src/condition_variable.cpp index bf89d255dd8..d133b010d71 100644 --- a/libcxx/src/condition_variable.cpp +++ b/libcxx/src/condition_variable.cpp @@ -15,7 +15,7 @@ #include "system_error" #include "__undef_macros" -#if defined(__unix__) && !defined(__ANDROID__) && defined(__ELF__) && defined(_LIBCPP_HAS_COMMENT_LIB_PRAGMA) +#if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB) #pragma comment(lib, "pthread") #endif diff --git a/libcxx/src/debug.cpp b/libcxx/src/debug.cpp index 1f5ce1052f8..20055fcf759 100644 --- a/libcxx/src/debug.cpp +++ b/libcxx/src/debug.cpp @@ -15,7 +15,7 @@ #include "__hash_table" #ifndef _LIBCPP_HAS_NO_THREADS #include "mutex" -#if defined(__unix__) && !defined(__ANDROID__) && defined(__ELF__) && defined(_LIBCPP_HAS_COMMENT_LIB_PRAGMA) +#if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB) #pragma comment(lib, "pthread") #endif #endif diff --git a/libcxx/src/experimental/memory_resource.cpp b/libcxx/src/experimental/memory_resource.cpp index e9872628317..68c5bc99cc7 100644 --- a/libcxx/src/experimental/memory_resource.cpp +++ b/libcxx/src/experimental/memory_resource.cpp @@ -12,7 +12,7 @@ #include "atomic" #elif !defined(_LIBCPP_HAS_NO_THREADS) #include "mutex" -#if defined(__unix__) && !defined(__ANDROID__) && defined(__ELF__) && defined(_LIBCPP_HAS_COMMENT_LIB_PRAGMA) +#if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB) #pragma comment(lib, "pthread") #endif #endif diff --git a/libcxx/src/filesystem/operations.cpp b/libcxx/src/filesystem/operations.cpp index 08a6b2b86e2..876399fb4d4 100644 --- a/libcxx/src/filesystem/operations.cpp +++ b/libcxx/src/filesystem/operations.cpp @@ -44,7 +44,7 @@ #include <sys/time.h> // for gettimeofday and timeval #endif // !defined(CLOCK_REALTIME) -#if defined(__unix__) && defined(__ELF__) && defined(_LIBCPP_HAS_COMMENT_LIB_PRAGMA) +#if defined(__ELF__) && defined(_LIBCPP_LINK_RT_LIB) #pragma comment(lib, "rt") #endif diff --git a/libcxx/src/memory.cpp b/libcxx/src/memory.cpp index e89d94f27e4..633c9a6f565 100644 --- a/libcxx/src/memory.cpp +++ b/libcxx/src/memory.cpp @@ -10,7 +10,7 @@ #ifndef _LIBCPP_HAS_NO_THREADS #include "mutex" #include "thread" -#if defined(__unix__) && !defined(__ANDROID__) && defined(__ELF__) && defined(_LIBCPP_HAS_COMMENT_LIB_PRAGMA) +#if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB) #pragma comment(lib, "pthread") #endif #endif diff --git a/libcxx/src/mutex.cpp b/libcxx/src/mutex.cpp index 7e979cd8904..27a4fd89277 100644 --- a/libcxx/src/mutex.cpp +++ b/libcxx/src/mutex.cpp @@ -13,7 +13,7 @@ #include "__undef_macros" #ifndef _LIBCPP_HAS_NO_THREADS -#if defined(__unix__) && !defined(__ANDROID__) && defined(__ELF__) && defined(_LIBCPP_HAS_COMMENT_LIB_PRAGMA) +#if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB) #pragma comment(lib, "pthread") #endif #endif diff --git a/libcxx/src/shared_mutex.cpp b/libcxx/src/shared_mutex.cpp index 9e6d5202aaf..5feef9f4889 100644 --- a/libcxx/src/shared_mutex.cpp +++ b/libcxx/src/shared_mutex.cpp @@ -10,7 +10,7 @@ #ifndef _LIBCPP_HAS_NO_THREADS #include "shared_mutex" -#if defined(__unix__) && !defined(__ANDROID__) && defined(__ELF__) && defined(_LIBCPP_HAS_COMMENT_LIB_PRAGMA) +#if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB) #pragma comment(lib, "pthread") #endif diff --git a/libcxx/src/thread.cpp b/libcxx/src/thread.cpp index 967a53735ac..c0bc1cbbbbc 100644 --- a/libcxx/src/thread.cpp +++ b/libcxx/src/thread.cpp @@ -35,7 +35,7 @@ #include <windows.h> #endif -#if defined(__unix__) && !defined(__ANDROID__) && defined(__ELF__) && defined(_LIBCPP_HAS_COMMENT_LIB_PRAGMA) +#if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB) #pragma comment(lib, "pthread") #endif diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt index d914b6e0290..0ddcd5f971f 100644 --- a/libcxxabi/CMakeLists.txt +++ b/libcxxabi/CMakeLists.txt @@ -456,7 +456,9 @@ if (LIBCXXABI_BAREMETAL) endif() if (LIBCXXABI_HAS_COMMENT_LIB_PRAGMA) - add_definitions(-D_LIBCXXABI_HAS_COMMENT_LIB_PRAGMA) + if (LIBCXXABI_HAS_PTHREAD_LIB) + add_definitions(-D_LIBCXXABI_LINK_PTHREAD_LIB) + endif() endif() string(REPLACE ";" " " LIBCXXABI_CXX_FLAGS "${LIBCXXABI_CXX_FLAGS}") diff --git a/libcxxabi/src/cxa_exception_storage.cpp b/libcxxabi/src/cxa_exception_storage.cpp index 28c0122ff07..24ff55e39d2 100644 --- a/libcxxabi/src/cxa_exception_storage.cpp +++ b/libcxxabi/src/cxa_exception_storage.cpp @@ -46,7 +46,7 @@ extern "C" { #include "abort_message.h" #include "fallback_malloc.h" -#if defined(__unix__) && !defined(__ANDROID__) && defined(__ELF__) && defined(_LIBCXXABI_HAS_COMMENT_LIB_PRAGMA) +#if defined(__ELF__) && defined(_LIBCXXABI_LINK_PTHREAD_LIB) #pragma comment(lib, "pthread") #endif diff --git a/libcxxabi/src/cxa_guard_impl.h b/libcxxabi/src/cxa_guard_impl.h index 98e42ba2fb0..a8ec0b72fee 100644 --- a/libcxxabi/src/cxa_guard_impl.h +++ b/libcxxabi/src/cxa_guard_impl.h @@ -50,7 +50,7 @@ #include <stdlib.h> #include <__threading_support> #ifndef _LIBCXXABI_HAS_NO_THREADS -#if defined(__unix__) && !defined(__ANDROID__) && defined(__ELF__) && defined(_LIBCXXABI_HAS_COMMENT_LIB_PRAGMA) +#if defined(__ELF__) && defined(_LIBCXXABI_LINK_PTHREAD_LIB) #pragma comment(lib, "pthread") #endif #endif diff --git a/libcxxabi/src/cxa_thread_atexit.cpp b/libcxxabi/src/cxa_thread_atexit.cpp index 923b265b27c..a940eaf2f9c 100644 --- a/libcxxabi/src/cxa_thread_atexit.cpp +++ b/libcxxabi/src/cxa_thread_atexit.cpp @@ -10,7 +10,7 @@ #include "cxxabi.h" #include <__threading_support> #ifndef _LIBCXXABI_HAS_NO_THREADS -#if defined(__unix__) && !defined(__ANDROID__) && defined(__ELF__) && defined(_LIBCXXABI_HAS_COMMENT_LIB_PRAGMA) +#if defined(__ELF__) && defined(_LIBCXXABI_LINK_PTHREAD_LIB) #pragma comment(lib, "pthread") #endif #endif diff --git a/libcxxabi/src/fallback_malloc.cpp b/libcxxabi/src/fallback_malloc.cpp index 8f301bcacd1..fdae40764ab 100644 --- a/libcxxabi/src/fallback_malloc.cpp +++ b/libcxxabi/src/fallback_malloc.cpp @@ -13,7 +13,7 @@ #include <__threading_support> #ifndef _LIBCXXABI_HAS_NO_THREADS -#if defined(__unix__) && !defined(__ANDROID__) && defined(__ELF__) && defined(_LIBCXXABI_HAS_COMMENT_LIB_PRAGMA) +#if defined(__ELF__) && defined(_LIBCXXABI_LINK_PTHREAD_LIB) #pragma comment(lib, "pthread") #endif #endif |