aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt110
1 files changed, 36 insertions, 74 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index cae5981b2b46..5f8b4d1bd269 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -9,7 +9,7 @@
# Check if compiler-rt is built as a standalone project.
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
- project(CompilerRT C CXX)
+ project(CompilerRT C CXX ASM)
set(COMPILER_RT_STANDALONE_BUILD TRUE)
else()
set(COMPILER_RT_STANDALONE_BUILD FALSE)
@@ -22,7 +22,7 @@ endif()
if (NOT MSVC)
cmake_minimum_required(VERSION 2.8.8)
else()
- # Version 2.8.12.1 is required to build with Visual Studion 2013.
+ # Version 2.8.12.1 is required to build with Visual Studio 2013.
cmake_minimum_required(VERSION 2.8.12.1)
endif()
@@ -43,6 +43,11 @@ endif()
# Top level target used to build all compiler-rt libraries.
add_custom_target(compiler-rt ALL)
+option(COMPILER_RT_BUILD_BUILTINS "Build builtins" ON)
+mark_as_advanced(COMPILER_RT_BUILD_BUILTINS)
+option(COMPILER_RT_BUILD_SANITIZERS "Build sanitizers" ON)
+mark_as_advanced(COMPILER_RT_BUILD_SANITIZERS)
+
if (NOT COMPILER_RT_STANDALONE_BUILD)
# Compute the Clang version from the LLVM version.
# FIXME: We should be able to reuse CLANG_VERSION variable calculated
@@ -132,22 +137,27 @@ else()
set(COMPILER_RT_TEST_COMPILER_ID GNU)
endif()
-# Tests using XFAIL use the first value in COMPILER_RT_TEST_TARGET_TRIPLE
-set(COMPILER_RT_TEST_TARGET_TRIPLE ${TARGET_TRIPLE} CACHE STRING
- "Default triple for cross-compiled executables")
-string(REPLACE "-" ";" TARGET_TRIPLE_LIST ${COMPILER_RT_TEST_TARGET_TRIPLE})
-list(GET TARGET_TRIPLE_LIST 0 COMPILER_RT_TEST_TARGET_ARCH)
-list(GET TARGET_TRIPLE_LIST 1 COMPILER_RT_TEST_TARGET_OS)
-list(GET TARGET_TRIPLE_LIST 2 COMPILER_RT_TEST_TARGET_ABI)
+set(COMPILER_RT_DEFAULT_TARGET_TRIPLE ${TARGET_TRIPLE} CACHE STRING
+ "Default triple for which compiler-rt runtimes will be built.")
+if(DEFINED COMPILER_RT_TEST_TARGET_TRIPLE)
+ # Backwards compatibility: this variable used to be called
+ # COMPILER_RT_TEST_TARGET_TRIPLE.
+ set(COMPILER_RT_DEFAULT_TARGET_TRIPLE ${COMPILER_RT_TEST_TARGET_TRIPLE})
+endif()
+
+string(REPLACE "-" ";" TARGET_TRIPLE_LIST ${COMPILER_RT_DEFAULT_TARGET_TRIPLE})
+list(GET TARGET_TRIPLE_LIST 0 COMPILER_RT_DEFAULT_TARGET_ARCH)
+list(GET TARGET_TRIPLE_LIST 1 COMPILER_RT_DEFAULT_TARGET_OS)
+list(GET TARGET_TRIPLE_LIST 2 COMPILER_RT_DEFAULT_TARGET_ABI)
# Determine if test target triple is specified explicitly, and doesn't match the
# default.
-if(NOT COMPILER_RT_TEST_TARGET_TRIPLE STREQUAL TARGET_TRIPLE)
- set(COMPILER_RT_HAS_EXPLICIT_TEST_TARGET_TRIPLE TRUE)
+if(NOT COMPILER_RT_DEFAULT_TARGET_TRIPLE STREQUAL TARGET_TRIPLE)
+ set(COMPILER_RT_HAS_EXPLICIT_DEFAULT_TARGET_TRIPLE TRUE)
else()
- set(COMPILER_RT_HAS_EXPLICIT_TEST_TARGET_TRIPLE FALSE)
+ set(COMPILER_RT_HAS_EXPLICIT_DEFAULT_TARGET_TRIPLE FALSE)
endif()
-if ("${COMPILER_RT_TEST_TARGET_ABI}" STREQUAL "androideabi")
+if ("${COMPILER_RT_DEFAULT_TARGET_ABI}" STREQUAL "androideabi")
set(ANDROID 1)
endif()
@@ -179,6 +189,8 @@ else()
endif()
option(COMPILER_RT_DEBUG "Build runtimes with full debug info" OFF)
+option(COMPILER_RT_EXTERNALIZE_DEBUGINFO
+ "Generate dSYM files and strip executables and libraries (Darwin Only)" OFF)
# COMPILER_RT_DEBUG_PYBOOL is used by lit.common.configured.in.
pythonize_bool(COMPILER_RT_DEBUG)
@@ -216,6 +228,7 @@ append_list_if(COMPILER_RT_HAS_FUNWIND_TABLES_FLAG -funwind-tables SANITIZER_COM
append_list_if(COMPILER_RT_HAS_FNO_STACK_PROTECTOR_FLAG -fno-stack-protector SANITIZER_COMMON_CFLAGS)
append_list_if(COMPILER_RT_HAS_FNO_SANITIZE_SAFE_STACK_FLAG -fno-sanitize=safe-stack SANITIZER_COMMON_CFLAGS)
append_list_if(COMPILER_RT_HAS_FVISIBILITY_HIDDEN_FLAG -fvisibility=hidden SANITIZER_COMMON_CFLAGS)
+append_list_if(COMPILER_RT_HAS_FVISIBILITY_INLINES_HIDDEN_FLAG -fvisibility-inlines-hidden SANITIZER_COMMON_CFLAGS)
append_list_if(COMPILER_RT_HAS_FNO_FUNCTION_SECTIONS_FLAG -fno-function-sections SANITIZER_COMMON_CFLAGS)
append_list_if(COMPILER_RT_HAS_FNO_LTO_FLAG -fno-lto SANITIZER_COMMON_CFLAGS)
@@ -250,8 +263,7 @@ endif()
# FIXME: Fix all sanitizers and add -Wframe-larger-than to
# SANITIZER_COMMON_FLAGS
if(COMPILER_RT_HAS_WFRAME_LARGER_THAN_FLAG AND NOT COMPILER_RT_DEBUG
- AND NOT ${LLVM_NATIVE_ARCH} STREQUAL "PowerPC"
- AND NOT ${LLVM_NATIVE_ARCH} STREQUAL "Mips")
+ AND NOT ${COMPILER_RT_DEFAULT_TARGET_ARCH} MATCHES "powerpc|mips")
set(SANITIZER_LIMIT_FRAME_SIZE TRUE)
else()
set(SANITIZER_LIMIT_FRAME_SIZE FALSE)
@@ -276,64 +288,6 @@ append_list_if(COMPILER_RT_HAS_WD4291_FLAG /wd4291 SANITIZER_COMMON_CFLAGS)
append_list_if(COMPILER_RT_HAS_WD4391_FLAG /wd4391 SANITIZER_COMMON_CFLAGS)
append_list_if(COMPILER_RT_HAS_WD4722_FLAG /wd4722 SANITIZER_COMMON_CFLAGS)
append_list_if(COMPILER_RT_HAS_WD4800_FLAG /wd4800 SANITIZER_COMMON_CFLAGS)
-if(APPLE)
- macro(find_darwin_sdk_dir var sdk_name)
- # Let's first try the internal SDK, otherwise use the public SDK.
- execute_process(
- COMMAND xcodebuild -version -sdk ${sdk_name}.internal Path
- OUTPUT_VARIABLE ${var}
- OUTPUT_STRIP_TRAILING_WHITESPACE
- ERROR_FILE /dev/null
- )
- if(${var} STREQUAL "")
- execute_process(
- COMMAND xcodebuild -version -sdk ${sdk_name} Path
- OUTPUT_VARIABLE ${var}
- OUTPUT_STRIP_TRAILING_WHITESPACE
- ERROR_FILE /dev/null
- )
- endif()
- endmacro()
-
- find_darwin_sdk_dir(OSX_SDK_DIR macosx)
- find_darwin_sdk_dir(IOSSIM_SDK_DIR iphonesimulator)
-
- set(SANITIZER_COMMON_SUPPORTED_OS osx)
- string(REGEX MATCH "-mmacosx-version-min=([.0-9]+)"
- MACOSX_VERSION_MIN_FLAG "${CMAKE_CXX_FLAGS}")
- if(MACOSX_VERSION_MIN_FLAG)
- set(SANITIZER_MIN_OSX_VERSION "${CMAKE_MATCH_1}")
- elseif(CMAKE_OSX_DEPLOYMENT_TARGET)
- set(SANITIZER_MIN_OSX_VERSION ${CMAKE_OSX_DEPLOYMENT_TARGET})
- else()
- set(SANITIZER_MIN_OSX_VERSION 10.9)
- if(IOSSIM_SDK_DIR)
- list(APPEND SANITIZER_COMMON_SUPPORTED_OS iossim)
- endif()
- endif()
- if(SANITIZER_MIN_OSX_VERSION VERSION_LESS "10.7")
- message(FATAL_ERROR "Too old OS X version: ${SANITIZER_MIN_OSX_VERSION}")
- endif()
-
- set(CMAKE_OSX_DEPLOYMENT_TARGET "") # We evaluate target OS X version above.
- set(DARWIN_osx_CFLAGS -mmacosx-version-min=${SANITIZER_MIN_OSX_VERSION}
- -stdlib=libc++)
- set(DARWIN_iossim_CFLAGS
- -stdlib=libc++
- -mios-simulator-version-min=7.0 -isysroot ${IOSSIM_SDK_DIR})
- set(DARWIN_osx_LINKFLAGS -mmacosx-version-min=${SANITIZER_MIN_OSX_VERSION}
- -stdlib=libc++ -lc++ -lc++abi)
- set(DARWIN_iossim_LINKFLAGS
- -stdlib=libc++ -lc++ -lc++abi
- -Wl,-ios_simulator_version_min,7.0.0
- -mios-simulator-version-min=7.0
- -isysroot ${IOSSIM_SDK_DIR})
-
- if(OSX_SDK_DIR)
- list(APPEND DARWIN_osx_CFLAGS -isysroot ${OSX_SDK_DIR})
- list(APPEND DARWIN_osx_LINKFLAGS -isysroot ${OSX_SDK_DIR})
- endif()
-endif()
if(APPLE AND SANITIZER_MIN_OSX_VERSION VERSION_LESS "10.9")
# Mac OS X prior to 10.9 had problems with exporting symbols from
@@ -353,9 +307,17 @@ else()
set(COMPILER_RT_HAS_LIBCXX_SOURCES FALSE)
endif()
+set(COMPILER_RT_LLD_PATH ${LLVM_MAIN_SRC_DIR}/tools/lld)
+if(EXISTS ${COMPILER_RT_LLD_PATH}/)
+ set(COMPILER_RT_HAS_LLD_SOURCES TRUE)
+else()
+ set(COMPILER_RT_HAS_LLD_SOURCES FALSE)
+endif()
+pythonize_bool(COMPILER_RT_HAS_LLD_SOURCES)
+
add_subdirectory(lib)
if(COMPILER_RT_INCLUDE_TESTS)
add_subdirectory(unittests)
+ add_subdirectory(test)
endif()
-add_subdirectory(test)