diff options
Diffstat (limited to 'test/lit.common.cfg')
-rw-r--r-- | test/lit.common.cfg | 52 |
1 files changed, 51 insertions, 1 deletions
diff --git a/test/lit.common.cfg b/test/lit.common.cfg index 0a551862c32b..02a3cd613029 100644 --- a/test/lit.common.cfg +++ b/test/lit.common.cfg @@ -5,6 +5,7 @@ # It is mostly copied from lit.cfg used by Clang. import os import platform +import subprocess import lit.formats import lit.util @@ -37,7 +38,9 @@ else: config.available_features.add(compiler_id) # Clear some environment variables that might affect Clang. -possibly_dangerous_env_vars = ['COMPILER_PATH', 'RC_DEBUG_OPTIONS', +possibly_dangerous_env_vars = ['ASAN_OPTIONS', 'DFSAN_OPTIONS', 'LSAN_OPTIONS', + 'MSAN_OPTIONS', 'UBSAN_OPTIONS', + 'COMPILER_PATH', 'RC_DEBUG_OPTIONS', 'CINDEXTEST_PREAMBLE_FILE', 'LIBRARY_PATH', 'CPATH', 'C_INCLUDE_PATH', 'CPLUS_INCLUDE_PATH', 'OBJC_INCLUDE_PATH', 'OBJCPLUS_INCLUDE_PATH', @@ -77,6 +80,15 @@ config.substitutions.append( ('%run', config.emulator) ) # Define CHECK-%os to check for OS-dependent output. config.substitutions.append( ('CHECK-%os', ("CHECK-" + config.host_os))) +if config.host_os == 'Windows': + # FIXME: This isn't quite right. Specifically, it will succeed if the program + # does not crash but exits with a non-zero exit code. We ought to merge + # KillTheDoctor and not --crash to make the latter more useful and remove the + # need for this substitution. + config.substitutions.append( ("%expect_crash ", "not KillTheDoctor ") ) +else: + config.substitutions.append( ("%expect_crash ", "not --crash ") ) + # Add supported compiler_rt architectures to a list of available features. compiler_rt_arch = getattr(config, 'compiler_rt_arch', None) if compiler_rt_arch: @@ -87,4 +99,42 @@ compiler_rt_debug = getattr(config, 'compiler_rt_debug', False) if not compiler_rt_debug: config.available_features.add('compiler-rt-optimized') +sanitizer_can_use_cxxabi = getattr(config, 'sanitizer_can_use_cxxabi', True) +if sanitizer_can_use_cxxabi: + config.available_features.add('cxxabi') + lit.util.usePlatformSdkOnDarwin(config, lit_config) + +def is_darwin_lto_supported(): + return os.path.exists(os.path.join(config.llvm_shlib_dir, 'libLTO.dylib')) + +def is_linux_lto_supported(): + if not os.path.exists(os.path.join(config.llvm_shlib_dir, 'LLVMgold.so')): + return False + + ld_cmd = subprocess.Popen([config.gold_executable, '--help'], stdout = subprocess.PIPE) + ld_out = ld_cmd.stdout.read().decode() + ld_cmd.wait() + + if not '-plugin' in ld_out: + return False + + return True + +def is_windows_lto_supported(): + return os.path.exists(os.path.join(config.llvm_tools_dir, 'lld-link2.exe')) + +if config.host_os == 'Darwin' and is_darwin_lto_supported(): + config.lto_supported = True + config.lto_launch = ["env", "DYLD_LIBRARY_PATH=" + config.llvm_shlib_dir] + config.lto_flags = [] +elif config.host_os == 'Linux' and is_linux_lto_supported(): + config.lto_supported = True + config.lto_launch = [] + config.lto_flags = ["-fuse-ld=gold"] +elif config.host_os == 'Windows' and is_windows_lto_supported(): + config.lto_supported = True + config.lto_launch = [] + config.lto_flags = ["-fuse-ld=lld-link2"] +else: + config.lto_supported = False |