[compiler-rt] r201778 - [CMake] break dependency between unit tests and runtimes in standalone build
Alexey Samsonov
samsonov at google.com
Thu Feb 20 04:03:57 PST 2014
Author: samsonov
Date: Thu Feb 20 06:03:56 2014
New Revision: 201778
URL: http://llvm.org/viewvc/llvm-project?rev=201778&view=rev
Log:
[CMake] break dependency between unit tests and runtimes in standalone build
Modified:
compiler-rt/trunk/lib/asan/tests/CMakeLists.txt
compiler-rt/trunk/lib/msan/tests/CMakeLists.txt
compiler-rt/trunk/lib/sanitizer_common/tests/CMakeLists.txt
compiler-rt/trunk/lib/tsan/CMakeLists.txt
compiler-rt/trunk/lib/tsan/tests/CMakeLists.txt
Modified: compiler-rt/trunk/lib/asan/tests/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/CMakeLists.txt?rev=201778&r1=201777&r2=201778&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/tests/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/asan/tests/CMakeLists.txt Thu Feb 20 06:03:56 2014
@@ -83,11 +83,13 @@ macro(asan_compile obj_list source arch)
get_filename_component(basename ${source} NAME)
set(output_obj "${obj_list}.${basename}.${arch}.o")
get_target_flags_for_arch(${arch} TARGET_CFLAGS)
+ set(COMPILE_DEPS ${ASAN_UNITTEST_HEADERS} ${ASAN_BLACKLIST_FILE})
+ if(NOT COMPILER_RT_STANDALONE_BUILD)
+ list(APPEND COMPILE_DEPS gtest asan)
+ endif()
clang_compile(${output_obj} ${source}
CFLAGS ${ARGN} ${TARGET_CFLAGS}
- DEPS gtest asan
- ${ASAN_UNITTEST_HEADERS}
- ${ASAN_BLACKLIST_FILE})
+ DEPS ${COMPILE_DEPS})
list(APPEND ${obj_list} ${output_obj})
endmacro()
@@ -96,7 +98,10 @@ endmacro()
macro(add_asan_test test_suite test_name arch)
parse_arguments(TEST "OBJECTS;LINKFLAGS" "WITH_TEST_RUNTIME" ${ARGN})
get_target_flags_for_arch(${arch} TARGET_LINK_FLAGS)
- set(TEST_DEPS asan ${TEST_OBJECTS})
+ set(TEST_DEPS ${TEST_OBJECTS})
+ if(NOT COMPILER_RT_STANDALONE_BUILD)
+ list(APPEND TEST_DEPS asan)
+ endif()
if(TEST_WITH_TEST_RUNTIME)
list(APPEND TEST_DEPS ${ASAN_TEST_RUNTIME})
list(APPEND TEST_OBJECTS lib${ASAN_TEST_RUNTIME}.a)
Modified: compiler-rt/trunk/lib/msan/tests/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/tests/CMakeLists.txt?rev=201778&r1=201777&r2=201778&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/tests/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/msan/tests/CMakeLists.txt Thu Feb 20 06:03:56 2014
@@ -76,9 +76,13 @@ macro(msan_compile obj_list source arch)
get_filename_component(basename ${source} NAME)
set(output_obj "${basename}.${arch}.o")
get_target_flags_for_arch(${arch} TARGET_CFLAGS)
+ set(COMPILE_DEPS ${MSAN_UNITTEST_HEADERS})
+ if(NOT COMPILER_RT_STANDALONE_BUILD)
+ list(APPEND COMPILE_DEPS gtest msan)
+ endif()
clang_compile(${output_obj} ${source}
CFLAGS ${ARGN} ${TARGET_CFLAGS}
- DEPS gtest msan ${MSAN_UNITTEST_HEADERS})
+ DEPS ${COMPILE_DEPS})
list(APPEND ${obj_list} ${output_obj})
endmacro()
@@ -86,6 +90,9 @@ macro(msan_link_shared so_list so_name a
parse_arguments(SOURCE "OBJECTS;LINKFLAGS;DEPS" "" ${ARGN})
set(output_so "${CMAKE_CURRENT_BINARY_DIR}/${so_name}.${arch}.so")
get_target_flags_for_arch(${arch} TARGET_LINKFLAGS)
+ if(NOT COMPILER_RT_STANDALONE_BUILD)
+ list(APPEND SOURCE_DEPS msan)
+ endif()
clang_link_shared(${output_so}
OBJECTS ${SOURCE_OBJECTS}
LINKFLAGS ${TARGET_LINKFLAGS} ${SOURCE_LINKFLAGS}
@@ -97,10 +104,13 @@ endmacro()
# of objects in ${ARGN}.
macro(add_msan_test test_suite test_name arch)
get_target_flags_for_arch(${arch} TARGET_LINK_FLAGS)
+ set(TEST_DEPS ${ARGN} ${MSAN_LOADABLE_SO})
+ if(NOT COMPILER_RT_STANDALONE_BUILD)
+ list(APPEND TEST_DEPS msan)
+ endif()
add_compiler_rt_test(${test_suite} ${test_name}
OBJECTS ${ARGN}
- DEPS msan ${ARGN}
- ${MSAN_LOADABLE_SO}
+ DEPS ${TEST_DEPS}
LINK_FLAGS ${MSAN_UNITTEST_LINK_FLAGS}
${TARGET_LINK_FLAGS}
"-Wl,-rpath=${CMAKE_CURRENT_BINARY_DIR}")
@@ -128,7 +138,7 @@ macro(add_msan_tests_for_arch arch)
msan_link_shared(MSAN_INST_LIBCXX "libcxx" ${arch}
OBJECTS ${MSAN_INST_LIBCXX_OBJECTS}
LINKFLAGS ${MSAN_LIBCXX_LINK_FLAGS}
- DEPS ${MSAN_INST_LIBCXX_OBJECTS} msan)
+ DEPS ${MSAN_INST_LIBCXX_OBJECTS})
# Instrumented tests.
set(MSAN_INST_TEST_OBJECTS)
@@ -151,13 +161,13 @@ macro(add_msan_tests_for_arch arch)
set(MSAN_LOADABLE_SO)
msan_link_shared(MSAN_LOADABLE_SO "libmsan_loadable" ${arch}
OBJECTS ${MSAN_INST_LOADABLE_OBJECTS}
- DEPS ${MSAN_INST_LOADABLE_OBJECTS} msan)
+ DEPS ${MSAN_INST_LOADABLE_OBJECTS})
# Uninstrumented shared library tests.
set(MSANDR_TEST_SO)
msan_link_shared(MSANDR_TEST_SO "libmsandr_test" ${arch}
OBJECTS ${MSANDR_TEST_OBJECTS}
- DEPS ${MSANDR_TEST_OBJECTS} msan)
+ DEPS ${MSANDR_TEST_OBJECTS})
# Link everything together.
add_msan_test(MsanUnitTests "Msan-${arch}-Test" ${arch}
Modified: compiler-rt/trunk/lib/sanitizer_common/tests/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/tests/CMakeLists.txt?rev=201778&r1=201777&r2=201778&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/tests/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/sanitizer_common/tests/CMakeLists.txt Thu Feb 20 06:03:56 2014
@@ -74,14 +74,17 @@ macro(add_sanitizer_tests_for_arch arch)
get_target_flags_for_arch(${arch} TARGET_FLAGS)
set(SANITIZER_TEST_SOURCES ${SANITIZER_UNITTESTS}
${COMPILER_RT_GTEST_SOURCE})
+ set(SANITIZER_TEST_COMPILE_DEPS ${SANITIZER_TEST_HEADERS})
+ if(NOT COMPILER_RT_STANDALONE_BUILD)
+ list(APPEND SANITIZER_TEST_COMPILE_DEPS gtest)
+ endif()
set(SANITIZER_TEST_OBJECTS)
foreach(source ${SANITIZER_TEST_SOURCES})
get_filename_component(basename ${source} NAME)
set(output_obj "${basename}.${arch}.o")
clang_compile(${output_obj} ${source}
CFLAGS ${SANITIZER_TEST_CFLAGS_COMMON} ${TARGET_FLAGS}
- DEPS gtest ${SANITIZER_RUNTIME_LIBRARIES}
- ${SANITIZER_TEST_HEADERS})
+ DEPS ${SANITIZER_TEST_COMPILE_DEPS})
list(APPEND SANITIZER_TEST_OBJECTS ${output_obj})
endforeach()
get_sanitizer_common_lib_for_arch(${arch} SANITIZER_COMMON_LIB
@@ -102,7 +105,7 @@ macro(add_sanitizer_tests_for_arch arch)
clang_compile(sanitizer_nolibc_test_main.${arch}.o
sanitizer_nolibc_test_main.cc
CFLAGS ${SANITIZER_TEST_CFLAGS_COMMON} ${TARGET_FLAGS}
- DEPS ${SANITIZER_RUNTIME_LIBRARIES} ${SANITIZER_TEST_HEADERS})
+ DEPS ${SANITIZER_TEST_COMPILE_DEPS})
add_compiler_rt_test(SanitizerUnitTests "Sanitizer-${arch}-Test-Nolibc"
OBJECTS sanitizer_nolibc_test_main.${arch}.o
-Wl,-whole-archive
Modified: compiler-rt/trunk/lib/tsan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/CMakeLists.txt?rev=201778&r1=201777&r2=201778&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/tsan/CMakeLists.txt Thu Feb 20 06:03:56 2014
@@ -51,6 +51,30 @@ elseif(UNIX)
rtl/tsan_platform_linux.cc)
endif()
+set(TSAN_HEADERS
+ rtl/tsan_clock.h
+ rtl/tsan_defs.h
+ rtl/tsan_fd.h
+ rtl/tsan_flags.h
+ rtl/tsan_ignoreset.h
+ rtl/tsan_interface_ann.h
+ rtl/tsan_interface.h
+ rtl/tsan_interface_inl.h
+ rtl/tsan_interface_java.h
+ rtl/tsan_mman.h
+ rtl/tsan_mutex.h
+ rtl/tsan_mutexset.h
+ rtl/tsan_platform.h
+ rtl/tsan_report.h
+ rtl/tsan_rtl.h
+ rtl/tsan_stat.h
+ rtl/tsan_suppressions.h
+ rtl/tsan_symbolize.h
+ rtl/tsan_sync.h
+ rtl/tsan_trace.h
+ rtl/tsan_update_shadow_word_inl.h
+ rtl/tsan_vector.h)
+
add_custom_target(tsan)
# TSan is currently supported on 64-bit Linux only.
if(CAN_TARGET_x86_64 AND UNIX AND NOT APPLE)
Modified: compiler-rt/trunk/lib/tsan/tests/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/tests/CMakeLists.txt?rev=201778&r1=201777&r2=201778&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/tests/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/tsan/tests/CMakeLists.txt Thu Feb 20 06:03:56 2014
@@ -11,14 +11,23 @@ set(TSAN_UNITTEST_CFLAGS
-I${COMPILER_RT_SOURCE_DIR}/lib/tsan/rtl
-DGTEST_HAS_RTTI=0)
+set(TSAN_RTL_HEADERS)
+foreach (header ${TSAN_HEADERS})
+ list(APPEND TSAN_RTL_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/../${header})
+endforeach()
+
# tsan_compile(obj_list, source, arch, {headers})
macro(tsan_compile obj_list source arch)
get_filename_component(basename ${source} NAME)
set(output_obj "${basename}.${arch}.o")
get_target_flags_for_arch(${arch} TARGET_CFLAGS)
+ set(COMPILE_DEPS ${TSAN_RTL_HEADERS} ${ARGN})
+ if(NOT COMPILER_RT_STANDALONE_BUILD)
+ list(APPEND COMPILE_DEPS gtest tsan)
+ endif()
clang_compile(${output_obj} ${source}
CFLAGS ${TSAN_UNITTEST_CFLAGS} ${TARGET_CFLAGS}
- DEPS gtest tsan ${ARGN})
+ DEPS ${COMPILE_DEPS})
list(APPEND ${obj_list} ${output_obj})
endmacro()
@@ -31,9 +40,16 @@ macro(add_tsan_unittest testname)
tsan_compile(TEST_OBJECTS ${SOURCE} x86_64 ${TEST_HEADERS})
endforeach()
get_target_flags_for_arch(${arch} TARGET_LINK_FLAGS)
+ set(TEST_DEPS ${TEST_OBJECTS})
+ if(NOT COMPILER_RT_STANDALONE_BUILD)
+ list(APPEND TEST_DEPS tsan)
+ endif()
+ # FIXME: Looks like we should link TSan with just-built runtime,
+ # and not rely on -fsanitize=thread, as these tests are essentially
+ # unit tests.
add_compiler_rt_test(TsanUnitTests ${testname}
OBJECTS ${TEST_OBJECTS}
- DEPS tsan ${TEST_OBJECTS}
+ DEPS ${TEST_DEPS}
LINK_FLAGS ${TARGET_LINK_FLAGS}
-fsanitize=thread
-lstdc++ -lm)
More information about the llvm-commits
mailing list