forked from OSchip/llvm-project
[CMake] Respect CMAKE_CXX_FLAGS in custom clang_compile commands
llvm-svn: 204593
This commit is contained in:
parent
8c956460d3
commit
1847401332
|
@ -11,9 +11,19 @@ macro(clang_compile object_file source)
|
|||
if(NOT COMPILER_RT_STANDALONE_BUILD)
|
||||
list(APPEND SOURCE_DEPS clang)
|
||||
endif()
|
||||
string(REGEX MATCH "[.](cc|cpp)$" is_cxx ${source_rpath})
|
||||
if(is_cxx)
|
||||
string(REPLACE " " ";" global_flags "${CMAKE_CXX_FLAGS}")
|
||||
else()
|
||||
string(REPLACE " " ";" global_flags "${CMAKE_C_FLAGS}")
|
||||
endif()
|
||||
# Ignore unknown warnings. CMAKE_CXX_FLAGS may contain GCC-specific options
|
||||
# which are not supported by Clang.
|
||||
list(APPEND global_flags -Wno-unknown-warning-option)
|
||||
set(compile_flags ${global_flags} ${SOURCE_CFLAGS})
|
||||
add_custom_command(
|
||||
OUTPUT ${object_file}
|
||||
COMMAND ${COMPILER_RT_TEST_COMPILER} ${SOURCE_CFLAGS} -c -o "${object_file}"
|
||||
COMMAND ${COMPILER_RT_TEST_COMPILER} ${compile_flags} -c -o "${object_file}"
|
||||
${source_rpath}
|
||||
MAIN_DEPENDENCY ${source}
|
||||
DEPENDS ${SOURCE_DEPS})
|
||||
|
|
|
@ -26,9 +26,7 @@ set(ASAN_UNITTEST_COMMON_CFLAGS
|
|||
-I${COMPILER_RT_SOURCE_DIR}/lib
|
||||
-I${COMPILER_RT_SOURCE_DIR}/lib/asan
|
||||
-I${COMPILER_RT_SOURCE_DIR}/lib/sanitizer_common/tests
|
||||
-Wall
|
||||
-Wno-format
|
||||
-Werror
|
||||
-Werror=sign-compare
|
||||
-g
|
||||
-O2)
|
||||
|
@ -146,7 +144,7 @@ macro(add_asan_tests_for_arch arch)
|
|||
set(ASAN_INST_TEST_OBJECTS)
|
||||
foreach(src ${ASAN_INST_TEST_SOURCES})
|
||||
asan_compile(ASAN_INST_TEST_OBJECTS ${src} ${arch}
|
||||
${ASAN_UNITTEST_INSTRUMENTED_CFLAGS} -std=c++11)
|
||||
${ASAN_UNITTEST_INSTRUMENTED_CFLAGS})
|
||||
endforeach()
|
||||
if (APPLE)
|
||||
# Add Mac-specific helper.
|
||||
|
@ -180,7 +178,7 @@ macro(add_asan_tests_for_arch arch)
|
|||
set(ASAN_NOINST_TEST_OBJECTS)
|
||||
foreach(src ${ASAN_NOINST_TEST_SOURCES})
|
||||
asan_compile(ASAN_NOINST_TEST_OBJECTS ${src} ${arch}
|
||||
${ASAN_UNITTEST_COMMON_CFLAGS} -std=c++11)
|
||||
${ASAN_UNITTEST_COMMON_CFLAGS})
|
||||
endforeach()
|
||||
add_asan_test(AsanUnitTests "Asan-${arch}-Noinst-Test" ${arch}
|
||||
OBJECTS ${ASAN_NOINST_TEST_OBJECTS}
|
||||
|
@ -191,7 +189,7 @@ macro(add_asan_tests_for_arch arch)
|
|||
set(ASAN_BENCHMARKS_OBJECTS)
|
||||
foreach(src ${ASAN_BENCHMARKS_SOURCES})
|
||||
asan_compile(ASAN_BENCHMARKS_OBJECTS ${src} ${arch}
|
||||
${ASAN_UNITTEST_INSTRUMENTED_CFLAGS} -std=c++11)
|
||||
${ASAN_UNITTEST_INSTRUMENTED_CFLAGS})
|
||||
endforeach()
|
||||
add_asan_test(AsanBenchmarks "Asan-${arch}-Benchmark" ${arch}
|
||||
OBJECTS ${ASAN_BENCHMARKS_OBJECTS}
|
||||
|
|
|
@ -13,9 +13,9 @@ set(MSAN_LIBCXX_CFLAGS
|
|||
-fsanitize-memory-track-origins
|
||||
-fPIC
|
||||
-Wno-\#warnings
|
||||
-Wno-pedantic
|
||||
-g
|
||||
-O2
|
||||
-std=c++0x
|
||||
-fstrict-aliasing
|
||||
-fno-exceptions
|
||||
-nostdinc++
|
||||
|
@ -44,7 +44,6 @@ set(MSAN_UNITTEST_COMMON_CFLAGS
|
|||
-I${COMPILER_RT_SOURCE_DIR}/include
|
||||
-I${COMPILER_RT_SOURCE_DIR}/lib
|
||||
-I${COMPILER_RT_SOURCE_DIR}/lib/msan
|
||||
-std=c++11
|
||||
-stdlib=libc++
|
||||
-g
|
||||
-O2
|
||||
|
@ -52,6 +51,9 @@ set(MSAN_UNITTEST_COMMON_CFLAGS
|
|||
-fno-omit-frame-pointer
|
||||
-mno-omit-leaf-frame-pointer
|
||||
-Wno-deprecated-declarations
|
||||
-Wno-unused-variable
|
||||
-Wno-zero-length-array
|
||||
-Werror=sign-compare
|
||||
)
|
||||
set(MSAN_UNITTEST_INSTRUMENTED_CFLAGS
|
||||
${MSAN_UNITTEST_COMMON_CFLAGS}
|
||||
|
|
|
@ -37,8 +37,9 @@ set(SANITIZER_TEST_CFLAGS_COMMON
|
|||
-I${COMPILER_RT_SOURCE_DIR}/lib
|
||||
-I${COMPILER_RT_SOURCE_DIR}/lib/sanitizer_common
|
||||
-DGTEST_HAS_RTTI=0
|
||||
-std=c++11 -O2 -g -fno-rtti
|
||||
-Wall -Werror -Werror=sign-compare)
|
||||
-O2 -g -fno-rtti
|
||||
-Werror=sign-compare
|
||||
-Wno-non-virtual-dtor)
|
||||
|
||||
set(SANITIZER_TEST_LINK_FLAGS_COMMON
|
||||
-lstdc++)
|
||||
|
|
|
@ -9,7 +9,6 @@ set(TSAN_UNITTEST_CFLAGS
|
|||
${COMPILER_RT_GTEST_INCLUDE_CFLAGS}
|
||||
-I${COMPILER_RT_SOURCE_DIR}/lib
|
||||
-I${COMPILER_RT_SOURCE_DIR}/lib/tsan/rtl
|
||||
-std=c++11
|
||||
-DGTEST_HAS_RTTI=0)
|
||||
|
||||
set(TSAN_RTL_HEADERS)
|
||||
|
|
Loading…
Reference in New Issue