Index: test/asan/CMakeLists.txt =================================================================== --- test/asan/CMakeLists.txt +++ test/asan/CMakeLists.txt @@ -9,7 +9,7 @@ get_filename_component(ASAN_TEST_LLVM_TOOLS_DIR ${CMAKE_C_COMPILER} PATH) set(ASAN_TEST_CONFIG_SUFFIX "-arm-android") set(ASAN_TEST_BITS "32") - get_target_flags_for_arch(arm_android ASAN_TEST_TARGET_CFLAGS) + get_target_flags_for_arch(arm_android COMPILER_RT_TEST_COMPILER_CFLAGS) configure_lit_site_cfg( ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in ${CMAKE_CURRENT_BINARY_DIR}/ARMAndroidConfig/lit.site.cfg @@ -17,10 +17,24 @@ list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/ARMAndroidConfig) endif() +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_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_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(COMPILER_RT_TEST_COMPILER_CFLAGS ${TARGET_64_BIT_CFLAGS}) set(ASAN_TEST_DYNAMIC False) configure_lit_site_cfg( ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in @@ -40,7 +54,7 @@ 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(COMPILER_RT_TEST_COMPILER_CFLAGS ${TARGET_32_BIT_CFLAGS}) set(ASAN_TEST_DYNAMIC False) set(ASAN_TEST_TARGET_ARCH "i386") configure_lit_site_cfg( Index: test/asan/lit.site.cfg.in =================================================================== --- test/asan/lit.site.cfg.in +++ test/asan/lit.site.cfg.in @@ -4,7 +4,6 @@ # Tool-specific config options. config.name_suffix = "@ASAN_TEST_CONFIG_SUFFIX@" 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.bits = "@ASAN_TEST_BITS@" Index: test/lit.common.cfg =================================================================== --- test/lit.common.cfg +++ test/lit.common.cfg @@ -56,6 +56,9 @@ (' clang', """\n\n*** Do not use 'clangXXX' in tests, instead define '%clangXXX' substitution in lit config. ***\n\n""") ) +# Allow tests to be executed on a simulator or remotely. +config.substitutions.append( ('%run', config.emulator) ) + # Add supported compiler_rt architectures to a list of available features. compiler_rt_arch = getattr(config, 'compiler_rt_arch', None) if compiler_rt_arch: Index: test/lit.common.configured.in =================================================================== --- test/lit.common.configured.in +++ test/lit.common.configured.in @@ -8,6 +8,7 @@ # Generic config options for all compiler-rt lit tests. set_default("target_triple", "@TARGET_TRIPLE@") +set_default("target_cflags", "@COMPILER_RT_TEST_COMPILER_FLAGS@") set_default("host_arch", "@HOST_ARCH@") set_default("target_arch", "@HOST_ARCH@") set_default("host_os", "@HOST_OS@") @@ -22,6 +23,7 @@ set_default("python_executable", "@PYTHON_EXECUTABLE@") set_default("compiler_rt_debug", @COMPILER_RT_DEBUG_PYBOOL@) set_default("compiler_rt_libdir", "@COMPILER_RT_LIBRARY_OUTPUT_DIR@") +set_default("emulator", "@COMPILER_RT_EMULATOR@") # LLVM tools dir can be passed in lit parameters, so try to # apply substitution. Index: test/profile/instrprof-basic.c =================================================================== --- test/profile/instrprof-basic.c +++ test/profile/instrprof-basic.c @@ -1,5 +1,5 @@ // RUN: %clang_profgen -o %t -O3 %s -// RUN: env LLVM_PROFILE_FILE=%t.profraw %t +// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t // RUN: llvm-profdata merge -o %t.profdata %t.profraw // RUN: %clang_profuse=%t.profdata -o - -S -emit-llvm %s | FileCheck %s Index: test/profile/lit.cfg =================================================================== --- test/profile/lit.cfg +++ test/profile/lit.cfg @@ -27,10 +27,16 @@ # Test suffixes. config.suffixes = ['.c', '.cc', '.cpp', '.m', '.mm', '.ll', '.test'] +# Clang flags. +clang_cflags = [config.target_cflags] + +def build_invocation(compile_flags): + return " " + " ".join([config.clang] + compile_flags) + " " + # Add clang substitutions. -config.substitutions.append( ("%clang ", config.clang + " ") ) -config.substitutions.append( ("%clang_profgen ", config.clang + " -fprofile-instr-generate ") ) -config.substitutions.append( ("%clang_profuse=", config.clang + " -fprofile-instr-use=") ) +config.substitutions.append( ("%clang ", build_invocation([])) ) +config.substitutions.append( ("%clang_profgen ", build_invocation(clang_cflags) + " -fprofile-instr-generate ") ) +config.substitutions.append( ("%clang_profuse=", build_invocation(clang_cflags) + " -fprofile-instr-use=") ) # Profile tests are currently supported on Linux and Darwin only. if config.host_os not in ['Linux', 'Darwin']: