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-07-30 02:12:45 +08:00
|
|
|
import re
|
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
|
|
|
|
2017-03-30 21:33:22 +08:00
|
|
|
|
|
|
|
# Choose between lit's internal shell pipeline runner and a real shell. If
|
|
|
|
# LIT_USE_INTERNAL_SHELL is in the environment, we use that as an override.
|
|
|
|
use_lit_shell = os.environ.get("LIT_USE_INTERNAL_SHELL")
|
|
|
|
if use_lit_shell:
|
|
|
|
# 0 is external, "" is default, and everything else is internal.
|
|
|
|
execute_external = (use_lit_shell == "0")
|
|
|
|
else:
|
|
|
|
# Otherwise we default to internal on Windows and external elsewhere, as
|
|
|
|
# bash on Windows is usually very slow.
|
|
|
|
execute_external = (not sys.platform in ['win32'])
|
|
|
|
|
|
|
|
# Setup test format.
|
2012-07-31 23:43:11 +08:00
|
|
|
config.test_format = lit.formats.ShTest(execute_external)
|
2015-08-13 07:49:52 +08:00
|
|
|
if execute_external:
|
|
|
|
config.available_features.add('shell')
|
2012-07-31 23:43:11 +08:00
|
|
|
|
|
|
|
# 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"]
|
2015-08-06 06:48:26 +08:00
|
|
|
if platform.system() == 'Windows':
|
|
|
|
config.debug_info_flags.append("-gcodeview")
|
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
|
|
|
|
2017-09-16 13:13:56 +08:00
|
|
|
# BFD linker in 64-bit android toolchains fails to find libm.so, which is a
|
|
|
|
# transitive shared library dependency (via asan runtime).
|
|
|
|
if config.android:
|
|
|
|
config.target_cflags += " -lm"
|
|
|
|
|
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',
|
[compiler-rt][XRay] Initial per-thread inmemory logging implementation
Depends on D21612 which implements the building blocks for the compiler-rt
implementation of the XRay runtime. We use a naive in-memory log of fixed-size
entries that get written out to a log file when the buffers are full, and when
the thread exits.
This implementation lays some foundations on to allowing for more complex XRay
records to be written to the log in subsequent changes. It also defines the format
that the function call accounting tool in D21987 will start building upon.
Once D21987 lands, we should be able to start defining more tests using that tool
once the function call accounting tool becomes part of the llvm distribution.
Reviewers: echristo, kcc, rnk, eugenis, majnemer, rSerge
Subscribers: sdardis, rSerge, dberris, tberghammer, danalbert, srhines, majnemer, llvm-commits, mehdi_amini
Differential Revision: https://reviews.llvm.org/D21982
llvm-svn: 279805
2016-08-26 14:39:33 +08:00
|
|
|
'LIBCLANG_CODE_COMPLETION_LOGGING',
|
|
|
|
'XRAY_OPTIONS']
|
2012-07-31 23:43:11 +08:00
|
|
|
# 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.
|
2017-09-16 06:10:46 +08:00
|
|
|
if (not config.llvm_tools_dir) or (not os.path.exists(config.llvm_tools_dir)):
|
|
|
|
lit_config.fatal("Invalid llvm_tools_dir config attribute: %r" % config.llvm_tools_dir)
|
|
|
|
path = os.path.pathsep.join((config.llvm_tools_dir, config.environment['PATH']))
|
2012-08-07 19:00:19 +08:00
|
|
|
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']
|
|
|
|
|
2016-01-28 08:35:17 +08:00
|
|
|
if re.match(r'^x86_64.*-linux', config.target_triple):
|
|
|
|
config.available_features.add("x86_64-linux")
|
|
|
|
|
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.
|
2017-04-27 02:59:22 +08:00
|
|
|
if config.emulator:
|
|
|
|
config.substitutions.append( ('%run', config.emulator) )
|
2017-04-27 04:38:24 +08:00
|
|
|
config.substitutions.append( ('%env ', "env ") )
|
2017-04-28 12:55:35 +08:00
|
|
|
config.compile_wrapper = ""
|
2017-04-27 02:59:22 +08:00
|
|
|
elif config.ios:
|
2017-04-28 12:55:35 +08:00
|
|
|
config.available_features.add('ios')
|
2017-04-27 02:59:22 +08:00
|
|
|
device_id_env = "SANITIZER_IOSSIM_TEST_DEVICE_IDENTIFIER" if config.iossim else "SANITIZER_IOS_TEST_DEVICE_IDENTIFIER"
|
|
|
|
if device_id_env in os.environ: config.environment[device_id_env] = os.environ[device_id_env]
|
|
|
|
ios_commands_dir = os.path.join(config.compiler_rt_src_root, "test", "sanitizer_common", "ios_commands")
|
|
|
|
run_wrapper = os.path.join(ios_commands_dir, "iossim_run.py" if config.iossim else "ios_run.py")
|
|
|
|
config.substitutions.append(('%run', run_wrapper))
|
2017-04-27 04:38:24 +08:00
|
|
|
env_wrapper = os.path.join(ios_commands_dir, "iossim_env.py" if config.iossim else "ios_env.py")
|
|
|
|
config.substitutions.append(('%env ', env_wrapper + " "))
|
2017-04-28 12:55:35 +08:00
|
|
|
compile_wrapper = os.path.join(ios_commands_dir, "iossim_compile.py" if config.iossim else "ios_compile.py")
|
|
|
|
config.compile_wrapper = compile_wrapper
|
2017-09-16 13:13:56 +08:00
|
|
|
elif config.android:
|
|
|
|
config.available_features.add('android')
|
|
|
|
compile_wrapper = os.path.join(config.compiler_rt_src_root, "test", "sanitizer_common", "android_commands", "android_compile.py") + " "
|
|
|
|
config.compile_wrapper = compile_wrapper
|
|
|
|
config.substitutions.append( ('%run', "") )
|
|
|
|
config.substitutions.append( ('%env ', "env ") )
|
2017-04-27 02:59:22 +08:00
|
|
|
else:
|
|
|
|
config.substitutions.append( ('%run', "") )
|
2017-04-27 04:38:24 +08:00
|
|
|
config.substitutions.append( ('%env ', "env ") )
|
2017-04-28 12:55:35 +08:00
|
|
|
config.compile_wrapper = ""
|
2014-05-01 05:32:30 +08:00
|
|
|
|
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)))
|
|
|
|
|
2016-10-06 17:58:11 +08:00
|
|
|
# Define %arch to check for architecture-dependent output.
|
|
|
|
config.substitutions.append( ('%arch', (config.host_arch)))
|
|
|
|
|
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.
|
2016-06-25 08:24:22 +08:00
|
|
|
config.expect_crash = "not KillTheDoctor "
|
2015-07-03 06:08:38 +08:00
|
|
|
else:
|
2016-06-25 08:24:22 +08:00
|
|
|
config.expect_crash = "not --crash "
|
|
|
|
|
|
|
|
config.substitutions.append( ("%expect_crash ", config.expect_crash) )
|
2015-07-03 06:08:38 +08:00
|
|
|
|
2016-02-23 09:58:56 +08:00
|
|
|
target_arch = getattr(config, 'target_arch', None)
|
|
|
|
if target_arch:
|
|
|
|
config.available_features.add(target_arch + '-target-arch')
|
2017-08-29 04:30:12 +08:00
|
|
|
if target_arch in ['x86_64', 'i386']:
|
2016-02-23 09:58:56 +08:00
|
|
|
config.available_features.add('x86-target-arch')
|
2016-08-28 00:06:36 +08:00
|
|
|
config.available_features.add(target_arch + '-' + config.host_os.lower())
|
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')
|
|
|
|
|
2015-08-11 08:33:07 +08:00
|
|
|
if config.has_lld:
|
2017-04-22 02:11:23 +08:00
|
|
|
config.available_features.add('lld-available')
|
|
|
|
|
|
|
|
if config.use_lld:
|
2015-08-11 08:33:07 +08:00
|
|
|
config.available_features.add('lld')
|
|
|
|
|
2016-01-23 04:26:10 +08:00
|
|
|
if config.can_symbolize:
|
|
|
|
config.available_features.add('can-symbolize')
|
|
|
|
|
2014-06-10 22:22:00 +08:00
|
|
|
lit.util.usePlatformSdkOnDarwin(config, lit_config)
|
2015-05-20 07:50:13 +08:00
|
|
|
|
[sanitizer] On OS X, verify that interceptors work and abort if not, take 2
On OS X 10.11+, we have "automatic interceptors", so we don't need to use DYLD_INSERT_LIBRARIES when launching instrumented programs. However, non-instrumented programs that load TSan late (e.g. via dlopen) are currently broken, as TSan will still try to initialize, but the program will crash/hang at random places (because the interceptors don't work). This patch adds an explicit check that interceptors are working, and if not, it aborts and prints out an error message suggesting to explicitly use DYLD_INSERT_LIBRARIES.
TSan unit tests run with a statically linked runtime, where interceptors don't work. To avoid aborting the process in this case, the patch replaces `DisableReexec()` with a weak `ReexecDisabled()` function which is defined to return true in unit tests.
Differential Revision: http://reviews.llvm.org/D18212
llvm-svn: 263695
2016-03-17 16:37:25 +08:00
|
|
|
if config.host_os == 'Darwin':
|
2017-03-17 06:35:34 +08:00
|
|
|
osx_version = (10, 0, 0)
|
2016-03-30 02:54:29 +08:00
|
|
|
try:
|
|
|
|
osx_version = subprocess.check_output(["sw_vers", "-productVersion"])
|
|
|
|
osx_version = tuple(int(x) for x in osx_version.split('.'))
|
2017-03-17 06:35:34 +08:00
|
|
|
if len(osx_version) == 2: osx_version = (osx_version[0], osx_version[1], 0)
|
2016-03-30 02:54:29 +08:00
|
|
|
if osx_version >= (10, 11):
|
|
|
|
config.available_features.add('osx-autointerception')
|
|
|
|
config.available_features.add('osx-ld64-live_support')
|
2016-03-31 06:21:58 +08:00
|
|
|
else:
|
|
|
|
# The ASAN initialization-bug.cc test should XFAIL on OS X systems
|
|
|
|
# older than El Capitan. By marking the test as being unsupported with
|
|
|
|
# this "feature", we can pass the test on newer OS X versions and other
|
|
|
|
# platforms.
|
|
|
|
config.available_features.add('osx-no-ld64-live_support')
|
2016-03-30 02:54:29 +08:00
|
|
|
except:
|
|
|
|
pass
|
[sanitizer] On OS X, verify that interceptors work and abort if not, take 2
On OS X 10.11+, we have "automatic interceptors", so we don't need to use DYLD_INSERT_LIBRARIES when launching instrumented programs. However, non-instrumented programs that load TSan late (e.g. via dlopen) are currently broken, as TSan will still try to initialize, but the program will crash/hang at random places (because the interceptors don't work). This patch adds an explicit check that interceptors are working, and if not, it aborts and prints out an error message suggesting to explicitly use DYLD_INSERT_LIBRARIES.
TSan unit tests run with a statically linked runtime, where interceptors don't work. To avoid aborting the process in this case, the patch replaces `DisableReexec()` with a weak `ReexecDisabled()` function which is defined to return true in unit tests.
Differential Revision: http://reviews.llvm.org/D18212
llvm-svn: 263695
2016-03-17 16:37:25 +08:00
|
|
|
|
2017-03-17 06:35:34 +08:00
|
|
|
config.darwin_osx_version = osx_version
|
|
|
|
|
2017-01-07 05:45:05 +08:00
|
|
|
# Detect x86_64h
|
|
|
|
try:
|
|
|
|
output = subprocess.check_output(["sysctl", "hw.cpusubtype"])
|
|
|
|
output_re = re.match("^hw.cpusubtype: ([0-9]+)$", output)
|
|
|
|
if output_re:
|
|
|
|
cpu_subtype = int(output_re.group(1))
|
|
|
|
if cpu_subtype == 8: # x86_64h
|
|
|
|
config.available_features.add('x86_64h')
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
2016-11-22 05:48:25 +08:00
|
|
|
config.substitutions.append( ("%macos_min_target_10_11", "-mmacosx-version-min=10.11") )
|
|
|
|
else:
|
|
|
|
config.substitutions.append( ("%macos_min_target_10_11", "") )
|
|
|
|
|
2017-09-16 06:10:46 +08:00
|
|
|
sancovcc_path = os.path.join(config.llvm_tools_dir, "sancov")
|
2016-01-28 07:51:36 +08:00
|
|
|
if os.path.exists(sancovcc_path):
|
|
|
|
config.available_features.add("has_sancovcc")
|
|
|
|
config.substitutions.append( ("%sancovcc ", sancovcc_path) )
|
|
|
|
|
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():
|
2017-04-22 02:11:23 +08:00
|
|
|
if config.use_lld:
|
|
|
|
return True
|
|
|
|
|
2015-05-20 07:50:13 +08:00
|
|
|
if not os.path.exists(os.path.join(config.llvm_shlib_dir, 'LLVMgold.so')):
|
|
|
|
return False
|
|
|
|
|
2016-11-12 01:46:51 +08:00
|
|
|
ld_cmd = subprocess.Popen([config.gold_executable, '--help'], stdout = subprocess.PIPE, env={'LANG': 'C'})
|
2015-05-20 07:50:13 +08:00
|
|
|
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():
|
2015-08-07 02:37:54 +08:00
|
|
|
return os.path.exists(os.path.join(config.llvm_tools_dir, 'lld-link.exe'))
|
2015-07-09 06:10:34 +08:00
|
|
|
|
|
|
|
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 = []
|
2017-04-22 02:11:23 +08:00
|
|
|
if config.use_lld:
|
|
|
|
config.lto_flags = ["-fuse-ld=lld"]
|
|
|
|
else:
|
|
|
|
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 = []
|
2017-03-23 03:49:29 +08:00
|
|
|
# FIXME: Remove -nopdb when PDB writing is ready.
|
|
|
|
config.lto_flags = ["-fuse-ld=lld -Wl,-nopdb"]
|
2015-05-20 07:50:13 +08:00
|
|
|
else:
|
|
|
|
config.lto_supported = False
|
2015-07-30 02:12:45 +08:00
|
|
|
|
2016-09-14 22:09:18 +08:00
|
|
|
if config.lto_supported:
|
|
|
|
config.available_features.add('lto')
|
2017-04-22 02:11:23 +08:00
|
|
|
if config.use_thinlto:
|
|
|
|
config.available_features.add('thinlto')
|
|
|
|
config.lto_flags += ["-flto=thin"]
|
|
|
|
else:
|
|
|
|
config.lto_flags += ["-flto"]
|
2016-09-14 22:09:18 +08:00
|
|
|
|
2015-07-30 02:12:45 +08:00
|
|
|
# Ask llvm-config about assertion mode.
|
|
|
|
try:
|
|
|
|
llvm_config_cmd = subprocess.Popen(
|
|
|
|
[os.path.join(config.llvm_tools_dir, 'llvm-config'), '--assertion-mode'],
|
|
|
|
stdout = subprocess.PIPE,
|
|
|
|
env=config.environment)
|
|
|
|
except OSError:
|
2017-09-16 06:10:46 +08:00
|
|
|
print("Could not find llvm-config in " + config.llvm_tools_dir)
|
2015-07-30 02:12:45 +08:00
|
|
|
exit(42)
|
|
|
|
|
|
|
|
if re.search(r'ON', llvm_config_cmd.stdout.read().decode('ascii')):
|
|
|
|
config.available_features.add('asserts')
|
|
|
|
llvm_config_cmd.wait()
|
2015-09-03 04:45:36 +08:00
|
|
|
|
|
|
|
# Sanitizer tests tend to be flaky on Windows due to PR24554, so add some
|
|
|
|
# retries. We don't do this on otther platforms because it's slower.
|
|
|
|
if platform.system() == 'Windows':
|
|
|
|
config.test_retry_attempts = 2
|
2017-01-20 08:25:01 +08:00
|
|
|
|
|
|
|
# Only run up to 3 64-bit sanitized processes simultaneously on Darwin.
|
|
|
|
# Using more scales badly and hogs the system due to inefficient handling
|
|
|
|
# of large mmap'd regions (terabytes) by the kernel.
|
|
|
|
if platform.system() == 'Darwin':
|
|
|
|
lit_config.parallelism_groups["darwin-64bit-sanitizer"] = 3
|