2012-04-05 06:12:04 +08:00
|
|
|
# CMake build for CompilerRT.
|
|
|
|
#
|
|
|
|
# This build assumes that CompilerRT is checked out into the
|
2014-02-19 15:49:16 +08:00
|
|
|
# 'projects/compiler-rt' inside of an LLVM tree.
|
|
|
|
# Standalone build system for CompilerRT is not yet ready.
|
2012-04-05 06:12:04 +08:00
|
|
|
#
|
|
|
|
# An important constraint of the build is that it only produces libraries
|
|
|
|
# based on the ability of the host toolchain to target various platforms.
|
|
|
|
|
2014-02-19 15:49:16 +08:00
|
|
|
# Check if compiler-rt is built as a standalone project.
|
|
|
|
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
2015-07-29 00:52:42 +08:00
|
|
|
project(CompilerRT C CXX ASM)
|
2014-02-19 15:49:16 +08:00
|
|
|
set(COMPILER_RT_STANDALONE_BUILD TRUE)
|
|
|
|
endif()
|
|
|
|
|
2016-06-01 04:21:42 +08:00
|
|
|
cmake_minimum_required(VERSION 3.4.3)
|
2016-06-03 04:33:33 +08:00
|
|
|
# FIXME:
|
|
|
|
# The OLD behavior (pre 3.2) for this policy is to not set the value of the
|
|
|
|
# CMAKE_EXE_LINKER_FLAGS variable in the generated test project. The NEW behavior
|
|
|
|
# for this policy is to set the value of the CMAKE_EXE_LINKER_FLAGS variable
|
|
|
|
# in the test project to the same as it is in the calling project. The new
|
|
|
|
# behavior cause the compiler_rt test to fail during try_compile: see
|
|
|
|
# projects/compiler-rt/cmake/Modules/CompilerRTUtils.cmake:121 such that
|
|
|
|
# CAN_TARGET_${arch} is not set properly. This results in COMPILER_RT_SUPPORTED_ARCH
|
|
|
|
# not being updated properly leading to poblems.
|
2016-06-10 05:32:17 +08:00
|
|
|
cmake_policy(SET CMP0056 OLD)
|
2014-02-26 14:45:11 +08:00
|
|
|
|
[CMake] Support platform building builtins without a full toolchain
Summary:
This patch adds support for building lib/builtins without a fully functioning toolchain. It allows you to bootstrap a cross-compiler, which previously couldn't be done with CMake.
This patch contains the following specific changes:
* Split builtin-specific code out of config-ix.cmake into builtin-config-ix.cmake
* Split some common CMake functionality needed by both builtins and sanitizers into base-config-ix.cmake
* Made lib/builtins/CMakeLists.txt able to be a top-level CMake configuration
I have tested this on Darwin targeting embedded Darwin, and on FreeBSD x86_64 targeting FreeBSD AArch64.
This patch depends on http://reviews.llvm.org/D19692, and is the last part of http://reviews.llvm.org/D16653.
Reviewers: samsonov, iains, jroelofs
Subscribers: compnerd, aemerson, tberghammer, danalbert, srhines, emaste, llvm-commits
Differential Revision: http://reviews.llvm.org/D19742
llvm-svn: 268977
2016-05-10 05:45:52 +08:00
|
|
|
# Add path for custom compiler-rt modules.
|
|
|
|
list(INSERT CMAKE_MODULE_PATH 0
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules"
|
|
|
|
)
|
|
|
|
|
|
|
|
include(base-config-ix)
|
2013-10-01 20:52:15 +08:00
|
|
|
|
2015-09-15 03:59:24 +08:00
|
|
|
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)
|
|
|
|
|
[CMake] Support platform building builtins without a full toolchain
Summary:
This patch adds support for building lib/builtins without a fully functioning toolchain. It allows you to bootstrap a cross-compiler, which previously couldn't be done with CMake.
This patch contains the following specific changes:
* Split builtin-specific code out of config-ix.cmake into builtin-config-ix.cmake
* Split some common CMake functionality needed by both builtins and sanitizers into base-config-ix.cmake
* Made lib/builtins/CMakeLists.txt able to be a top-level CMake configuration
I have tested this on Darwin targeting embedded Darwin, and on FreeBSD x86_64 targeting FreeBSD AArch64.
This patch depends on http://reviews.llvm.org/D19692, and is the last part of http://reviews.llvm.org/D16653.
Reviewers: samsonov, iains, jroelofs
Subscribers: compnerd, aemerson, tberghammer, danalbert, srhines, emaste, llvm-commits
Differential Revision: http://reviews.llvm.org/D19742
llvm-svn: 268977
2016-05-10 05:45:52 +08:00
|
|
|
if (COMPILER_RT_STANDALONE_BUILD)
|
2014-02-19 18:04:29 +08:00
|
|
|
if (NOT LLVM_CONFIG_PATH)
|
2014-03-05 17:21:49 +08:00
|
|
|
find_program(LLVM_CONFIG_PATH "llvm-config"
|
|
|
|
DOC "Path to llvm-config binary")
|
2014-02-19 18:04:29 +08:00
|
|
|
if (NOT LLVM_CONFIG_PATH)
|
|
|
|
message(FATAL_ERROR "llvm-config not found: specify LLVM_CONFIG_PATH")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
execute_process(
|
|
|
|
COMMAND ${LLVM_CONFIG_PATH} "--obj-root" "--bindir" "--libdir" "--src-root"
|
|
|
|
RESULT_VARIABLE HAD_ERROR
|
|
|
|
OUTPUT_VARIABLE CONFIG_OUTPUT)
|
|
|
|
if (HAD_ERROR)
|
|
|
|
message(FATAL_ERROR "llvm-config failed with status ${HAD_ERROR}")
|
2014-02-19 15:49:16 +08:00
|
|
|
endif()
|
2014-02-19 18:04:29 +08:00
|
|
|
string(REGEX REPLACE "[ \t]*[\r\n]+[ \t]*" ";" CONFIG_OUTPUT ${CONFIG_OUTPUT})
|
|
|
|
list(GET CONFIG_OUTPUT 0 LLVM_BINARY_DIR)
|
|
|
|
list(GET CONFIG_OUTPUT 1 LLVM_TOOLS_BINARY_DIR)
|
|
|
|
list(GET CONFIG_OUTPUT 2 LLVM_LIBRARY_DIR)
|
|
|
|
list(GET CONFIG_OUTPUT 3 LLVM_MAIN_SRC_DIR)
|
|
|
|
|
2014-02-19 15:49:16 +08:00
|
|
|
# Make use of LLVM CMake modules.
|
2014-03-13 19:55:27 +08:00
|
|
|
file(TO_CMAKE_PATH ${LLVM_BINARY_DIR} LLVM_BINARY_DIR_CMAKE_STYLE)
|
2016-02-05 07:15:29 +08:00
|
|
|
set(LLVM_CMAKE_PATH "${LLVM_BINARY_DIR_CMAKE_STYLE}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
|
2014-02-19 15:49:16 +08:00
|
|
|
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}")
|
|
|
|
# Get some LLVM variables from LLVMConfig.
|
|
|
|
include("${LLVM_CMAKE_PATH}/LLVMConfig.cmake")
|
|
|
|
|
2014-12-29 20:26:30 +08:00
|
|
|
set(LLVM_LIBRARY_OUTPUT_INTDIR
|
|
|
|
${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX})
|
2014-02-19 18:04:29 +08:00
|
|
|
|
|
|
|
# Find Python interpreter.
|
|
|
|
set(Python_ADDITIONAL_VERSIONS 2.7 2.6 2.5)
|
|
|
|
include(FindPythonInterp)
|
|
|
|
if(NOT PYTHONINTERP_FOUND)
|
|
|
|
message(FATAL_ERROR "
|
|
|
|
Unable to find Python interpreter required testing. Please install Python
|
|
|
|
or specify the PYTHON_EXECUTABLE CMake variable.")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Define default arguments to lit.
|
|
|
|
set(LIT_ARGS_DEFAULT "-sv")
|
|
|
|
if (MSVC OR XCODE)
|
|
|
|
set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar")
|
|
|
|
endif()
|
|
|
|
set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" CACHE STRING "Default options for lit")
|
2014-02-19 15:49:16 +08:00
|
|
|
endif()
|
|
|
|
|
2016-06-28 06:52:03 +08:00
|
|
|
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)
|
2015-07-25 06:01:07 +08:00
|
|
|
# Determine if test target triple is specified explicitly, and doesn't match the
|
|
|
|
# default.
|
2015-09-09 06:48:35 +08:00
|
|
|
if(NOT COMPILER_RT_DEFAULT_TARGET_TRIPLE STREQUAL TARGET_TRIPLE)
|
|
|
|
set(COMPILER_RT_HAS_EXPLICIT_DEFAULT_TARGET_TRIPLE TRUE)
|
2015-07-25 06:01:07 +08:00
|
|
|
else()
|
2015-09-09 06:48:35 +08:00
|
|
|
set(COMPILER_RT_HAS_EXPLICIT_DEFAULT_TARGET_TRIPLE FALSE)
|
2015-07-25 06:01:07 +08:00
|
|
|
endif()
|
2016-06-28 06:52:05 +08:00
|
|
|
if ("${COMPILER_RT_DEFAULT_TARGET_ABI}" STREQUAL "androideabi")
|
|
|
|
set(ANDROID 1)
|
|
|
|
endif()
|
2014-02-18 15:26:58 +08:00
|
|
|
include(CompilerRTUtils)
|
2012-12-19 20:33:39 +08:00
|
|
|
|
|
|
|
set(COMPILER_RT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
2013-06-06 20:35:48 +08:00
|
|
|
set(COMPILER_RT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
2012-12-19 20:33:39 +08:00
|
|
|
|
2014-05-13 22:25:49 +08:00
|
|
|
# We support running instrumented tests when we're not cross compiling
|
|
|
|
# and target a UNIX-like system or Windows.
|
|
|
|
# We can run tests on Android even when we are cross-compiling.
|
2015-07-18 00:23:05 +08:00
|
|
|
if(("${CMAKE_HOST_SYSTEM}" STREQUAL "${CMAKE_SYSTEM}" AND (UNIX OR WIN32)) OR ANDROID
|
2014-05-14 08:36:15 +08:00
|
|
|
OR COMPILER_RT_EMULATOR)
|
2013-04-01 12:13:03 +08:00
|
|
|
option(COMPILER_RT_CAN_EXECUTE_TESTS "Can we execute instrumented tests" ON)
|
2012-12-27 21:19:23 +08:00
|
|
|
else()
|
2013-04-01 12:13:03 +08:00
|
|
|
option(COMPILER_RT_CAN_EXECUTE_TESTS "Can we execute instrumented tests" OFF)
|
2012-12-27 21:19:23 +08:00
|
|
|
endif()
|
2013-04-01 12:13:03 +08:00
|
|
|
|
2013-10-26 07:03:34 +08:00
|
|
|
option(COMPILER_RT_DEBUG "Build runtimes with full debug info" OFF)
|
2015-12-04 04:08:22 +08:00
|
|
|
option(COMPILER_RT_EXTERNALIZE_DEBUGINFO
|
|
|
|
"Generate dSYM files and strip executables and libraries (Darwin Only)" OFF)
|
2013-10-26 07:03:34 +08:00
|
|
|
# COMPILER_RT_DEBUG_PYBOOL is used by lit.common.configured.in.
|
|
|
|
pythonize_bool(COMPILER_RT_DEBUG)
|
|
|
|
|
2014-02-18 15:26:58 +08:00
|
|
|
#================================
|
|
|
|
# Setup Compiler Flags
|
|
|
|
#================================
|
2015-01-14 23:55:17 +08:00
|
|
|
|
2014-02-18 15:26:58 +08:00
|
|
|
include(config-ix)
|
|
|
|
|
2014-03-13 19:31:10 +08:00
|
|
|
if(MSVC)
|
2016-06-18 01:48:52 +08:00
|
|
|
# Override any existing /W flags with /W4. This is what LLVM does. Failing to
|
|
|
|
# remove other /W[0-4] flags will result in a warning about overriding a
|
|
|
|
# previous flag.
|
|
|
|
if (COMPILER_RT_HAS_W4_FLAG)
|
|
|
|
string(REGEX REPLACE " /W[0-4]" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
|
|
|
string(REGEX REPLACE " /W[0-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
|
|
|
append_string_if(COMPILER_RT_HAS_W4_FLAG /W4 CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
|
|
|
|
endif()
|
2014-03-13 19:31:10 +08:00
|
|
|
else()
|
|
|
|
append_string_if(COMPILER_RT_HAS_WALL_FLAG -Wall CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
|
|
|
|
endif()
|
2014-02-24 19:22:39 +08:00
|
|
|
if(COMPILER_RT_ENABLE_WERROR)
|
2014-03-13 19:31:10 +08:00
|
|
|
append_string_if(COMPILER_RT_HAS_WERROR_FLAG -Werror CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
|
|
|
|
append_string_if(COMPILER_RT_HAS_WX_FLAG /WX CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
|
2014-02-24 19:22:39 +08:00
|
|
|
endif()
|
|
|
|
|
2014-03-18 20:49:22 +08:00
|
|
|
append_string_if(COMPILER_RT_HAS_STD_CXX11_FLAG -std=c++11 CMAKE_CXX_FLAGS)
|
|
|
|
|
2014-02-27 05:54:39 +08:00
|
|
|
# Emulate C99 and C++11's __func__ for MSVC prior to 2013 CTP.
|
2014-02-27 14:52:41 +08:00
|
|
|
if(NOT COMPILER_RT_HAS_FUNC_SYMBOL)
|
2014-02-27 15:03:32 +08:00
|
|
|
add_definitions(-D__func__=__FUNCTION__)
|
2014-02-27 05:54:39 +08:00
|
|
|
endif()
|
|
|
|
|
2014-02-18 15:26:58 +08:00
|
|
|
# Provide some common commmandline flags for Sanitizer runtimes.
|
2014-10-16 06:47:54 +08:00
|
|
|
append_list_if(COMPILER_RT_HAS_FPIC_FLAG -fPIC SANITIZER_COMMON_CFLAGS)
|
|
|
|
append_list_if(COMPILER_RT_HAS_FNO_BUILTIN_FLAG -fno-builtin SANITIZER_COMMON_CFLAGS)
|
|
|
|
append_list_if(COMPILER_RT_HAS_FNO_EXCEPTIONS_FLAG -fno-exceptions SANITIZER_COMMON_CFLAGS)
|
2016-05-23 03:59:06 +08:00
|
|
|
if(NOT COMPILER_RT_DEBUG)
|
|
|
|
append_list_if(COMPILER_RT_HAS_FOMIT_FRAME_POINTER_FLAG -fomit-frame-pointer SANITIZER_COMMON_CFLAGS)
|
|
|
|
endif()
|
2014-10-16 06:47:54 +08:00
|
|
|
append_list_if(COMPILER_RT_HAS_FUNWIND_TABLES_FLAG -funwind-tables SANITIZER_COMMON_CFLAGS)
|
|
|
|
append_list_if(COMPILER_RT_HAS_FNO_STACK_PROTECTOR_FLAG -fno-stack-protector SANITIZER_COMMON_CFLAGS)
|
2015-06-16 05:08:47 +08:00
|
|
|
append_list_if(COMPILER_RT_HAS_FNO_SANITIZE_SAFE_STACK_FLAG -fno-sanitize=safe-stack SANITIZER_COMMON_CFLAGS)
|
2014-10-16 06:47:54 +08:00
|
|
|
append_list_if(COMPILER_RT_HAS_FVISIBILITY_HIDDEN_FLAG -fvisibility=hidden SANITIZER_COMMON_CFLAGS)
|
2015-12-01 03:16:42 +08:00
|
|
|
append_list_if(COMPILER_RT_HAS_FVISIBILITY_INLINES_HIDDEN_FLAG -fvisibility-inlines-hidden SANITIZER_COMMON_CFLAGS)
|
2014-10-16 06:47:54 +08:00
|
|
|
append_list_if(COMPILER_RT_HAS_FNO_FUNCTION_SECTIONS_FLAG -fno-function-sections SANITIZER_COMMON_CFLAGS)
|
2015-01-16 00:31:22 +08:00
|
|
|
append_list_if(COMPILER_RT_HAS_FNO_LTO_FLAG -fno-lto SANITIZER_COMMON_CFLAGS)
|
2014-02-18 15:26:58 +08:00
|
|
|
|
2014-02-28 16:04:30 +08:00
|
|
|
if(MSVC)
|
2015-07-09 06:10:34 +08:00
|
|
|
# Replace the /M[DT][d] flags with /MT, and strip any definitions of _DEBUG,
|
|
|
|
# which cause definition mismatches at link time.
|
2014-08-12 17:44:56 +08:00
|
|
|
# FIXME: In fact, sanitizers should support both /MT and /MD, see PR20214.
|
2014-02-28 16:04:30 +08:00
|
|
|
if(COMPILER_RT_HAS_MT_FLAG)
|
2014-10-24 04:24:00 +08:00
|
|
|
foreach(flag_var
|
2016-02-20 20:56:04 +08:00
|
|
|
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
|
|
|
|
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
|
2014-10-24 04:24:00 +08:00
|
|
|
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
|
|
|
|
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
|
2015-07-09 06:10:34 +08:00
|
|
|
string(REGEX REPLACE "/M[DT]d" "/MT" ${flag_var} "${${flag_var}}")
|
|
|
|
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
|
|
|
|
string(REGEX REPLACE "/D_DEBUG" "" ${flag_var} "${${flag_var}}")
|
2014-10-24 04:24:00 +08:00
|
|
|
endforeach()
|
2014-02-28 16:04:30 +08:00
|
|
|
endif()
|
2014-10-16 06:47:54 +08:00
|
|
|
append_list_if(COMPILER_RT_HAS_Oy_FLAG /Oy- SANITIZER_COMMON_CFLAGS)
|
|
|
|
append_list_if(COMPILER_RT_HAS_GS_FLAG /GS- SANITIZER_COMMON_CFLAGS)
|
2016-03-22 04:08:59 +08:00
|
|
|
# VS 2015 (version 1900) added support for thread safe static initialization.
|
|
|
|
# However, ASan interceptors run before CRT initialization, which causes the
|
|
|
|
# new thread safe code to crash. Disable this feature for now.
|
|
|
|
if (MSVC_VERSION GREATER 1899)
|
|
|
|
list(APPEND SANITIZER_COMMON_CFLAGS /Zc:threadSafeInit-)
|
|
|
|
endif()
|
2014-02-28 16:04:30 +08:00
|
|
|
endif()
|
2014-02-18 15:26:58 +08:00
|
|
|
|
2015-01-07 04:25:34 +08:00
|
|
|
append_list_if(COMPILER_RT_DEBUG -DSANITIZER_DEBUG=1 SANITIZER_COMMON_CFLAGS)
|
2015-01-03 12:29:12 +08:00
|
|
|
|
2014-03-13 21:37:07 +08:00
|
|
|
# Build with optimization, unless we're in debug mode. If we're using MSVC,
|
|
|
|
# always respect the optimization flags set by CMAKE_BUILD_TYPE instead.
|
|
|
|
if(NOT COMPILER_RT_DEBUG AND NOT MSVC)
|
|
|
|
list(APPEND SANITIZER_COMMON_CFLAGS -O3)
|
2012-11-08 22:49:28 +08:00
|
|
|
endif()
|
2014-02-18 15:26:58 +08:00
|
|
|
|
2015-01-03 12:29:12 +08:00
|
|
|
# Determine if we should restrict stack frame sizes.
|
2015-04-10 17:45:22 +08:00
|
|
|
# Stack frames on PowerPC and Mips and in debug biuld can be much larger than
|
2015-01-03 12:29:12 +08:00
|
|
|
# anticipated.
|
|
|
|
# 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
|
2015-09-09 07:13:47 +08:00
|
|
|
AND NOT ${COMPILER_RT_DEFAULT_TARGET_ARCH} MATCHES "powerpc|mips")
|
2015-01-03 12:29:12 +08:00
|
|
|
set(SANITIZER_LIMIT_FRAME_SIZE TRUE)
|
|
|
|
else()
|
|
|
|
set(SANITIZER_LIMIT_FRAME_SIZE FALSE)
|
|
|
|
endif()
|
|
|
|
|
2014-02-18 15:26:58 +08:00
|
|
|
# Build sanitizer runtimes with debug info.
|
2014-12-23 09:52:53 +08:00
|
|
|
if(COMPILER_RT_HAS_GLINE_TABLES_ONLY_FLAG AND NOT COMPILER_RT_DEBUG)
|
2014-02-18 15:26:58 +08:00
|
|
|
list(APPEND SANITIZER_COMMON_CFLAGS -gline-tables-only)
|
|
|
|
elseif(COMPILER_RT_HAS_G_FLAG)
|
|
|
|
list(APPEND SANITIZER_COMMON_CFLAGS -g)
|
|
|
|
elseif(COMPILER_RT_HAS_Zi_FLAG)
|
|
|
|
list(APPEND SANITIZER_COMMON_CFLAGS /Zi)
|
2013-03-25 18:31:49 +08:00
|
|
|
endif()
|
2014-02-18 15:26:58 +08:00
|
|
|
|
|
|
|
# Turn off several warnings.
|
2014-11-14 05:19:53 +08:00
|
|
|
append_list_if(COMPILER_RT_HAS_WGNU_FLAG -Wno-gnu SANITIZER_COMMON_CFLAGS)
|
|
|
|
append_list_if(COMPILER_RT_HAS_WVARIADIC_MACROS_FLAG -Wno-variadic-macros SANITIZER_COMMON_CFLAGS)
|
|
|
|
append_list_if(COMPILER_RT_HAS_WC99_EXTENSIONS_FLAG -Wno-c99-extensions SANITIZER_COMMON_CFLAGS)
|
|
|
|
append_list_if(COMPILER_RT_HAS_WNON_VIRTUAL_DTOR_FLAG -Wno-non-virtual-dtor SANITIZER_COMMON_CFLAGS)
|
2014-10-24 04:39:58 +08:00
|
|
|
append_list_if(COMPILER_RT_HAS_WD4146_FLAG /wd4146 SANITIZER_COMMON_CFLAGS)
|
|
|
|
append_list_if(COMPILER_RT_HAS_WD4291_FLAG /wd4291 SANITIZER_COMMON_CFLAGS)
|
2014-10-16 06:47:54 +08:00
|
|
|
append_list_if(COMPILER_RT_HAS_WD4391_FLAG /wd4391 SANITIZER_COMMON_CFLAGS)
|
|
|
|
append_list_if(COMPILER_RT_HAS_WD4722_FLAG /wd4722 SANITIZER_COMMON_CFLAGS)
|
2014-10-24 04:39:58 +08:00
|
|
|
append_list_if(COMPILER_RT_HAS_WD4800_FLAG /wd4800 SANITIZER_COMMON_CFLAGS)
|
2012-08-29 08:13:11 +08:00
|
|
|
|
2016-06-18 02:30:37 +08:00
|
|
|
# Warnings to turn off for all libraries, not just sanitizers.
|
|
|
|
append_string_if(COMPILER_RT_HAS_WUNUSED_PARAMETER_FLAG -Wno-unused-parameter CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
|
|
|
|
|
2015-06-25 08:57:42 +08:00
|
|
|
if(APPLE 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.
|
|
|
|
set(SANITIZER_CAN_USE_CXXABI FALSE)
|
2016-02-02 03:13:28 +08:00
|
|
|
elseif(MSVC)
|
|
|
|
set(SANITIZER_CAN_USE_CXXABI FALSE)
|
2015-06-25 08:57:42 +08:00
|
|
|
else()
|
|
|
|
set(SANITIZER_CAN_USE_CXXABI TRUE)
|
|
|
|
endif()
|
|
|
|
pythonize_bool(SANITIZER_CAN_USE_CXXABI)
|
|
|
|
|
2013-04-11 23:49:52 +08:00
|
|
|
add_subdirectory(include)
|
|
|
|
|
2015-08-12 01:22:06 +08:00
|
|
|
set(COMPILER_RT_LIBCXX_PATH ${LLVM_MAIN_SRC_DIR}/projects/libcxx)
|
2014-02-14 21:02:58 +08:00
|
|
|
if(EXISTS ${COMPILER_RT_LIBCXX_PATH}/)
|
|
|
|
set(COMPILER_RT_HAS_LIBCXX_SOURCES TRUE)
|
|
|
|
else()
|
|
|
|
set(COMPILER_RT_HAS_LIBCXX_SOURCES FALSE)
|
|
|
|
endif()
|
|
|
|
|
2015-08-12 02:43:13 +08:00
|
|
|
set(COMPILER_RT_LLD_PATH ${LLVM_MAIN_SRC_DIR}/tools/lld)
|
2015-08-11 08:33:07 +08:00
|
|
|
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)
|
|
|
|
|
2012-04-05 06:12:04 +08:00
|
|
|
add_subdirectory(lib)
|
|
|
|
|
2014-02-19 19:18:47 +08:00
|
|
|
if(COMPILER_RT_INCLUDE_TESTS)
|
2014-02-14 19:00:07 +08:00
|
|
|
add_subdirectory(unittests)
|
2015-09-15 03:54:12 +08:00
|
|
|
add_subdirectory(test)
|
2012-04-05 06:12:04 +08:00
|
|
|
endif()
|