Index: CMakeLists.txt =================================================================== --- CMakeLists.txt +++ CMakeLists.txt @@ -207,7 +207,8 @@ pythonize_bool(COMPILER_RT_DEBUG) # We have to support both static and dynamic/shared runtime on Windows. -if(WIN32) +# Android only works with dynamic runtime. +if(WIN32 OR ANDROID) option(COMPILER_RT_BUILD_SHARED_ASAN "Build shared version of AddressSanitizer runtime" ON) else() option(COMPILER_RT_BUILD_SHARED_ASAN "Build shared version of AddressSanitizer runtime" OFF) Index: cmake/Modules/AddCompilerRT.cmake =================================================================== --- cmake/Modules/AddCompilerRT.cmake +++ cmake/Modules/AddCompilerRT.cmake @@ -43,7 +43,8 @@ # add_compiler_rt_runtime( {STATIC,SHARED} # SOURCES # CFLAGS -# DEFS ) +# DEFS +# OUTPUT_NAME ) macro(add_compiler_rt_runtime name arch type) if(CAN_TARGET_${arch}) parse_arguments(LIB "SOURCES;CFLAGS;DEFS;OUTPUT_NAME" "" ${ARGN}) @@ -59,7 +60,10 @@ set_target_properties(${name} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR} LIBRARY_OUTPUT_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR}) - if (LIB_OUTPUT_NAME) + if ("${LIB_OUTPUT_NAME}" STREQUAL "") + set_target_properties(${name} PROPERTIES + OUTPUT_NAME ${name}${COMPILER_RT_OS_SUFFIX}) + else() set_target_properties(${name} PROPERTIES OUTPUT_NAME ${LIB_OUTPUT_NAME}) endif() Index: cmake/config-ix.cmake =================================================================== --- cmake/config-ix.cmake +++ cmake/config-ix.cmake @@ -79,16 +79,47 @@ CMAKE_FLAGS "-DCMAKE_EXE_LINKER_FLAGS:STRING=${argstring}") if(${CAN_TARGET_${arch}}) list(APPEND COMPILER_RT_SUPPORTED_ARCH ${arch}) - elseif("${COMPILER_RT_TEST_TARGET_ARCH}" MATCHES "${arch}" OR - "${arch}" STREQUAL "arm_android") + elseif("${COMPILER_RT_TEST_TARGET_ARCH}" MATCHES "${arch}") # Bail out if we cannot target the architecture we plan to test. message(FATAL_ERROR "Cannot compile for ${arch}:\n${TARGET_${arch}_OUTPUT}") endif() endmacro() +# Add $arch as supported with no additional flags. +macro(add_default_target_arch arch) + set(TARGET_${arch}_CFLAGS "") + set(CAN_TARGET_${arch} 1) + list(APPEND COMPILER_RT_SUPPORTED_ARCH ${arch}) +endmacro() + +macro(detect_target_arch) + check_symbol_exists(__arm__ "" __ARM) + check_symbol_exists(__aarch64__ "" __AARCH64) + check_symbol_exists(__x86_64__ "" __X86_64) + check_symbol_exists(__i386__ "" __I386) + check_symbol_exists(__mips__ "" __MIPS) + check_symbol_exists(__mips64__ "" __MIPS64) + if(__ARM) + add_default_target_arch(arm) + elseif(__AARCH64) + add_default_target_arch(aarch64) + elseif(__X86_64) + add_default_target_arch(x86_64) + elseif(__I386) + add_default_target_arch(i386) + elseif(__MIPS64) # must be checked before __MIPS + add_default_target_arch(mips64) + elseif(__MIPS) + add_default_target_arch(mips) + endif() +endmacro() + # Generate the COMPILER_RT_SUPPORTED_ARCH list. if(ANDROID) - test_target_arch(arm_android "") + # Can't rely on LLVM_NATIVE_ARCH in cross-compilation. + # Examine compiler output instead. + detect_target_arch() + set(COMPILER_RT_OS_SUFFIX "-android") else() if("${LLVM_NATIVE_ARCH}" STREQUAL "X86") if (NOT MSVC) @@ -105,8 +136,11 @@ test_target_arch(arm "-march=armv7-a") test_target_arch(aarch64 "-march=armv8-a") endif() + set(COMPILER_RT_OS_SUFFIX "") endif() +message("Compiler-RT supported architectures: ${COMPILER_RT_SUPPORTED_ARCH}") + # Takes ${ARGN} and puts only supported architectures in @out_var list. function(filter_available_targets out_var) set(archs) @@ -120,11 +154,10 @@ endfunction() # Arhcitectures supported by compiler-rt libraries. -# FIXME: add arm_android here filter_available_targets(SANITIZER_COMMON_SUPPORTED_ARCH - x86_64 i386 powerpc64 arm aarch64 mips arm_android) + x86_64 i386 powerpc64 arm aarch64 mips) filter_available_targets(ASAN_SUPPORTED_ARCH - x86_64 i386 powerpc64 arm mips arm_android) + x86_64 i386 powerpc64 arm mips) filter_available_targets(DFSAN_SUPPORTED_ARCH x86_64) filter_available_targets(LSAN_SUPPORTED_ARCH x86_64) # LSan common files should be available on all architectures supported @@ -173,7 +206,7 @@ endif() if (COMPILER_RT_HAS_SANITIZER_COMMON AND LSAN_COMMON_SUPPORTED_ARCH AND - OS_NAME MATCHES "Darwin|Linux|FreeBSD") + OS_NAME MATCHES "Darwin|Linux|FreeBSD|Android") set(COMPILER_RT_HAS_LSAN_COMMON TRUE) else() set(COMPILER_RT_HAS_LSAN_COMMON FALSE) Index: lib/asan/CMakeLists.txt =================================================================== --- lib/asan/CMakeLists.txt +++ lib/asan/CMakeLists.txt @@ -66,6 +66,8 @@ append_if(COMPILER_RT_HAS_LIBPTHREAD pthread ASAN_DYNAMIC_LIBS) append_if(COMPILER_RT_HAS_LIBSTDCXX stdc++ ASAN_DYNAMIC_LIBS) +append_if(ANDROID log ASAN_DYNAMIC_LIBS) + # Compile ASan sources into an object library. if(APPLE) foreach(os ${SANITIZER_COMMON_SUPPORTED_DARWIN_OS}) @@ -75,11 +77,6 @@ CFLAGS ${ASAN_CFLAGS} DEFS ${ASAN_COMMON_DEFINITIONS}) endforeach() -elseif(ANDROID) - add_library(RTAsan.arm.android OBJECT ${ASAN_SOURCES} ${ASAN_CXX_SOURCES}) - set_target_compile_flags(RTAsan.arm.android ${ASAN_CFLAGS}) - set_property(TARGET RTAsan.arm.android APPEND PROPERTY - COMPILE_DEFINITIONS ${ASAN_COMMON_DEFINITIONS}) else() foreach(arch ${ASAN_SUPPORTED_ARCH}) add_compiler_rt_object_library(RTAsan ${arch} @@ -114,21 +111,6 @@ DEFS ${ASAN_COMMON_DEFINITIONS}) add_dependencies(asan clang_rt.asan_${os}_dynamic) endforeach() - -elseif(ANDROID) - add_library(clang_rt.asan-arm-android SHARED - $ - $ - $) - set_target_compile_flags(clang_rt.asan-arm-android - ${ASAN_CFLAGS}) - set_property(TARGET clang_rt.asan-arm-android APPEND PROPERTY - COMPILE_DEFINITIONS ${ASAN_COMMON_DEFINITIONS}) - target_link_libraries(clang_rt.asan-arm-android dl log) - add_dependencies(asan clang_rt.asan-arm-android) - install(TARGETS clang_rt.asan-arm-android - ARCHIVE DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR} - LIBRARY DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR}) else() # Build separate libraries for each target. foreach(arch ${ASAN_SUPPORTED_ARCH}) @@ -136,7 +118,7 @@ $ $ $) - if (NOT WIN32) + if(NOT WIN32) # We can't build Leak Sanitizer on Windows yet. list(APPEND ASAN_COMMON_RUNTIME_OBJECTS $) @@ -164,9 +146,9 @@ add_dependencies(asan clang_rt.asan-preinit-${arch}) if (WIN32) - set(SHARED_ASAN_NAME clang_rt.asan_dynamic-${arch}) + set(SHARED_ASAN_NAME clang_rt.asan_dynamic-${arch}${COMPILER_RT_OS_SUFFIX}) else() - set(SHARED_ASAN_NAME clang_rt.asan-${arch}) + set(SHARED_ASAN_NAME clang_rt.asan-${arch}${COMPILER_RT_OS_SUFFIX}) endif() add_compiler_rt_runtime(clang_rt.asan-dynamic-${arch} ${arch} SHARED Index: lib/asan/scripts/asan_device_setup =================================================================== --- lib/asan/scripts/asan_device_setup +++ lib/asan/scripts/asan_device_setup @@ -107,8 +107,8 @@ ASAN_RT_PATH="$HERE" elif [[ $(basename "$HERE") == "bin" ]]; then # We could be in the toolchain's base directory. - # Consider ../lib, ../lib/asan and ../lib/clang/$VERSION/lib/linux. - P=$(ls "$HERE"/../lib/"$ASAN_RT" "$HERE"/../lib/asan/"$ASAN_RT" "$HERE"/../lib/clang/*/lib/linux/"$ASAN_RT" 2>/dev/null | sort | tail -1) + # Consider ../lib, ../lib/asan, ../lib/linux and ../lib/clang/$VERSION/lib/linux. + P=$(ls "$HERE"/../lib/"$ASAN_RT" "$HERE"/../lib/asan/"$ASAN_RT" "$HERE"/../lib/linux/"$ASAN_RT" "$HERE"/../lib/clang/*/lib/linux/"$ASAN_RT" 2>/dev/null | sort | tail -1) if [[ -n "$P" ]]; then ASAN_RT_PATH="$(dirname "$P")" fi Index: lib/asan/tests/CMakeLists.txt =================================================================== --- lib/asan/tests/CMakeLists.txt +++ lib/asan/tests/CMakeLists.txt @@ -73,16 +73,16 @@ set(ASAN_UNITTEST_INSTRUMENTED_LINKFLAGS ${ASAN_UNITTEST_COMMON_LINKFLAGS}) -# On Android, we link with ASan runtime manually. On other platforms we depend -# on Clang driver behavior, passing -fsanitize=address flag. -if(NOT ANDROID) - list(APPEND ASAN_UNITTEST_INSTRUMENTED_LINKFLAGS -fsanitize=address) -endif() +list(APPEND ASAN_UNITTEST_INSTRUMENTED_LINKFLAGS -fsanitize=address) set(ASAN_DYNAMIC_UNITTEST_INSTRUMENTED_LINKFLAGS ${ASAN_UNITTEST_INSTRUMENTED_LINKFLAGS} -shared-libasan) +set(ASAN_UNITTEST_INSTRUMENTED_LIBS) +# NDK r10 requires -latomic almost always. +append_if(ANDROID atomic ASAN_UNITTEST_INSTRUMENTED_LIBS) + set(ASAN_UNITTEST_NOINST_LINKFLAGS ${ASAN_UNITTEST_COMMON_LINKFLAGS}) append_if(COMPILER_RT_HAS_LIBM -lm ASAN_UNITTEST_NOINST_LINKFLAGS) append_if(COMPILER_RT_HAS_LIBDL -ldl ASAN_UNITTEST_NOINST_LINKFLAGS) @@ -90,6 +90,12 @@ append_if(COMPILER_RT_HAS_LIBPTHREAD -pthread ASAN_DYNAMIC_UNITTEST_INSTRUMENTED_LINKFLAGS) +# TODO(eugenis): move all -l flags above to _LIBS? +set(ASAN_UNITTEST_NOINST_LIBS) +append_if(ANDROID log ASAN_UNITTEST_NOINST_LIBS) +# NDK r10 requires -latomic almost always. +append_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) @@ -198,7 +204,7 @@ $ $ $) - if(NOT MSVC) + if(NOT WIN32) list(APPEND ASAN_TEST_RUNTIME_OBJECTS $) endif() @@ -242,31 +248,31 @@ endif() if(ANDROID) - # We assume that unit tests on Android are built in a build - # tree with fresh Clang as a host compiler. - - # Test w/o ASan instrumentation. Link it with ASan statically. - add_executable(AsanNoinstTest - $ - $ - $ - ${COMPILER_RT_GTEST_SOURCE} - ${ASAN_NOINST_TEST_SOURCES}) - set_target_compile_flags(AsanNoinstTest ${ASAN_UNITTEST_COMMON_CFLAGS}) - set_target_link_flags(AsanNoinstTest ${ASAN_UNITTEST_NOINST_LINKFLAGS}) - target_link_libraries(AsanNoinstTest log) - - # Test with ASan instrumentation. Link with ASan dynamic runtime. - add_executable(AsanTest - ${COMPILER_RT_GTEST_SOURCE} - ${ASAN_INST_TEST_SOURCES}) - set_target_compile_flags(AsanTest ${ASAN_UNITTEST_INSTRUMENTED_CFLAGS}) - set_target_link_flags(AsanTest ${ASAN_UNITTEST_INSTRUMENTED_LINKFLAGS}) - target_link_libraries(AsanTest clang_rt.asan-arm-android) - - # Setup correct output directory and link flags. - set_target_properties(AsanNoinstTest AsanTest PROPERTIES - RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - # Add unit test to test suite. - add_dependencies(AsanUnitTests AsanNoinstTest AsanTest) + foreach(arch ${ASAN_SUPPORTED_ARCH}) + # Test w/o ASan instrumentation. Link it with ASan statically. + add_executable(AsanNoinstTest # FIXME: .arch? + $ + $ + $ + $ + ${COMPILER_RT_GTEST_SOURCE} + ${ASAN_NOINST_TEST_SOURCES}) + set_target_compile_flags(AsanNoinstTest ${ASAN_UNITTEST_COMMON_CFLAGS}) + set_target_link_flags(AsanNoinstTest ${ASAN_UNITTEST_NOINST_LINKFLAGS}) + target_link_libraries(AsanNoinstTest ${ASAN_UNITTEST_NOINST_LIBS}) + + # Test with ASan instrumentation. Link with ASan dynamic runtime. + add_executable(AsanTest + ${COMPILER_RT_GTEST_SOURCE} + ${ASAN_INST_TEST_SOURCES}) + set_target_compile_flags(AsanTest ${ASAN_UNITTEST_INSTRUMENTED_CFLAGS}) + set_target_link_flags(AsanTest ${ASAN_UNITTEST_INSTRUMENTED_LINKFLAGS}) + target_link_libraries(AsanTest ${ASAN_UNITTEST_INSTRUMENTED_LIBS}) + + # Setup correct output directory and link flags. + set_target_properties(AsanNoinstTest AsanTest PROPERTIES + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + # Add unit tests to the test suite. + add_dependencies(AsanUnitTests AsanNoinstTest AsanTest) + endforeach() endif() Index: lib/interception/CMakeLists.txt =================================================================== --- lib/interception/CMakeLists.txt +++ lib/interception/CMakeLists.txt @@ -20,10 +20,6 @@ SOURCES ${INTERCEPTION_SOURCES} CFLAGS ${INTERCEPTION_CFLAGS}) endforeach() -elseif(ANDROID) - add_library(RTInterception.arm.android OBJECT ${INTERCEPTION_SOURCES}) - set_target_compile_flags(RTInterception.arm.android - ${INTERCEPTION_CFLAGS}) else() # Otherwise, build separate libraries for each target. foreach(arch ${SANITIZER_COMMON_SUPPORTED_ARCH}) Index: lib/lsan/CMakeLists.txt =================================================================== --- lib/lsan/CMakeLists.txt +++ lib/lsan/CMakeLists.txt @@ -25,7 +25,7 @@ SOURCES ${LSAN_COMMON_SOURCES} CFLAGS ${LSAN_CFLAGS}) endforeach() -elseif(NOT ANDROID) +else() foreach(arch ${LSAN_COMMON_SUPPORTED_ARCH}) add_compiler_rt_object_library(RTLSanCommon ${arch} SOURCES ${LSAN_COMMON_SOURCES} Index: lib/sanitizer_common/CMakeLists.txt =================================================================== --- lib/sanitizer_common/CMakeLists.txt +++ lib/sanitizer_common/CMakeLists.txt @@ -121,14 +121,6 @@ DEFS ${SANITIZER_COMMON_DEFINITIONS}) list(APPEND SANITIZER_RUNTIME_LIBRARIES RTSanitizerCommon.${os}) endforeach() -elseif(ANDROID) - add_library(RTSanitizerCommon.arm.android OBJECT - ${SANITIZER_SOURCES} ${SANITIZER_LIBCDEP_SOURCES}) - set_target_compile_flags(RTSanitizerCommon.arm.android - ${SANITIZER_CFLAGS}) - set_property(TARGET RTSanitizerCommon.arm.android APPEND PROPERTY - COMPILE_DEFINITIONS ${SANITIZER_COMMON_DEFINITIONS}) - list(APPEND SANITIZER_RUNTIME_LIBRARIES RTSanitizerCommon.arm.android) else() # Otherwise, build separate libraries for each target. foreach(arch ${SANITIZER_COMMON_SUPPORTED_ARCH}) Index: lib/sanitizer_common/tests/CMakeLists.txt =================================================================== --- lib/sanitizer_common/tests/CMakeLists.txt +++ lib/sanitizer_common/tests/CMakeLists.txt @@ -57,6 +57,11 @@ list(APPEND SANITIZER_TEST_LINK_FLAGS_COMMON --driver-mode=g++) endif() +set(SANITIZER_TEST_LINK_LIBS) +append_if(ANDROID log SANITIZER_TEST_LINK_LIBS) +# NDK r10 requires -latomic almost always. +append_if(ANDROID atomic SANITIZER_TEST_LINK_LIBS) + append_if(COMPILER_RT_HAS_LIBDL -ldl SANITIZER_TEST_LINK_FLAGS_COMMON) append_if(COMPILER_RT_HAS_LIBPTHREAD -pthread SANITIZER_TEST_LINK_FLAGS_COMMON) # x86_64 FreeBSD 9.2 additionally requires libc++ to build the tests. Also, @@ -172,20 +177,21 @@ endif() if(ANDROID) - # We assume that unit tests on Android are built in a build - # tree with fresh Clang as a host compiler. - add_executable(SanitizerTest - ${SANITIZER_UNITTESTS} - ${COMPILER_RT_GTEST_SOURCE} - $) - set_target_compile_flags(SanitizerTest - ${SANITIZER_COMMON_CFLAGS} - ${SANITIZER_TEST_CFLAGS_COMMON}) - # Setup correct output directory and link flags. - set_target_properties(SanitizerTest PROPERTIES - RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - set_target_link_flags(SanitizerTest ${SANITIZER_TEST_LINK_FLAGS_COMMON}) - target_link_libraries(SanitizerTest log) - # Add unit test to test suite. - add_dependencies(SanitizerUnitTests SanitizerTest) + foreach(arch ${SANITIZER_COMMON_SUPPORTED_ARCH}) + add_executable(SanitizerTest + ${SANITIZER_UNITTESTS} + ${COMPILER_RT_GTEST_SOURCE} + $ + $) + set_target_compile_flags(SanitizerTest + ${SANITIZER_COMMON_CFLAGS} + ${SANITIZER_TEST_CFLAGS_COMMON}) + # Setup correct output directory and link flags. + set_target_properties(SanitizerTest PROPERTIES + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + set_target_link_flags(SanitizerTest ${SANITIZER_TEST_LINK_FLAGS_COMMON}) + target_link_libraries(SanitizerTest ${SANITIZER_TEST_LINK_LIBS}) + # Add unit test to test suite. + add_dependencies(SanitizerUnitTests SanitizerTest) + endforeach() endif() Index: test/asan/CMakeLists.txt =================================================================== --- test/asan/CMakeLists.txt +++ test/asan/CMakeLists.txt @@ -2,113 +2,132 @@ set(ASAN_TESTSUITES) -if(CAN_TARGET_arm_android) - # This is only true if we are cross-compiling. - # Build all tests with host compiler and use host tools. - set(ASAN_TEST_TARGET_CC ${CMAKE_C_COMPILER}) - set(ASAN_TEST_TARGET_CFLAGS ${COMPILER_RT_TEST_COMPILER_CFLAGS}) - get_filename_component(ASAN_TEST_LLVM_TOOLS_DIR ${CMAKE_C_COMPILER} PATH) - set(ASAN_TEST_CONFIG_SUFFIX "-arm-android") - set(ASAN_TEST_BITS "32") - set(ASAN_TEST_DYNAMIC True) - set(ASAN_TEST_TARGET_ARCH "arm-android") - configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/ARMAndroidConfig/lit.site.cfg - ) - list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/ARMAndroidConfig) -endif() +macro(get_bits_for_arch arch bits) + if (${arch} STREQUAL "arm" OR + ${arch} STREQUAL "i386" OR + ${arch} STREQUAL "mips") + set(bits 32) + elseif (${arch} STREQUAL "aarch64" OR + ${arch} STREQUAL "x86_64" OR + ${arch} STREQUAL "mips64") + set(bits 64) + else() + message(FATAL_ERROR "Unknown target architecture: ${arch}") + endif() +endmacro() -if(CAN_TARGET_arm) - # This is only true if we are cross-compiling. - # Build all tests with host compiler and use host tools. - set(ASAN_TEST_TARGET_CC ${COMPILER_RT_TEST_COMPILER}) - set(ASAN_TEST_TARGET_CFLAGS ${COMPILER_RT_TEST_COMPILER_CFLAGS}) - set(ASAN_TEST_CONFIG_SUFFIX "-arm-linux") - set(ASAN_TEST_BITS "32") - set(ASAN_TEST_DYNAMIC False) - configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/ARMLinuxConfig/lit.site.cfg - ) - list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/ARMLinuxConfig) -endif() +# TODO: merge with non-ANDROID case +if(ANDROID) + foreach(arch ${ASAN_SUPPORTED_ARCH}) + set(ASAN_TEST_TARGET_CC ${COMPILER_RT_TEST_COMPILER}) + set(ASAN_TEST_TARGET_CFLAGS ${COMPILER_RT_TEST_COMPILER_CFLAGS}) + set(ASAN_TEST_CONFIG_SUFFIX "-${arch}-android") + get_bits_for_arch(${arch} ASAN_TEST_BITS) + set(ASAN_TEST_DYNAMIC True) + set(ASAN_TEST_TARGET_ARCH "${arch}-android") + string(TOUPPER ${arch} ARCH_UPPER_CASE) + set(CONFIG ${ARCH_UPPER_CASE}AndroidConfig) + configure_lit_site_cfg( + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in + ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG}/lit.site.cfg + ) + list(APPEND ASAN_TESTSUITES + ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG}) + endforeach() + +else() # Not Android + + if(CAN_TARGET_arm) + # This is only true if we are cross-compiling. + # Build all tests with host compiler and use host tools. + set(ASAN_TEST_TARGET_CC ${COMPILER_RT_TEST_COMPILER}) + set(ASAN_TEST_TARGET_CFLAGS ${COMPILER_RT_TEST_COMPILER_CFLAGS}) + set(ASAN_TEST_CONFIG_SUFFIX "-arm-linux") + set(ASAN_TEST_BITS "32") + set(ASAN_TEST_DYNAMIC False) + configure_lit_site_cfg( + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in + ${CMAKE_CURRENT_BINARY_DIR}/ARMLinuxConfig/lit.site.cfg + ) + list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/ARMLinuxConfig) + endif() -if(CAN_TARGET_aarch64) - # This is only true if we are cross-compiling. - # Build all tests with host compiler and use host tools. - set(ASAN_TEST_TARGET_CC ${COMPILER_RT_TEST_COMPILER}) - set(ASAN_TEST_TARGET_CFLAGS ${COMPILER_RT_TEST_COMPILER_CFLAGS}) - set(ASAN_TEST_CONFIG_SUFFIX "-aarch64-linux") - set(ASAN_TEST_BITS "64") - set(ASAN_TEST_DYNAMIC False) - configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/AArch64LinuxConfig/lit.site.cfg - ) - list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/AArch64LinuxConfig) -endif() + if(CAN_TARGET_aarch64) + # This is only true if we are cross-compiling. + # Build all tests with host compiler and use host tools. + set(ASAN_TEST_TARGET_CC ${COMPILER_RT_TEST_COMPILER}) + set(ASAN_TEST_TARGET_CFLAGS ${COMPILER_RT_TEST_COMPILER_CFLAGS}) + set(ASAN_TEST_CONFIG_SUFFIX "-aarch64-linux") + set(ASAN_TEST_BITS "64") + set(ASAN_TEST_DYNAMIC False) + configure_lit_site_cfg( + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in + ${CMAKE_CURRENT_BINARY_DIR}/AArch64LinuxConfig/lit.site.cfg + ) + list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/AArch64LinuxConfig) + endif() -if(CAN_TARGET_x86_64 OR CAN_TARGET_powerpc64) - set(ASAN_TEST_CONFIG_SUFFIX "64") - set(ASAN_TEST_BITS "64") - set(ASAN_TEST_TARGET_CFLAGS ${TARGET_64_BIT_CFLAGS}) - set(ASAN_TEST_DYNAMIC False) - configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/64bitConfig/lit.site.cfg - ) - list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/64bitConfig) - if(COMPILER_RT_BUILD_SHARED_ASAN) - set(ASAN_TEST_CONFIG_SUFFIX "64-Dynamic") - set(ASAN_TEST_DYNAMIC True) + if(CAN_TARGET_x86_64 OR CAN_TARGET_powerpc64) + set(ASAN_TEST_CONFIG_SUFFIX "64") + set(ASAN_TEST_BITS "64") + set(ASAN_TEST_TARGET_CFLAGS ${TARGET_64_BIT_CFLAGS}) + set(ASAN_TEST_DYNAMIC False) configure_lit_site_cfg( ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/64bitConfig-dynamic/lit.site.cfg) - list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/64bitConfig-dynamic) + ${CMAKE_CURRENT_BINARY_DIR}/64bitConfig/lit.site.cfg + ) + list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/64bitConfig) + if(COMPILER_RT_BUILD_SHARED_ASAN) + set(ASAN_TEST_CONFIG_SUFFIX "64-Dynamic") + set(ASAN_TEST_DYNAMIC True) + configure_lit_site_cfg( + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in + ${CMAKE_CURRENT_BINARY_DIR}/64bitConfig-dynamic/lit.site.cfg) + list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/64bitConfig-dynamic) + endif() endif() -endif() -if(CAN_TARGET_i386) - set(ASAN_TEST_CONFIG_SUFFIX "32") - set(ASAN_TEST_BITS "32") - set(ASAN_TEST_TARGET_CFLAGS ${TARGET_32_BIT_CFLAGS}) - set(ASAN_TEST_DYNAMIC False) - set(ASAN_TEST_TARGET_ARCH "i386") - configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/32bitConfig/lit.site.cfg - ) - list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/32bitConfig) - if(COMPILER_RT_BUILD_SHARED_ASAN) - set(ASAN_TEST_CONFIG_SUFFIX "32-Dynamic") - set(ASAN_TEST_DYNAMIC True) + if(CAN_TARGET_i386) + set(ASAN_TEST_CONFIG_SUFFIX "32") + set(ASAN_TEST_BITS "32") + set(ASAN_TEST_TARGET_CFLAGS ${TARGET_32_BIT_CFLAGS}) + set(ASAN_TEST_DYNAMIC False) + set(ASAN_TEST_TARGET_ARCH "i386") configure_lit_site_cfg( ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/32bitConfig-dynamic/lit.site.cfg) - list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/32bitConfig-dynamic) + ${CMAKE_CURRENT_BINARY_DIR}/32bitConfig/lit.site.cfg + ) + list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/32bitConfig) + if(COMPILER_RT_BUILD_SHARED_ASAN) + set(ASAN_TEST_CONFIG_SUFFIX "32-Dynamic") + set(ASAN_TEST_DYNAMIC True) + configure_lit_site_cfg( + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in + ${CMAKE_CURRENT_BINARY_DIR}/32bitConfig-dynamic/lit.site.cfg) + list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/32bitConfig-dynamic) + endif() endif() -endif() -if(CAN_TARGET_mips) - set(ASAN_TEST_CONFIG_SUFFIX "32") - set(ASAN_TEST_BITS "32") - set(ASAN_TEST_TARGET_CFLAGS ${TARGET_32_BIT_CFLAGS}) - set(ASAN_TEST_DYNAMIC False) - configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/32bitConfig/lit.site.cfg - ) - list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/32bitConfig) - if(COMPILER_RT_BUILD_SHARED_ASAN) - set(ASAN_TEST_CONFIG_SUFFIX "32-Dynamic") - set(ASAN_TEST_DYNAMIC True) + if(CAN_TARGET_mips) + set(ASAN_TEST_CONFIG_SUFFIX "32") + set(ASAN_TEST_BITS "32") + set(ASAN_TEST_TARGET_CFLAGS ${TARGET_32_BIT_CFLAGS}) + set(ASAN_TEST_DYNAMIC False) configure_lit_site_cfg( ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/32bitConfig-dynamic/lit.site.cfg) - list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/32bitConfig-dynamic) + ${CMAKE_CURRENT_BINARY_DIR}/32bitConfig/lit.site.cfg + ) + list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/32bitConfig) + if(COMPILER_RT_BUILD_SHARED_ASAN) + set(ASAN_TEST_CONFIG_SUFFIX "32-Dynamic") + set(ASAN_TEST_DYNAMIC True) + configure_lit_site_cfg( + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in + ${CMAKE_CURRENT_BINARY_DIR}/32bitConfig-dynamic/lit.site.cfg) + list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/32bitConfig-dynamic) + endif() endif() -endif() +endif() # Not Android if(COMPILER_RT_INCLUDE_TESTS) configure_lit_site_cfg( @@ -124,7 +143,7 @@ endif() # FIXME: support unit test in the android test runner -if(COMPILER_RT_INCLUDE_TESTS AND NOT CAN_TARGET_arm_android) +if(COMPILER_RT_INCLUDE_TESTS AND NOT ANDROID) list(APPEND ASAN_TEST_DEPS AsanUnitTests) list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/Unit) endif() Index: test/asan/lit.cfg =================================================================== --- test/asan/lit.cfg +++ test/asan/lit.cfg @@ -55,7 +55,7 @@ config.available_features.add("asan-static-runtime") asan_lit_source_dir = get_required_attr(config, "asan_lit_source_dir") -if config.android == "TRUE": +if config.android == "1": config.available_features.add('android') clang_wrapper = os.path.join(asan_lit_source_dir, "android_commands", "android_compile.py") + " " @@ -108,7 +108,7 @@ config.substitutions.append( ("%sancov", python_exec + " " + sancov + " ") ) # Determine kernel bitness -if config.host_arch.find('64') != -1 and config.android != "TRUE": +if config.host_arch.find('64') != -1 and config.android != "1": kernel_bits = '64' else: kernel_bits = '32' Index: test/asan/lit.site.cfg.in =================================================================== --- test/asan/lit.site.cfg.in +++ test/asan/lit.site.cfg.in @@ -6,9 +6,9 @@ config.asan_lit_source_dir = "@ASAN_LIT_SOURCE_DIR@" config.target_cflags = "@ASAN_TEST_TARGET_CFLAGS@" config.clang = "@ASAN_TEST_TARGET_CC@" -config.llvm_tools_dir = "@ASAN_TEST_LLVM_TOOLS_DIR@" +config.llvm_tools_dir = "@LLVM_TOOLS_BINARY_DIR@" config.bits = "@ASAN_TEST_BITS@" -config.android = "@CAN_TARGET_arm_android@" +config.android = "@ANDROID@" config.asan_dynamic = @ASAN_TEST_DYNAMIC@ config.target_arch = "@ASAN_TEST_TARGET_ARCH@"