summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2014-02-18 08:07:09 +0000
committerAlexey Samsonov <samsonov@google.com>2014-02-18 08:07:09 +0000
commit62c2164db4cd9586fd35949f961240c1277b55ee (patch)
tree8c97d7794d81cca74954a3a90c9a69d3b1fa921c /lib
parente5a1ffffd0d17487caba21a0176fe9f7042a7feb (diff)
[CMake] Check for -fPIE and -ffreestanding flags for consistency
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@201549 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/dfsan/CMakeLists.txt14
-rw-r--r--lib/msan/CMakeLists.txt9
-rw-r--r--lib/tsan/CMakeLists.txt5
3 files changed, 14 insertions, 14 deletions
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})