2012-07-31 23:43:11 +08:00
|
|
|
# -*- Python -*-
|
|
|
|
|
|
|
|
# Configuration file for 'lit' test runner.
|
|
|
|
# This file contains common rules for various compiler-rt testsuites.
|
|
|
|
# It is mostly copied from lit.cfg used by Clang.
|
|
|
|
import os
|
|
|
|
import platform
|
2015-05-20 07:50:13 +08:00
|
|
|
import subprocess
|
2012-07-31 23:43:11 +08:00
|
|
|
|
2013-08-10 06:14:01 +08:00
|
|
|
import lit.formats
|
2014-06-10 22:22:00 +08:00
|
|
|
import lit.util
|
2013-08-10 06:14:01 +08:00
|
|
|
|
2012-07-31 23:43:11 +08:00
|
|
|
# Setup test format
|
|
|
|
execute_external = (platform.system() != 'Windows'
|
2013-08-10 06:14:01 +08:00
|
|
|
or lit_config.getBashPath() not in [None, ""])
|
2012-07-31 23:43:11 +08:00
|
|
|
config.test_format = lit.formats.ShTest(execute_external)
|
|
|
|
|
|
|
|
# Setup clang binary.
|
2014-02-19 23:13:14 +08:00
|
|
|
compiler_path = getattr(config, 'clang', None)
|
|
|
|
if (not compiler_path) or (not os.path.exists(compiler_path)):
|
|
|
|
lit_config.fatal("Can't find compiler on path %r" % compiler_path)
|
|
|
|
|
|
|
|
compiler_id = getattr(config, 'compiler_id', None)
|
|
|
|
if compiler_id == "Clang":
|
2014-05-15 03:10:43 +08:00
|
|
|
if platform.system() != 'Windows':
|
|
|
|
config.cxx_mode_flags = ["--driver-mode=g++"]
|
|
|
|
else:
|
|
|
|
config.cxx_mode_flags = []
|
2014-10-01 07:07:45 +08:00
|
|
|
# We assume that sanitizers should provide good enough error
|
|
|
|
# reports and stack traces even with minimal debug info.
|
|
|
|
config.debug_info_flags = ["-gline-tables-only"]
|
2014-02-19 23:13:14 +08:00
|
|
|
elif compiler_id == 'GNU':
|
|
|
|
config.cxx_mode_flags = ["-x c++"]
|
2014-09-06 06:05:32 +08:00
|
|
|
config.debug_info_flags = ["-g"]
|
2014-02-19 23:13:14 +08:00
|
|
|
else:
|
|
|
|
lit_config.fatal("Unsupported compiler id: %r" % compiler_id)
|
2014-05-17 04:12:27 +08:00
|
|
|
# Add compiler ID to the list of available features.
|
|
|
|
config.available_features.add(compiler_id)
|
2012-07-31 23:43:11 +08:00
|
|
|
|
|
|
|
# Clear some environment variables that might affect Clang.
|
2015-06-04 08:12:55 +08:00
|
|
|
possibly_dangerous_env_vars = ['ASAN_OPTIONS', 'DFSAN_OPTIONS', 'LSAN_OPTIONS',
|
|
|
|
'MSAN_OPTIONS', 'UBSAN_OPTIONS',
|
|
|
|
'COMPILER_PATH', 'RC_DEBUG_OPTIONS',
|
2012-07-31 23:43:11 +08:00
|
|
|
'CINDEXTEST_PREAMBLE_FILE', 'LIBRARY_PATH',
|
|
|
|
'CPATH', 'C_INCLUDE_PATH', 'CPLUS_INCLUDE_PATH',
|
|
|
|
'OBJC_INCLUDE_PATH', 'OBJCPLUS_INCLUDE_PATH',
|
|
|
|
'LIBCLANG_TIMING', 'LIBCLANG_OBJTRACKING',
|
|
|
|
'LIBCLANG_LOGGING', 'LIBCLANG_BGPRIO_INDEX',
|
|
|
|
'LIBCLANG_BGPRIO_EDIT', 'LIBCLANG_NOTHREADS',
|
|
|
|
'LIBCLANG_RESOURCE_USAGE',
|
|
|
|
'LIBCLANG_CODE_COMPLETION_LOGGING']
|
|
|
|
# Clang/Win32 may refer to %INCLUDE%. vsvarsall.bat sets it.
|
|
|
|
if platform.system() != 'Windows':
|
|
|
|
possibly_dangerous_env_vars.append('INCLUDE')
|
|
|
|
for name in possibly_dangerous_env_vars:
|
|
|
|
if name in config.environment:
|
|
|
|
del config.environment[name]
|
|
|
|
|
2012-08-07 19:00:19 +08:00
|
|
|
# Tweak PATH to include llvm tools dir.
|
|
|
|
llvm_tools_dir = getattr(config, 'llvm_tools_dir', None)
|
|
|
|
if (not llvm_tools_dir) or (not os.path.exists(llvm_tools_dir)):
|
2013-08-10 06:14:01 +08:00
|
|
|
lit_config.fatal("Invalid llvm_tools_dir config attribute: %r" % llvm_tools_dir)
|
2012-08-07 19:00:19 +08:00
|
|
|
path = os.path.pathsep.join((llvm_tools_dir, config.environment['PATH']))
|
|
|
|
config.environment['PATH'] = path
|
|
|
|
|
2014-05-15 03:10:43 +08:00
|
|
|
# Help MSVS link.exe find the standard libraries.
|
2015-02-21 07:35:19 +08:00
|
|
|
# Make sure we only try to use it when targetting Windows.
|
|
|
|
if platform.system() == 'Windows' and '-win' in config.target_triple:
|
2014-05-15 03:10:43 +08:00
|
|
|
config.environment['LIB'] = os.environ['LIB']
|
|
|
|
|
2012-07-31 23:43:11 +08:00
|
|
|
# Use ugly construction to explicitly prohibit "clang", "clang++" etc.
|
|
|
|
# in RUN lines.
|
|
|
|
config.substitutions.append(
|
|
|
|
(' clang', """\n\n*** Do not use 'clangXXX' in tests,
|
|
|
|
instead define '%clangXXX' substitution in lit config. ***\n\n""") )
|
2013-05-21 16:22:03 +08:00
|
|
|
|
2014-05-01 05:32:30 +08:00
|
|
|
# Allow tests to be executed on a simulator or remotely.
|
|
|
|
config.substitutions.append( ('%run', config.emulator) )
|
|
|
|
|
2014-08-28 17:25:06 +08:00
|
|
|
# Define CHECK-%os to check for OS-dependent output.
|
|
|
|
config.substitutions.append( ('CHECK-%os', ("CHECK-" + config.host_os)))
|
|
|
|
|
2015-07-03 06:08:38 +08:00
|
|
|
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 ") )
|
|
|
|
|
2013-05-21 16:22:03 +08:00
|
|
|
# Add supported compiler_rt architectures to a list of available features.
|
|
|
|
compiler_rt_arch = getattr(config, 'compiler_rt_arch', None)
|
|
|
|
if compiler_rt_arch:
|
|
|
|
for arch in compiler_rt_arch.split(";"):
|
|
|
|
config.available_features.add(arch + "-supported-target")
|
2013-10-26 07:03:34 +08:00
|
|
|
|
|
|
|
compiler_rt_debug = getattr(config, 'compiler_rt_debug', False)
|
|
|
|
if not compiler_rt_debug:
|
|
|
|
config.available_features.add('compiler-rt-optimized')
|
2014-06-10 22:22:00 +08:00
|
|
|
|
2015-06-25 08:57:42 +08:00
|
|
|
sanitizer_can_use_cxxabi = getattr(config, 'sanitizer_can_use_cxxabi', True)
|
|
|
|
if sanitizer_can_use_cxxabi:
|
|
|
|
config.available_features.add('cxxabi')
|
|
|
|
|
2014-06-10 22:22:00 +08:00
|
|
|
lit.util.usePlatformSdkOnDarwin(config, lit_config)
|
2015-05-20 07:50:13 +08:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2015-07-09 06:10:34 +08:00
|
|
|
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():
|
2015-05-20 07:50:13 +08:00
|
|
|
config.lto_supported = True
|
|
|
|
config.lto_launch = ["env", "DYLD_LIBRARY_PATH=" + config.llvm_shlib_dir]
|
|
|
|
config.lto_flags = []
|
2015-07-09 06:10:34 +08:00
|
|
|
elif config.host_os == 'Linux' and is_linux_lto_supported():
|
2015-05-20 07:50:13 +08:00
|
|
|
config.lto_supported = True
|
|
|
|
config.lto_launch = []
|
|
|
|
config.lto_flags = ["-fuse-ld=gold"]
|
2015-07-09 06:10:34 +08:00
|
|
|
elif config.host_os == 'Windows' and is_windows_lto_supported():
|
|
|
|
config.lto_supported = True
|
|
|
|
config.lto_launch = []
|
|
|
|
config.lto_flags = ["-fuse-ld=lld-link2"]
|
2015-05-20 07:50:13 +08:00
|
|
|
else:
|
|
|
|
config.lto_supported = False
|