Index: cmake/Modules/SanitizerUtils.cmake =================================================================== --- cmake/Modules/SanitizerUtils.cmake +++ cmake/Modules/SanitizerUtils.cmake @@ -9,51 +9,55 @@ # interceptors are exported automatically, user can also provide files with # symbol names that should be exported as well. # add_sanitizer_rt_symbols( +# ARCHS # PARENT_TARGET # EXTRA ) macro(add_sanitizer_rt_symbols name) cmake_parse_arguments(ARG "" "PARENT_TARGET" - "EXTRA" + "ARCHS;EXTRA" ${ARGN}) - set(stamp ${CMAKE_CURRENT_BINARY_DIR}/${name}.syms-stamp) - set(extra_args) - foreach(arg ${ARG_EXTRA}) - list(APPEND extra_args "--extra" ${arg}) - endforeach() - add_custom_command(OUTPUT ${stamp} - COMMAND ${PYTHON_EXECUTABLE} - ${SANITIZER_GEN_DYNAMIC_LIST} ${extra_args} $ - > $.syms - COMMAND ${CMAKE_COMMAND} -E touch ${stamp} - DEPENDS ${name} ${SANITIZER_GEN_DYNAMIC_LIST} ${ARG_EXTRA} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMENT "Generating exported symbols for ${name}" - VERBATIM) - add_custom_target(${name}-symbols ALL - DEPENDS ${stamp} - SOURCES ${SANITIZER_GEN_DYNAMIC_LIST} ${ARG_EXTRA}) + foreach(arch ${ARG_ARCHS}) + set(target_name ${name}-${arch}) + set(stamp ${CMAKE_CURRENT_BINARY_DIR}/${target_name}.syms-stamp) + set(extra_args) + foreach(arg ${ARG_EXTRA}) + list(APPEND extra_args "--extra" ${arg}) + endforeach() + add_custom_command(OUTPUT ${stamp} + COMMAND ${PYTHON_EXECUTABLE} + ${SANITIZER_GEN_DYNAMIC_LIST} ${extra_args} $ + > $.syms + COMMAND ${CMAKE_COMMAND} -E touch ${stamp} + DEPENDS ${target_name} ${SANITIZER_GEN_DYNAMIC_LIST} ${ARG_EXTRA} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMENT "Generating exported symbols for ${target_name}" + VERBATIM) + add_custom_target(${target_name}-symbols ALL + DEPENDS ${stamp} + SOURCES ${SANITIZER_GEN_DYNAMIC_LIST} ${ARG_EXTRA}) - if(NOT CMAKE_VERSION VERSION_LESS 3.0) - install(FILES $.syms - DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR}) - else() - # Per-config install location. - if(CMAKE_CONFIGURATION_TYPES) - foreach(c ${CMAKE_CONFIGURATION_TYPES}) - get_target_property(libfile ${name} LOCATION_${c}) - install(FILES ${libfile}.syms CONFIGURATIONS ${c} - DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR}) - endforeach() + if(NOT CMAKE_VERSION VERSION_LESS 3.0) + install(FILES $.syms + DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR}) else() - get_target_property(libfile ${name} LOCATION_${CMAKE_BUILD_TYPE}) - install(FILES ${libfile}.syms DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR}) + # Per-config install location. + if(CMAKE_CONFIGURATION_TYPES) + foreach(c ${CMAKE_CONFIGURATION_TYPES}) + get_target_property(libfile ${target_name} LOCATION_${c}) + install(FILES ${libfile}.syms CONFIGURATIONS ${c} + DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR}) + endforeach() + else() + get_target_property(libfile ${target_name} LOCATION_${CMAKE_BUILD_TYPE}) + install(FILES ${libfile}.syms DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR}) + endif() endif() - endif() - if(ARG_PARENT_TARGET) - add_dependencies(${ARG_PARENT_TARGET} ${name}-symbols) - endif() + if(ARG_PARENT_TARGET) + add_dependencies(${ARG_PARENT_TARGET} ${target_name}-symbols) + endif() + endforeach() endmacro() macro(add_sanitizer_rt_version_list name) Index: lib/asan/CMakeLists.txt =================================================================== --- lib/asan/CMakeLists.txt +++ lib/asan/CMakeLists.txt @@ -189,9 +189,11 @@ PARENT_TARGET asan) if (UNIX AND NOT ${arch} MATCHES "i386|i686") - add_sanitizer_rt_symbols(clang_rt.asan_cxx-${arch}) + add_sanitizer_rt_symbols(clang_rt.asan_cxx + ARCHS ${arch}) add_dependencies(asan clang_rt.asan_cxx-${arch}-symbols) - add_sanitizer_rt_symbols(clang_rt.asan-${arch} + add_sanitizer_rt_symbols(clang_rt.asan + ARCHS ${arch} EXTRA asan.syms.extra) add_dependencies(asan clang_rt.asan-${arch}-symbols) endif() Index: lib/dfsan/CMakeLists.txt =================================================================== --- lib/dfsan/CMakeLists.txt +++ lib/dfsan/CMakeLists.txt @@ -24,7 +24,8 @@ $ CFLAGS ${DFSAN_CFLAGS} PARENT_TARGET dfsan) - add_sanitizer_rt_symbols(clang_rt.dfsan-${arch} + add_sanitizer_rt_symbols(clang_rt.dfsan + ARCHS ${arch} EXTRA dfsan.syms.extra) add_dependencies(dfsan clang_rt.dfsan-${arch}-symbols) Index: lib/msan/CMakeLists.txt =================================================================== --- lib/msan/CMakeLists.txt +++ lib/msan/CMakeLists.txt @@ -47,9 +47,11 @@ list(APPEND MSAN_RUNTIME_LIBRARIES clang_rt.msan-${arch} clang_rt.msan_cxx-${arch}) if(UNIX) - add_sanitizer_rt_symbols(clang_rt.msan-${arch} + add_sanitizer_rt_symbols(clang_rt.msan + ARCHS ${arch} EXTRA msan.syms.extra) - add_sanitizer_rt_symbols(clang_rt.msan_cxx-${arch} + add_sanitizer_rt_symbols(clang_rt.msan_cxx + ARCHS ${arch} EXTRA msan.syms.extra) add_dependencies(msan clang_rt.msan-${arch}-symbols clang_rt.msan_cxx-${arch}-symbols) Index: lib/tsan/CMakeLists.txt =================================================================== --- lib/tsan/CMakeLists.txt +++ lib/tsan/CMakeLists.txt @@ -118,9 +118,11 @@ CFLAGS ${TSAN_RTL_CFLAGS}) list(APPEND TSAN_RUNTIME_LIBRARIES clang_rt.tsan-${arch} clang_rt.tsan_cxx-${arch}) - add_sanitizer_rt_symbols(clang_rt.tsan-${arch} + add_sanitizer_rt_symbols(clang_rt.tsan + ARCHS ${arch} EXTRA rtl/tsan.syms.extra) - add_sanitizer_rt_symbols(clang_rt.tsan_cxx-${arch} + add_sanitizer_rt_symbols(clang_rt.tsan_cxx + ARCHS ${arch} EXTRA rtl/tsan.syms.extra) add_dependencies(tsan clang_rt.tsan-${arch} clang_rt.tsan_cxx-${arch} Index: lib/ubsan/CMakeLists.txt =================================================================== --- lib/ubsan/CMakeLists.txt +++ lib/ubsan/CMakeLists.txt @@ -94,16 +94,18 @@ CFLAGS ${UBSAN_CXXFLAGS} PARENT_TARGET ubsan) - foreach(arch ${UBSAN_SUPPORTED_ARCH}) - if (UNIX AND NOT ${arch} MATCHES "i386|i686") - add_sanitizer_rt_symbols(clang_rt.ubsan_standalone-${arch} - PARENT_TARGET ubsan - EXTRA ubsan.syms.extra) - add_sanitizer_rt_symbols(clang_rt.ubsan_standalone_cxx-${arch} - PARENT_TARGET ubsan - EXTRA ubsan.syms.extra) - endif() - endforeach() + if (UNIX) + set(ARCHS_FOR_SYMBOLS ${UBSAN_SUPPORTED_ARCH}) + list(REMOVE_ITEM ARCHS_FOR_SYMBOLS i386 i686) + add_sanitizer_rt_symbols(clang_rt.ubsan_standalone + ARCHS ${ARCHS_FOR_SYMBOLS} + PARENT_TARGET ubsan + EXTRA ubsan.syms.extra) + add_sanitizer_rt_symbols(clang_rt.ubsan_standalone_cxx + ARCHS ${ARCHS_FOR_SYMBOLS} + PARENT_TARGET ubsan + EXTRA ubsan.syms.extra) + endif() endif() endif()