[ASan] Generalize/simplify lit test configs generation.

llvm-svn: 227413
This commit is contained in:
Alexey Samsonov 2015-01-29 02:28:53 +00:00
parent 76797c935b
commit 7f25a40550
1 changed files with 34 additions and 114 deletions

View File

@ -4,135 +4,55 @@ set(ASAN_TESTSUITES)
set(ASAN_DYNAMIC_TESTSUITES)
macro(get_bits_for_arch arch bits)
if (${arch} STREQUAL "arm" OR
${arch} STREQUAL "i386" OR
${arch} STREQUAL "i686" OR
${arch} STREQUAL "mips")
if (${arch} MATCHES "i386|i686|arm|mips|mipsel")
set(bits 32)
elseif (${arch} STREQUAL "aarch64" OR
${arch} STREQUAL "x86_64" OR
${arch} STREQUAL "mips64")
elseif (${arch} MATCHES "x86_64|powerpc64|powerpc64le|aarch64|mips64|mips64el")
set(bits 64)
else()
message(FATAL_ERROR "Unknown target architecture: ${arch}")
endif()
endmacro()
# TODO: merge with non-ANDROID case
if(ANDROID)
foreach(arch ${ASAN_SUPPORTED_ARCH})
set(ASAN_TEST_TARGET_CC ${CMAKE_CXX_COMPILER})
foreach(arch ${ASAN_SUPPORTED_ARCH})
if(ANDROID)
set(ASAN_TEST_TARGET_ARCH ${arch}-android)
else()
set(ASAN_TEST_TARGET_ARCH ${arch})
endif()
string(TOLOWER "-${arch}-${OS_NAME}" ASAN_TEST_CONFIG_SUFFIX)
get_bits_for_arch(${arch} ASAN_TEST_BITS)
if(ANDROID OR ${arch} MATCHES "arm|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 "-${arch}-android")
get_bits_for_arch(${arch} ASAN_TEST_BITS)
else()
get_target_flags_for_arch(${arch} ASAN_TEST_TARGET_CFLAGS)
endif()
if(ANDROID)
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")
else()
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()
string(TOUPPER ${arch} ARCH_UPPER_CASE)
set(CONFIG_NAME ${ARCH_UPPER_CASE}${OS_NAME}Config)
configure_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg
)
list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME})
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)
if(COMPILER_RT_ASAN_HAS_STATIC_RUNTIME)
string(TOLOWER "-${arch}-${OS_NAME}-dynamic" ASAN_TEST_CONFIG_SUFFIX)
set(ASAN_TEST_DYNAMIC True)
set(CONFIG_NAME ${ARCH_UPPER_CASE}${OS_NAME}DynamicConfig)
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)
${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg)
list(APPEND ASAN_DYNAMIC_TESTSUITES
${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME})
endif()
if(CAN_TARGET_x86_64 OR CAN_TARGET_powerpc64 OR CAN_TARGET_mips64 OR CAN_TARGET_mips64el)
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_ASAN_HAS_STATIC_RUNTIME)
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_DYNAMIC_TESTSUITES
${CMAKE_CURRENT_BINARY_DIR}/64bitConfig-dynamic)
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_ASAN_HAS_STATIC_RUNTIME)
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_DYNAMIC_TESTSUITES
${CMAKE_CURRENT_BINARY_DIR}/32bitConfig-dynamic)
endif()
endif()
if(CAN_TARGET_mips OR CAN_TARGET_mipsel)
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_ASAN_HAS_STATIC_RUNTIME)
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_DYNAMIC_TESTSUITES
${CMAKE_CURRENT_BINARY_DIR}/32bitConfig-dynamic)
endif()
endif()
endif() # Not Android
endforeach()
set(ASAN_TEST_DEPS ${SANITIZER_COMMON_LIT_TEST_DEPS})
if(COMPILER_RT_STANDALONE_BUILD)