[ASan] hoist more compile flags to SANITIZER_COMMON_CFLAGS var and add the rest of flags/defs from old Makefile to CMake
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@163204 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 17268c8..0820360 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -77,9 +77,12 @@
# Provide some common commmandline flags for Sanitizer runtimes.
set(SANITIZER_COMMON_CFLAGS
-fPIC
+ -fno-builtin
-fno-exceptions
+ -fomit-frame-pointer
-funwind-tables
-fvisibility=hidden
+ -O3
)
if(SUPPORTS_NO_VARIADIC_MACROS_FLAG)
list(APPEND SANITIZER_COMMON_CFLAGS -Wno-variadic-macros)
@@ -89,6 +92,9 @@
if(SUPPORTS_NO_C99_EXTENSIONS_FLAG)
list(APPEND SANITIZER_COMMON_CFLAGS -Wno-c99-extensions)
endif()
+if(APPLE)
+ list(APPEND SANITIZER_COMMON_CFLAGS -mmacosx-version-min=10.5)
+endif()
# Because compiler-rt spends a lot of time setting up custom compile flags,
# define a handy helper function for it. The compile flags setting in CMake
diff --git a/lib/asan/CMakeLists.txt b/lib/asan/CMakeLists.txt
index 8051e33..878eccd 100644
--- a/lib/asan/CMakeLists.txt
+++ b/lib/asan/CMakeLists.txt
@@ -28,11 +28,12 @@
include_directories(..)
-set(ASAN_CFLAGS
- ${SANITIZER_COMMON_CFLAGS}
- -fno-builtin
- -fomit-frame-pointer
- -O3
+set(ASAN_CFLAGS ${SANITIZER_COMMON_CFLAGS})
+
+set(ASAN_COMMON_DEFINITIONS
+ ASAN_HAS_EXCEPTIONS=1
+ ASAN_FLEXIBLE_MAPPING_AND_OFFSET=0
+ ASAN_NEEDS_SEGV=1
)
set(ASAN_DYLIB_DEFINITIONS
@@ -40,15 +41,6 @@
MAC_INTERPOSE_FUNCTIONS=1
)
-if (APPLE)
- list(APPEND ASAN_CFLAGS -mmacosx-version-min=10.5)
-endif()
-
-set(ASAN_COMMON_DEFINITIONS
- ASAN_HAS_EXCEPTIONS=1
- ASAN_NEEDS_SEGV=1
- )
-
set(ASAN_RUNTIME_LIBRARIES)
if(APPLE)
# Build universal binary on APPLE.
diff --git a/lib/asan/tests/CMakeLists.txt b/lib/asan/tests/CMakeLists.txt
index d6104d7..a998cd8 100644
--- a/lib/asan/tests/CMakeLists.txt
+++ b/lib/asan/tests/CMakeLists.txt
@@ -46,6 +46,11 @@
${ASAN_GTEST_INCLUDE_CFLAGS}
-faddress-sanitizer
-mllvm "-asan-blacklist=${CMAKE_CURRENT_SOURCE_DIR}/asan_test.ignore"
+ -mllvm -asan-stack=1
+ -mllvm -asan-globals=1
+ -mllvm -asan-mapping-scale=0 # default will be used
+ -mllvm -asan-mapping-offset-log=-1 # default will be used
+ -mllvm -asan-use-after-return=0
)
function(add_asan_test testsuite testname)
diff --git a/lib/interception/CMakeLists.txt b/lib/interception/CMakeLists.txt
index 27e0452..2c7619b 100644
--- a/lib/interception/CMakeLists.txt
+++ b/lib/interception/CMakeLists.txt
@@ -13,7 +13,7 @@
list(APPEND INTERCEPTION_SOURCES mach_override/mach_override.c)
endif ()
-set(INTERCEPTION_CFLAGS -O3 ${SANITIZER_COMMON_CFLAGS})
+set(INTERCEPTION_CFLAGS ${SANITIZER_COMMON_CFLAGS})
if(APPLE)
# Build universal binary on APPLE.
diff --git a/lib/sanitizer_common/CMakeLists.txt b/lib/sanitizer_common/CMakeLists.txt
index cb425a2..9d79882 100644
--- a/lib/sanitizer_common/CMakeLists.txt
+++ b/lib/sanitizer_common/CMakeLists.txt
@@ -18,7 +18,7 @@
sanitizer_win.cc
)
-set(SANITIZER_CFLAGS -O3 ${SANITIZER_COMMON_CFLAGS})
+set(SANITIZER_CFLAGS ${SANITIZER_COMMON_CFLAGS})
set(SANITIZER_COMMON_DEFINITIONS)