[compiler-rt] r309405 - [sanitizer tests CMake] Factor out CMake logic for compiling sanitizer tests
Kostya Serebryany via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 28 13:12:12 PDT 2017
Actually, yes, this reproduces on my box exactly the way it fails on the
bot:
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLLVM_ENABLE_ASSERTIONS=ON
-DLLVM_PARALLEL_LINK_JOBS=10 -DLLVM_APPEND_VC_REV=OFF
-DLLVM_BINUTILS_INCDIR=/usr/include ~/llvm
-- Builtin supported architectures: i386;i686;x86_64
CMake Error at projects/compiler-rt/lib/msan/tests/CMakeLists.txt:88
(msan_compile):
msan_compile Macro invoked with incorrect arguments for macro named:
msan_compile
Call Stack (most recent call first):
projects/compiler-rt/lib/msan/tests/CMakeLists.txt:134
(add_msan_tests_for_arch)
On Fri, Jul 28, 2017 at 1:07 PM, Kostya Serebryany <kcc at google.com> wrote:
> Let me clobber the bot first...
>
> On Fri, Jul 28, 2017 at 1:05 PM, George Karpenkov <ekarpenkov at apple.com>
> wrote:
>
>> Kostya, can you reproduce on your machine? I’ve copied the command
>> exactly from buildbot on a fresh checkout, and still could not reproduce.
>> Also just by looking at the source code the number of arguments is
>> clearly matching.
>>
>> On Jul 28, 2017, at 12:53 PM, George Karpenkov via llvm-commits <
>> llvm-commits at lists.llvm.org> wrote:
>>
>> Looking into this, for now can’t reproduce on my linux machine.
>>
>> On Jul 28, 2017, at 12:28 PM, Kostya Serebryany <kcc at google.com> wrote:
>>
>> Looks like this made the sanitizer bot sad:
>> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/3107
>>
>> -- Builtin supported architectures: i386;i686;x86_64
>> CMake Error at projects/compiler-rt/lib/msan/tests/CMakeLists.txt:88 (msan_compile):
>> msan_compile Macro invoked with incorrect arguments for macro named:
>> msan_compile
>> Call Stack (most recent call first):
>> projects/compiler-rt/lib/msan/tests/CMakeLists.txt:134 (add_msan_tests_for_arch)
>>
>>
>> -- Linker detection: GNU Gold
>> -- Linker detection: GNU Gold
>>
>>
>> On Fri, Jul 28, 2017 at 10:32 AM, George Karpenkov via llvm-commits <
>> llvm-commits at lists.llvm.org> wrote:
>>
>>> Author: george.karpenkov
>>> Date: Fri Jul 28 10:32:37 2017
>>> New Revision: 309405
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=309405&view=rev
>>> Log:
>>> [sanitizer tests CMake] Factor out CMake logic for compiling sanitizer
>>> tests
>>>
>>> Currently there's a large amount of CMake logic duplication for
>>> compiling sanitizer tests.
>>> If we add more sanitizers, the duplication will get even worse.
>>>
>>> This change factors out common compilation commands into a macro
>>> available to all sanitizers.
>>>
>>> Modified:
>>> compiler-rt/trunk/cmake/Modules/CompilerRTCompile.cmake
>>> compiler-rt/trunk/lib/asan/tests/CMakeLists.txt
>>> compiler-rt/trunk/lib/msan/tests/CMakeLists.txt
>>> compiler-rt/trunk/lib/tsan/tests/CMakeLists.txt
>>> compiler-rt/trunk/lib/xray/tests/CMakeLists.txt
>>>
>>> Modified: compiler-rt/trunk/cmake/Modules/CompilerRTCompile.cmake
>>> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/cmake/
>>> Modules/CompilerRTCompile.cmake?rev=309405&r1=309404&r2=309405&view=diff
>>> ============================================================
>>> ==================
>>> --- compiler-rt/trunk/cmake/Modules/CompilerRTCompile.cmake (original)
>>> +++ compiler-rt/trunk/cmake/Modules/CompilerRTCompile.cmake Fri Jul 28
>>> 10:32:37 2017
>>> @@ -24,6 +24,41 @@ function(translate_msvc_cflags out_flags
>>> set(${out_flags} "${clang_flags}" PARENT_SCOPE)
>>> endfunction()
>>>
>>> +# Compile a sanitizer test with a freshly built clang
>>> +# for a given architecture, adding the result to the object list.
>>> +# - obj_list: output list of objects, populated by path
>>> +# of the generated object file.
>>> +# - source: source file of a test.
>>> +# - arch: architecture to compile for.
>>> +# sanitizer_test_compile(<obj_list> <source> <arch>
>>> +# KIND <custom namespace>
>>> +# COMPILE_DEPS <list of compile-time
>>> dependencies>
>>> +# DEPS <list of dependencies>
>>> +# CFLAGS <list of flags>
>>> +# )
>>> +macro(sanitizer_test_compile obj_list source arch)
>>> + cmake_parse_arguments(TEST
>>> + "" "" "KIND;COMPILE_DEPS;DEPS;CFLAGS" ${ARGN})
>>> + get_filename_component(basename ${source} NAME)
>>> + if(CMAKE_CONFIGURATION_TYPES)
>>> + set(output_obj
>>> + "${CMAKE_CFG_INTDIR}/${obj_list}.${basename}.${arch}${TEST_K
>>> IND}.o")
>>> + else()
>>> + set(output_obj "${obj_list}.${basename}.${arch}${TEST_KIND}.o")
>>> + endif()
>>> +
>>> + # Write out architecture-specific flags into TARGET_CFLAGS variable.
>>> + get_target_flags_for_arch(${arch} TARGET_CFLAGS)
>>> + set(COMPILE_DEPS ${TEST_COMPILE_DEPS})
>>> + if(NOT COMPILER_RT_STANDALONE_BUILD)
>>> + list(APPEND COMPILE_DEPS ${TEST_DEPS})
>>> + endif()
>>> + clang_compile(${output_obj} ${source}
>>> + CFLAGS ${TEST_CFLAGS} ${TARGET_CFLAGS}
>>> + DEPS ${TEST_COMPILE_DEPS})
>>> + list(APPEND ${obj_list} ${output_obj})
>>> +endmacro()
>>> +
>>> # Compile a source into an object file with COMPILER_RT_TEST_COMPILER
>>> using
>>> # a provided compile flags and dependenices.
>>> # clang_compile(<object> <source>
>>>
>>> Modified: compiler-rt/trunk/lib/asan/tests/CMakeLists.txt
>>> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/as
>>> an/tests/CMakeLists.txt?rev=309405&r1=309404&r2=309405&view=diff
>>> ============================================================
>>> ==================
>>> --- compiler-rt/trunk/lib/asan/tests/CMakeLists.txt (original)
>>> +++ compiler-rt/trunk/lib/asan/tests/CMakeLists.txt Fri Jul 28 10:32:37
>>> 2017
>>> @@ -125,20 +125,14 @@ append_list_if(COMPILER_RT_HAS_LIBLOG lo
>>> # NDK r10 requires -latomic almost always.
>>> append_list_if(ANDROID atomic ASAN_UNITTEST_NOINST_LIBS)
>>>
>>> -# Compile source for the given architecture, using compiler
>>> -# options in ${ARGN}, and add it to the object list.
>>> macro(asan_compile obj_list source arch kind)
>>> - get_filename_component(basename ${source} NAME)
>>> - set(output_obj "${CMAKE_CFG_RESOLVED_INTDIR}$
>>> {obj_list}.${basename}.${arch}${kind}.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 ${COMPILE_DEPS})
>>> - list(APPEND ${obj_list} ${output_obj})
>>> + cmake_parse_arguments(ASAN_TEST "" "" "CFLAGS" ${ARGN})
>>> + sanitizer_test_compile(${obj_list} ${source} ${arch}
>>> + KIND ${kind}
>>> + COMPILE_DEPS ${ASAN_UNITTEST_HEADERS} ${ASAN_BLACKLIST_FILE}
>>> + DEPS gtest asan
>>> + CFLAGS ${ASAN_TEST_CFLAGS}
>>> + )
>>> endmacro()
>>>
>>> # Link ASan unit test for a given architecture from a set
>>> @@ -200,17 +194,17 @@ set(ASAN_BENCHMARKS_SOURCES
>>> asan_benchmarks_test.cc)
>>>
>>> # Adds ASan unit tests and benchmarks for architecture.
>>> -macro(add_asan_tests_for_arch_and_kind arch kind)
>>> +macro(add_asan_tests_for_arch_and_kind arch kind cflags)
>>> # Instrumented tests.
>>> set(ASAN_INST_TEST_OBJECTS)
>>> foreach(src ${ASAN_INST_TEST_SOURCES})
>>> asan_compile(ASAN_INST_TEST_OBJECTS ${src} ${arch} ${kind}
>>> - ${ASAN_UNITTEST_INSTRUMENTED_CFLAGS} ${ARGN})
>>> + CFLAGS ${ASAN_UNITTEST_INSTRUMENTED_CFLAGS} ${cflags})
>>> endforeach()
>>> if (APPLE)
>>> # Add Mac-specific helper.
>>> asan_compile(ASAN_INST_TEST_OBJECTS asan_mac_test_helpers.mm
>>> ${arch} ${kind}
>>> - ${ASAN_UNITTEST_INSTRUMENTED_CFLAGS} -ObjC ${ARGN})
>>> + CFLAGS ${ASAN_UNITTEST_INSTRUMENTED_CFLAGS} -ObjC
>>> ${cflags})
>>> endif()
>>>
>>> if (MSVC)
>>> @@ -219,7 +213,7 @@ macro(add_asan_tests_for_arch_and_kind a
>>> set(ASAN_INST_DYNAMIC_TEST_OBJECTS)
>>> foreach(src ${ASAN_INST_TEST_SOURCES})
>>> asan_compile(ASAN_INST_DYNAMIC_TEST_OBJECTS ${src} ${arch}
>>> ${kind}
>>> - ${ASAN_UNITTEST_INSTRUMENTED_CFLAGS} -D_MT -D_DLL ${ARGN})
>>> + CFLAGS ${ASAN_UNITTEST_INSTRUMENTED_CFLAGS} -D_MT -D_DLL
>>> ${cflags})
>>> endforeach()
>>> # Clang links the static CRT by default. Override that to use the
>>> dynamic
>>> # CRT.
>>> @@ -276,7 +270,7 @@ macro(add_asan_tests_for_arch_and_kind a
>>> set(ASAN_NOINST_TEST_OBJECTS)
>>> foreach(src ${ASAN_NOINST_TEST_SOURCES})
>>> asan_compile(ASAN_NOINST_TEST_OBJECTS ${src} ${arch} ${kind}
>>> - ${ASAN_UNITTEST_COMMON_CFLAGS} ${ARGN})
>>> + CFLAGS ${ASAN_UNITTEST_COMMON_CFLAGS} ${cflags})
>>> endforeach()
>>> add_asan_test(AsanUnitTests "Asan-${arch}${kind}-Noinst-Test"
>>> ${arch} ${kind} SUBDIR "default"
>>> @@ -288,7 +282,7 @@ macro(add_asan_tests_for_arch_and_kind a
>>> set(ASAN_BENCHMARKS_OBJECTS)
>>> foreach(src ${ASAN_BENCHMARKS_SOURCES})
>>> asan_compile(ASAN_BENCHMARKS_OBJECTS ${src} ${arch} ${kind}
>>> - ${ASAN_UNITTEST_INSTRUMENTED_CFLAGS} ${ARGN})
>>> + CFLAGS ${ASAN_UNITTEST_INSTRUMENTED_CFLAGS} ${cflags})
>>> endforeach()
>>> add_asan_test(AsanBenchmarks "Asan-${arch}${kind}-Benchmark"
>>> ${arch} ${kind} SUBDIR "default"
>>> @@ -302,9 +296,9 @@ if(COMPILER_RT_CAN_EXECUTE_TESTS AND NOT
>>> darwin_filter_host_archs(ASAN_SUPPORTED_ARCH ASAN_TEST_ARCH)
>>> endif()
>>> foreach(arch ${ASAN_TEST_ARCH})
>>> - add_asan_tests_for_arch_and_kind(${arch} "-inline")
>>> + add_asan_tests_for_arch_and_kind(${arch} "-inline" "")
>>> add_asan_tests_for_arch_and_kind(${arch} "-with-calls"
>>> - -mllvm -asan-instrumentation-with-call-threshold=0)
>>> + "-mllvm;-asan-instrumentation-with-call-threshold=0")
>>> endforeach()
>>> endif()
>>>
>>>
>>> Modified: compiler-rt/trunk/lib/msan/tests/CMakeLists.txt
>>> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ms
>>> an/tests/CMakeLists.txt?rev=309405&r1=309404&r2=309405&view=diff
>>> ============================================================
>>> ==================
>>> --- compiler-rt/trunk/lib/msan/tests/CMakeLists.txt (original)
>>> +++ compiler-rt/trunk/lib/msan/tests/CMakeLists.txt Fri Jul 28 10:32:37
>>> 2017
>>> @@ -53,20 +53,14 @@ set(MSAN_UNITTEST_LINK_FLAGS
>>>
>>> append_list_if(COMPILER_RT_HAS_LIBDL -ldl MSAN_UNITTEST_LINK_FLAGS)
>>>
>>> -# Compile source for the given architecture, using compiler
>>> -# options in ${ARGN}, and add it to the object list.
>>> -macro(msan_compile obj_list source arch kind)
>>> - get_filename_component(basename ${source} NAME)
>>> - set(output_obj "${basename}.${arch}${kind}.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 ${COMPILE_DEPS})
>>> - list(APPEND ${obj_list} ${output_obj})
>>> +macro(msan_compile obj_list source arch kind cflags)
>>> + sanitizer_test_compile(
>>> + ${obj_list} ${source} ${arch}
>>> + KIND ${kind}
>>> + COMPILE_DEPS ${MSAN_UNITTEST_HEADERS}
>>> + DEPS gtest msan
>>> + CFLAGS ${MSAN_UNITTEST_INSTRUMENTED_CFLAGS} ${cflags}
>>> + )
>>> endmacro()
>>>
>>> macro(msan_link_shared so_list so_name arch kind)
>>> @@ -88,23 +82,22 @@ add_custom_target(MsanUnitTests)
>>> set_target_properties(MsanUnitTests PROPERTIES FOLDER "MSan unit
>>> tests")
>>>
>>> # Adds MSan unit tests and benchmarks for architecture.
>>> -macro(add_msan_tests_for_arch arch kind)
>>> +macro(add_msan_tests_for_arch arch kind cflags)
>>> # Build gtest instrumented with MSan.
>>> set(MSAN_INST_GTEST)
>>> - msan_compile(MSAN_INST_GTEST ${COMPILER_RT_GTEST_SOURCE} ${arch}
>>> "${kind}"
>>> - ${MSAN_UNITTEST_INSTRUMENTED_CFLAGS}
>>> ${ARGN})
>>> + msan_compile(MSAN_INST_GTEST ${COMPILER_RT_GTEST_SOURCE} ${arch}
>>> ${kind}
>>> + "${cflags}")
>>>
>>> # Instrumented tests.
>>> set(MSAN_INST_TEST_OBJECTS)
>>> foreach (SOURCE ${MSAN_UNITTEST_SOURCES})
>>> - msan_compile(MSAN_INST_TEST_OBJECTS ${SOURCE} ${arch} "${kind}"
>>> - ${MSAN_UNITTEST_INSTRUMENTED_CFLAGS} ${ARGN})
>>> + msan_compile(MSAN_INST_TEST_OBJECTS ${SOURCE} ${arch} "${kind}"
>>> "${cflags}")
>>> endforeach(SOURCE)
>>>
>>> # Instrumented loadable module objects.
>>> set(MSAN_INST_LOADABLE_OBJECTS)
>>> msan_compile(MSAN_INST_LOADABLE_OBJECTS ${MSAN_LOADABLE_SOURCE}
>>> ${arch} "${kind}"
>>> - ${MSAN_UNITTEST_INSTRUMENTED_CFLAGS} "-fPIC" ${ARGN})
>>> + "-fPIC;${cflags}")
>>>
>>> # Instrumented loadable library tests.
>>> set(MSAN_LOADABLE_SO)
>>> @@ -138,8 +131,8 @@ if(COMPILER_RT_CAN_EXECUTE_TESTS AND COM
>>> CFLAGS ${MSAN_LIBCXX_CFLAGS} ${TARGET_CFLAGS})
>>> set(MSAN_LIBCXX_SO ${LIBCXX_PREFIX}/lib/libc++.so)
>>>
>>> - add_msan_tests_for_arch(${arch} "")
>>> + add_msan_tests_for_arch(${arch} "" "")
>>> add_msan_tests_for_arch(${arch} "-with-call"
>>> - -mllvm -msan-instrumentation-with-cal
>>> l-threshold=0)
>>> + "-mllvm;-msan-instrumentation-
>>> with-call-threshold=0")
>>> endforeach()
>>> endif()
>>>
>>> Modified: compiler-rt/trunk/lib/tsan/tests/CMakeLists.txt
>>> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ts
>>> an/tests/CMakeLists.txt?rev=309405&r1=309404&r2=309405&view=diff
>>> ============================================================
>>> ==================
>>> --- compiler-rt/trunk/lib/tsan/tests/CMakeLists.txt (original)
>>> +++ compiler-rt/trunk/lib/tsan/tests/CMakeLists.txt Fri Jul 28 10:32:37
>>> 2017
>>> @@ -23,21 +23,6 @@ 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 ${COMPILE_DEPS})
>>> - list(APPEND ${obj_list} ${output_obj})
>>> -endmacro()
>>> -
>>> macro(add_tsan_unittest testname)
>>> set(TSAN_TEST_ARCH ${TSAN_SUPPORTED_ARCH})
>>> if(APPLE)
>>> @@ -48,7 +33,12 @@ macro(add_tsan_unittest testname)
>>> cmake_parse_arguments(TEST "" "" "SOURCES;HEADERS" ${ARGN})
>>> set(TEST_OBJECTS)
>>> foreach(SOURCE ${TEST_SOURCES} ${COMPILER_RT_GTEST_SOURCE})
>>> - tsan_compile(TEST_OBJECTS ${SOURCE} ${arch} ${TEST_HEADERS})
>>> + sanitizer_test_compile(
>>> + TEST_OBJECTS ${SOURCE} ${arch}
>>> + COMPILE_DEPS ${TSAN_RTL_HEADERS} ${TEST_HEADERS}
>>> + DEPS gtest tsan
>>> + CFLAGS ${TSAN_UNITTEST_CFLAGS}
>>> + )
>>> endforeach()
>>> get_target_flags_for_arch(${arch} TARGET_LINK_FLAGS)
>>> set(TEST_DEPS ${TEST_OBJECTS})
>>>
>>> Modified: compiler-rt/trunk/lib/xray/tests/CMakeLists.txt
>>> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/xr
>>> ay/tests/CMakeLists.txt?rev=309405&r1=309404&r2=309405&view=diff
>>> ============================================================
>>> ==================
>>> --- compiler-rt/trunk/lib/xray/tests/CMakeLists.txt (original)
>>> +++ compiler-rt/trunk/lib/xray/tests/CMakeLists.txt Fri Jul 28 10:32:37
>>> 2017
>>> @@ -11,19 +11,6 @@ set(XRAY_UNITTEST_CFLAGS
>>> -I${COMPILER_RT_SOURCE_DIR}/lib/xray
>>> -I${COMPILER_RT_SOURCE_DIR}/lib)
>>>
>>> -macro(xray_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)
>>> - if(NOT COMPILER_RT_STANDALONE_BUILD)
>>> - list(APPEND COMPILE_DEPS gtest_main xray)
>>> - endif()
>>> - clang_compile(${output_obj} ${source}
>>> - CFLAGS ${XRAY_UNITTEST_CFLAGS} ${TARGET_CFLAGS}
>>> - DEPS ${COMPILE_DEPS})
>>> - list(APPEND ${obj_list} ${output_obj})
>>> -endmacro()
>>> -
>>> macro(add_xray_unittest testname)
>>> set(XRAY_TEST_ARCH ${XRAY_SUPPORTED_ARCH})
>>> if (APPLE)
>>> @@ -34,7 +21,9 @@ macro(add_xray_unittest testname)
>>> cmake_parse_arguments(TEST "" "" "SOURCES;HEADERS" ${ARGN})
>>> set(TEST_OBJECTS)
>>> foreach(SOURCE ${TEST_SOURCES} ${COMPILER_RT_GTEST_SOURCE})
>>> - xray_compile(TEST_OBJECTS ${SOURCE} ${arch} ${TEST_HEADERS})
>>> + sanitizer_test_compile(TEST_OBJECTS ${SOURCE} ${arch}
>>> + DEPS gtest_main xray
>>> + CFLAGS ${XRAY_UNITTEST_CFLAGS})
>>> endforeach()
>>> get_target_flags_for_arch(${arch} TARGET_LINK_FLAGS)
>>> set(TEST_DEPS ${TEST_OBJECTS})
>>>
>>>
>>> _______________________________________________
>>> llvm-commits mailing list
>>> llvm-commits at lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>>
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170728/6ef9df9b/attachment.html>
More information about the llvm-commits
mailing list