summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2018-05-18 18:44:37 +0000
committerReid Kleckner <rnk@google.com>2018-05-18 18:44:37 +0000
commitf1588bfea7e2156d892b8feb730a71e934392609 (patch)
tree3002196f381db62abdf88148e10110f48adfcdf8 /CMakeLists.txt
parente9de4d9dcedd7c3ae3046692702d2c3ac0296de0 (diff)
Revert r332683 & r332684 relating to compiler runtime checks
r332683 passes flags to the compiler without first checking if they are supported. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@332754 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt56
1 files changed, 29 insertions, 27 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b7bd46107..84a7dcd81 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -112,6 +112,9 @@ option(COMPILER_RT_EXTERNALIZE_DEBUGINFO
# COMPILER_RT_DEBUG_PYBOOL is used by lit.common.configured.in.
pythonize_bool(COMPILER_RT_DEBUG)
+include(HandleCompilerRT)
+include(config-ix)
+
if(APPLE AND SANITIZER_MIN_OSX_VERSION AND SANITIZER_MIN_OSX_VERSION VERSION_LESS "10.9")
# Mac OS X prior to 10.9 had problems with exporting symbols from
# libc++/libc++abi.
@@ -120,7 +123,7 @@ else()
set(cxxabi_supported ON)
endif()
-option(SANITIZER_ALLOW_CXXABI "Allow use of C++ ABI details in sanitizers" ON)
+option(SANITIZER_ALLOW_CXXABI "Allow use of C++ ABI details in ubsan" ON)
set(SANITIZE_CAN_USE_CXXABI OFF)
if (cxxabi_supported AND SANITIZER_ALLOW_CXXABI)
@@ -128,51 +131,48 @@ if (cxxabi_supported AND SANITIZER_ALLOW_CXXABI)
endif()
pythonize_bool(SANITIZER_CAN_USE_CXXABI)
-check_link_libraries(cxx_link_libraries)
-
set(SANITIZER_CXX_ABI "default" CACHE STRING
"Specify C++ ABI library to use.")
-set(CXXABIS none default libc++ libstdc++)
+set(CXXABIS none default libcxxabi libstdc++ libc++)
set_property(CACHE SANITIZER_CXX_ABI PROPERTY STRINGS ;${CXXABIS})
if (SANITIZER_CXX_ABI STREQUAL "default")
- if(APPLE)
- set(SANITIZER_CXX_ABI_LIBNAME "libc++")
+ if (HAVE_LIBCXXABI AND COMPILER_RT_DEFAULT_TARGET_ONLY)
+ set(SANITIZER_CXX_ABI_LIBNAME "libcxxabi")
+ set(SANITIZER_CXX_ABI_INTREE 1)
+ elseif (APPLE)
+ set(SANITIZER_CXX_ABI_LIBNAME "libcxxabi")
set(SANITIZER_CXX_ABI_SYSTEM 1)
- elseif("stdc++" IN_LIST cxx_link_libraries)
+ else()
set(SANITIZER_CXX_ABI_LIBNAME "libstdc++")
set(SANITIZER_CXX_ABI_SYSTEM 1)
- elseif("c++" IN_LIST cxx_link_libraries)
- set(SANITIZER_CXX_ABI_LIBNAME "libc++")
endif()
else()
set(SANITIZER_CXX_ABI_LIBNAME "${SANITIZER_CXX_ABI}")
endif()
-if (SANITIZER_CXX_ABI_LIBNAME STREQUAL "libc++")
- if(SANITIZER_CXX_ABI_SYSTEM)
- list(APPEND SANITIZER_CXX_ABI_LIBRARY "c++")
- else()
- if(TARGET cxxabi_shared OR (HAVE_LIBCXXABI AND NOT LIBCXX_ENABLE_STATIC_ABI_LIBRARY))
+if (SANITIZER_CXX_ABI_LIBNAME STREQUAL "libcxxabi")
+ if (SANITIZER_CXX_ABI_INTREE)
+ if (NOT LIBCXXABI_ENABLE_STATIC_UNWINDER AND (TARGET unwind_shared OR HAVE_LIBUNWIND))
+ list(APPEND SANITIZER_CXX_ABI_LIBRARY unwind_shared)
+ elseif (LIBCXXABI_ENABLE_STATIC_UNWINDER AND (TARGET unwind_static OR HAVE_LIBUNWIND))
+ list(APPEND SANITIZER_CXX_ABI_LIBRARY unwind_static)
+ endif()
+ if (NOT LIBCXX_ENABLE_STATIC_ABI_LIBRARY AND (TARGET cxxabi_shared OR HAVE_LIBCXXABI))
list(APPEND SANITIZER_CXX_ABI_LIBRARY cxxabi_shared)
- elseif(TARGET cxxabi_shared OR (HAVE_LIBCXXABI AND LIBCXX_ENABLE_STATIC_ABI_LIBRARY))
+ elseif (LIBCXX_ENABLE_STATIC_ABI_LIBRARY AND (TARGET cxxabi_static OR HAVE_LIBCXXABI))
list(APPEND SANITIZER_CXX_ABI_LIBRARY cxxabi_static)
- else()
- list(APPEND SANITIZER_CXX_ABI_LIBRARY "c++")
endif()
+ else()
+ list(APPEND SANITIZER_CXX_ABI_LIBRARY "c++abi")
endif()
+elseif (SANITIZER_CXX_ABI_LIBNAME STREQUAL "libc++")
+ list(APPEND SANITIZER_CXX_ABI_LIBRARY "c++")
elseif (SANITIZER_CXX_ABI_LIBNAME STREQUAL "libstdc++")
- list(APPEND SANITIZER_CXX_ABI_LIBRARY "stdc++")
+ append_list_if(COMPILER_RT_HAS_LIBSTDCXX stdc++ SANITIZER_CXX_ABI_LIBRARY)
endif()
-check_runtime_library(runtime_library)
-if(runtime_library MATCHES ".*libgcc.*")
- set(COMPILER_RT_RUNTIME_LIBRARY "libgcc")
-elseif(runtime_library MATCHES ".*libclang_rt.builtins.*")
- set(COMPILER_RT_RUNTIME_LIBRARY "compiler-rt")
-endif()
-
-include(config-ix)
+option(SANITIZER_USE_COMPILER_RT "Use compiler-rt builtins instead of libgcc" OFF)
#================================
# Setup Compiler Flags
@@ -320,7 +320,9 @@ append_list_if(COMPILER_RT_HAS_WD4800_FLAG /wd4800 SANITIZER_COMMON_CFLAGS)
# Set common link flags.
append_list_if(COMPILER_RT_HAS_NODEFAULTLIBS_FLAG -nodefaultlibs SANITIZER_COMMON_LINK_FLAGS)
-if (COMPILER_RT_RUNTIME_LIBRARY STREQUAL "compiler-rt")
+if (SANITIZER_USE_COMPILER_RT)
+ list(APPEND SANITIZER_COMMON_LINK_FLAGS -rtlib=compiler-rt)
+ find_compiler_rt_library(builtins COMPILER_RT_BUILTINS_LIBRARY)
list(APPEND SANITIZER_COMMON_LINK_LIBS ${COMPILER_RT_BUILTINS_LIBRARY})
else()
if (ANDROID)