summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmake/config-ix.cmake2
-rw-r--r--lib/dfsan/CMakeLists.txt14
-rw-r--r--lib/msan/CMakeLists.txt9
-rw-r--r--lib/tsan/CMakeLists.txt5
4 files changed, 16 insertions, 14 deletions
diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake
index 1b81a9550..2af4ea3a6 100644
--- a/cmake/config-ix.cmake
+++ b/cmake/config-ix.cmake
@@ -2,6 +2,7 @@ include(CheckCXXCompilerFlag)
# CodeGen options.
check_cxx_compiler_flag(-fPIC COMPILER_RT_HAS_FPIC_FLAG)
+check_cxx_compiler_flag(-fPIE COMPILER_RT_HAS_FPIE_FLAG)
check_cxx_compiler_flag(-fno-builtin COMPILER_RT_HAS_FNO_BUILTIN_FLAG)
check_cxx_compiler_flag(-fno-exceptions COMPILER_RT_HAS_FNO_EXCEPTIONS_FLAG)
check_cxx_compiler_flag(-fomit-frame-pointer COMPILER_RT_HAS_FOMIT_FRAME_POINTER_FLAG)
@@ -9,6 +10,7 @@ check_cxx_compiler_flag(-funwind-tables COMPILER_RT_HAS_FUNWIND_TABLES_FLAG
check_cxx_compiler_flag(-fno-stack-protector COMPILER_RT_HAS_FNO_STACK_PROTECTOR_FLAG)
check_cxx_compiler_flag(-fvisibility=hidden COMPILER_RT_HAS_FVISIBILITY_HIDDEN_FLAG)
check_cxx_compiler_flag(-fno-rtti COMPILER_RT_HAS_FNO_RTTI_FLAG)
+check_cxx_compiler_flag(-ffreestanding COMPILER_RT_HAS_FFREESTANDING_FLAG)
check_cxx_compiler_flag("-Werror -fno-function-sections" COMPILER_RT_HAS_FNO_FUNCTION_SECTIONS_FLAG)
check_cxx_compiler_flag(/GR COMPILER_RT_HAS_GR_FLAG)
diff --git a/lib/dfsan/CMakeLists.txt b/lib/dfsan/CMakeLists.txt
index 8de7498ec..3fa6189eb 100644
--- a/lib/dfsan/CMakeLists.txt
+++ b/lib/dfsan/CMakeLists.txt
@@ -5,25 +5,27 @@ set(DFSAN_RTL_SOURCES
dfsan.cc
dfsan_custom.cc
dfsan_interceptors.cc)
-set(DFSAN_RTL_CFLAGS
- ${SANITIZER_COMMON_CFLAGS}
- # Prevent clang from generating libc calls.
- -ffreestanding)
+set(DFSAN_COMMON_CFLAGS ${SANITIZER_COMMON_CFLAGS})
+# Prevent clang from generating libc calls.
+append_if(DFSAN_COMMON_CFLAGS COMPILER_RT_HAS_FFREESTANDING_FLAG -ffreestanding)
# Static runtime library.
add_custom_target(dfsan)
set(arch "x86_64")
if(CAN_TARGET_${arch})
+ set(DFSAN_CFLAGS ${DFSAN_COMMON_CFLAGS})
+ append_if(DFSAN_CFLAGS COMPILER_RT_HAS_FPIE_FLAG -fPIE)
add_compiler_rt_static_runtime(clang_rt.dfsan-${arch} ${arch}
SOURCES ${DFSAN_RTL_SOURCES}
$<TARGET_OBJECTS:RTInterception.${arch}>
$<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
$<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}>
- CFLAGS ${DFSAN_RTL_CFLAGS} -fPIE)
+ CFLAGS ${DFSAN_CFLAGS})
+ set(DFSAN_NOLIBC_CFLAGS ${DFSAN_COMMON_CFLAGS} -DDFSAN_NOLIBC)
add_compiler_rt_static_runtime(clang_rt.dfsan-libc-${arch} ${arch}
SOURCES ${DFSAN_RTL_SOURCES}
$<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
- CFLAGS ${DFSAN_RTL_CFLAGS} -fPIC -DDFSAN_NOLIBC)
+ CFLAGS ${DFSAN_NOLIBC_CFLAGS})
add_sanitizer_rt_symbols(clang_rt.dfsan-${arch} dfsan.syms.extra)
add_dependencies(dfsan
clang_rt.dfsan-${arch}
diff --git a/lib/msan/CMakeLists.txt b/lib/msan/CMakeLists.txt
index 2c822741c..2578b689c 100644
--- a/lib/msan/CMakeLists.txt
+++ b/lib/msan/CMakeLists.txt
@@ -10,12 +10,11 @@ set(MSAN_RTL_SOURCES
msan_report.cc
)
-set(MSAN_RTL_CFLAGS
- ${SANITIZER_COMMON_CFLAGS}
- -fPIE
- # Prevent clang from generating libc calls.
- -ffreestanding)
+set(MSAN_RTL_CFLAGS ${SANITIZER_COMMON_CFLAGS})
append_no_rtti_flag(MSAN_RTL_CFLAGS)
+append_if(MSAN_RTL_CFLAGS COMPILER_RT_HAS_FPIE_FLAG -fPIE)
+# Prevent clang from generating libc calls.
+append_if(MSAN_RTL_CFLAGS COMPILER_RT_HAS_FFREESTANDING_FLAG -ffreestanding)
# Static runtime library.
add_custom_target(msan)
diff --git a/lib/tsan/CMakeLists.txt b/lib/tsan/CMakeLists.txt
index 37233bb40..64ae0d477 100644
--- a/lib/tsan/CMakeLists.txt
+++ b/lib/tsan/CMakeLists.txt
@@ -2,11 +2,10 @@
include_directories(..)
+set(TSAN_CFLAGS ${SANITIZER_COMMON_CFLAGS})
# SANITIZER_COMMON_CFLAGS contains -fPIC, but it's performance-critical for
# TSan runtime to be built with -fPIE to reduce the number of register spills.
-set(TSAN_CFLAGS
- ${SANITIZER_COMMON_CFLAGS}
- -fPIE)
+append_if(TSAN_CFLAGS COMPILER_RT_HAS_FPIE_FLAG -fPIE)
append_no_rtti_flag(TSAN_CFLAGS)
set(TSAN_RTL_CFLAGS ${TSAN_CFLAGS})