summaryrefslogtreecommitdiffstats
path: root/libunwind
diff options
context:
space:
mode:
authorPetr Hosek <phosek@chromium.org>2019-05-30 04:40:21 +0000
committerPetr Hosek <phosek@chromium.org>2019-05-30 04:40:21 +0000
commit789b7f0828b08f5c4bf9ff1ff7ef733c73ecdc0a (patch)
tree529f48a2d6693be385cf978860ec04995e6dfe86 /libunwind
parent2c91c3b7af7cd4da64f1babde3798d65522a21e4 (diff)
downloadbcm5719-llvm-789b7f0828b08f5c4bf9ff1ff7ef733c73ecdc0a.tar.gz
bcm5719-llvm-789b7f0828b08f5c4bf9ff1ff7ef733c73ecdc0a.zip
[runtimes] Check if pragma comment(lib, ...) is supported first
This fixes the issue introduced by r362048 where we always use pragma comment(lib, ...) for dependent libraries when the compiler is Clang, but older Clang versions don't support this pragma so we need to check first if it's supported before using it. llvm-svn: 362055
Diffstat (limited to 'libunwind')
-rw-r--r--libunwind/CMakeLists.txt4
-rw-r--r--libunwind/cmake/config-ix.cmake11
-rw-r--r--libunwind/src/AddressSpace.hpp2
-rw-r--r--libunwind/src/RWMutex.hpp2
4 files changed, 15 insertions, 4 deletions
diff --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt
index 65cd5b2c672..16bfb9a8202 100644
--- a/libunwind/CMakeLists.txt
+++ b/libunwind/CMakeLists.txt
@@ -362,6 +362,10 @@ if (WIN32 AND LIBUNWIND_ENABLE_STATIC AND NOT LIBUNWIND_ENABLE_SHARED)
add_definitions(-D_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS)
endif()
+if (LIBUNWIND_HAS_COMMENT_LIB_PRAGMA)
+ add_definitions(-D_LIBUNWIND_HAS_COMMENT_LIB_PRAGMA)
+endif()
+
#===============================================================================
# Setup Source Code
#===============================================================================
diff --git a/libunwind/cmake/config-ix.cmake b/libunwind/cmake/config-ix.cmake
index 670c31f2d09..2c27ecf5207 100644
--- a/libunwind/cmake/config-ix.cmake
+++ b/libunwind/cmake/config-ix.cmake
@@ -1,7 +1,7 @@
-
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
include(CheckLibraryExists)
+include(CheckCSourceCompiles)
check_library_exists(c fopen "" LIBUNWIND_HAS_C_LIB)
@@ -55,6 +55,14 @@ if (LIBUNWIND_HAS_NODEFAULTLIBS_FLAG)
endif ()
endif ()
+# Check compiler pragmas
+if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+ check_c_source_compiles("
+#pragma comment(lib, \"c\")
+int main() { return 0; }
+" LIBUNWIND_HAS_COMMENT_LIB_PRAGMA)
+endif()
+
# Check compiler flags
check_c_compiler_flag(-funwind-tables LIBUNWIND_HAS_FUNWIND_TABLES)
check_cxx_compiler_flag(-fno-exceptions LIBUNWIND_HAS_NO_EXCEPTIONS_FLAG)
@@ -96,4 +104,3 @@ endif()
check_library_exists(dl dladdr "" LIBUNWIND_HAS_DL_LIB)
check_library_exists(pthread pthread_once "" LIBUNWIND_HAS_PTHREAD_LIB)
-
diff --git a/libunwind/src/AddressSpace.hpp b/libunwind/src/AddressSpace.hpp
index 66439530309..fb07c807db9 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(__clang__)
+#if defined(__unix__) && defined(__ELF__) && defined(_LIBUNWIND_HAS_COMMENT_LIB_PRAGMA)
#pragma comment(lib, "dl")
#endif
#endif
diff --git a/libunwind/src/RWMutex.hpp b/libunwind/src/RWMutex.hpp
index 4f234a77edf..a37ac77144f 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(__ELF__) && defined(__clang__)
+#if defined(__unix__) && defined(__ELF__) && defined(_LIBUNWIND_HAS_COMMENT_LIB_PRAGMA)
#pragma comment(lib, "pthread")
#endif
#endif
OpenPOWER on IntegriCloud