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.
|
2019-06-28 04:56:04 +08:00
|
|
|
# It is mostly copied from lit.cfg.py used by Clang.
|
2012-07-31 23:43:11 +08:00
|
|
|
import os
|
|
|
|
import platform
|
2015-07-30 02:12:45 +08:00
|
|
|
import re
|
2015-05-20 07:50:13 +08:00
|
|
|
import subprocess
|
2018-06-20 21:33:42 +08:00
|
|
|
import json
|
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
|
|
|
|
2021-02-24 01:22:01 +08:00
|
|
|
# Get shlex.quote if available (added in 3.3), and fall back to pipes.quote if
|
|
|
|
# it's not available.
|
|
|
|
try:
|
|
|
|
import shlex
|
|
|
|
sh_quote = shlex.quote
|
|
|
|
except:
|
|
|
|
import pipes
|
|
|
|
sh_quote = pipes.quote
|
|
|
|
|
2021-05-01 07:24:33 +08:00
|
|
|
def find_compiler_libdir():
|
|
|
|
"""
|
|
|
|
Returns the path to library resource directory used
|
|
|
|
by the compiler.
|
|
|
|
"""
|
|
|
|
if config.compiler_id != 'Clang':
|
|
|
|
lit_config.warning(f'Determining compiler\'s runtime directory is not supported for {config.compiler_id}')
|
|
|
|
# TODO: Support other compilers.
|
|
|
|
return None
|
|
|
|
def get_path_from_clang(args, allow_failure):
|
|
|
|
clang_cmd = [
|
|
|
|
config.clang.strip(),
|
|
|
|
f'--target={config.target_triple}',
|
|
|
|
]
|
|
|
|
clang_cmd.extend(args)
|
|
|
|
path = None
|
|
|
|
try:
|
|
|
|
result = subprocess.run(
|
|
|
|
clang_cmd,
|
|
|
|
stdout=subprocess.PIPE,
|
|
|
|
stderr=subprocess.PIPE,
|
|
|
|
check=True
|
|
|
|
)
|
|
|
|
path = result.stdout.decode().strip()
|
|
|
|
except subprocess.CalledProcessError as e:
|
|
|
|
msg = f'Failed to run {clang_cmd}\nrc:{e.returncode}\nstdout:{e.stdout}\ne.stderr{e.stderr}'
|
|
|
|
if allow_failure:
|
|
|
|
lit_config.warning(msg)
|
|
|
|
else:
|
|
|
|
lit_config.fatal(msg)
|
2021-05-16 02:09:34 +08:00
|
|
|
return path, clang_cmd
|
2021-05-01 07:24:33 +08:00
|
|
|
|
|
|
|
# Try using `-print-runtime-dir`. This is only supported by very new versions of Clang.
|
|
|
|
# so allow failure here.
|
2021-09-16 00:07:47 +08:00
|
|
|
runtime_dir, clang_cmd = get_path_from_clang(shlex.split(config.target_cflags)
|
|
|
|
+ ['-print-runtime-dir'],
|
|
|
|
allow_failure=True)
|
2021-05-01 07:24:33 +08:00
|
|
|
if runtime_dir:
|
|
|
|
if os.path.exists(runtime_dir):
|
|
|
|
return os.path.realpath(runtime_dir)
|
2021-05-16 02:09:34 +08:00
|
|
|
# TODO(dliew): This should be a fatal error but it seems to trip the `llvm-clang-win-x-aarch64`
|
|
|
|
# bot which is likely misconfigured
|
|
|
|
lit_config.warning(
|
|
|
|
f'Path reported by clang does not exist: \"{runtime_dir}\". '
|
|
|
|
f'This path was found by running {clang_cmd}.'
|
|
|
|
)
|
|
|
|
return None
|
2021-05-01 07:24:33 +08:00
|
|
|
|
|
|
|
# Fall back for older AppleClang that doesn't support `-print-runtime-dir`
|
|
|
|
# Note `-print-file-name=<path to compiler-rt lib>` was broken for Apple
|
|
|
|
# platforms so we can't use that approach here (see https://reviews.llvm.org/D101682).
|
|
|
|
if config.host_os == 'Darwin':
|
2021-05-16 02:09:34 +08:00
|
|
|
lib_dir, _ = get_path_from_clang(['-print-file-name=lib'], allow_failure=False)
|
2021-05-01 07:24:33 +08:00
|
|
|
runtime_dir = os.path.join(lib_dir, 'darwin')
|
|
|
|
if not os.path.exists(runtime_dir):
|
|
|
|
lit_config.fatal(f'Path reported by clang does not exist: {runtime_dir}')
|
|
|
|
return os.path.realpath(runtime_dir)
|
|
|
|
|
|
|
|
lit_config.warning('Failed to determine compiler\'s runtime directory')
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
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'])
|
|
|
|
|
2020-07-14 16:37:27 +08:00
|
|
|
# Allow expanding substitutions that are based on other substitutions
|
|
|
|
config.recursiveExpansionLimit = 10
|
|
|
|
|
2017-03-30 21:33:22 +08:00
|
|
|
# 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
|
|
|
|
2014-02-19 23:13:14 +08:00
|
|
|
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':
|
2018-02-27 06:55:33 +08:00
|
|
|
# On Windows, use CodeView with column info instead of DWARF. Both VS and
|
|
|
|
# windbg do not behave well when column info is enabled, but users have
|
|
|
|
# requested it because it makes ASan reports more precise.
|
2015-08-06 06:48:26 +08:00
|
|
|
config.debug_info_flags.append("-gcodeview")
|
2018-02-27 06:55:33 +08:00
|
|
|
config.debug_info_flags.append("-gcolumn-info")
|
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
|
|
|
|
2021-09-16 00:07:47 +08:00
|
|
|
# When LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=on, the initial value of
|
|
|
|
# config.compiler_rt_libdir (COMPILER_RT_RESOLVED_LIBRARY_OUTPUT_DIR) has the
|
|
|
|
# triple as the trailing path component. The value is incorrect for -m32/-m64.
|
|
|
|
# Adjust config.compiler_rt accordingly.
|
|
|
|
if config.enable_per_target_runtime_dir:
|
|
|
|
if '-m32' in shlex.split(config.target_cflags):
|
|
|
|
config.compiler_rt_libdir = re.sub(r'/x86_64(?=-[^/]+$)', '/i386', config.compiler_rt_libdir)
|
|
|
|
elif '-m64' in shlex.split(config.target_cflags):
|
|
|
|
config.compiler_rt_libdir = re.sub(r'/i386(?=-[^/]+$)', '/x86_64', config.compiler_rt_libdir)
|
|
|
|
|
2021-05-01 07:24:33 +08:00
|
|
|
# Ask the compiler for the path to libraries it is going to use. If this
|
|
|
|
# doesn't match config.compiler_rt_libdir then it means we might be testing the
|
|
|
|
# compiler's own runtime libraries rather than the ones we just built.
|
|
|
|
# Warn about about this and handle appropriately.
|
|
|
|
compiler_libdir = find_compiler_libdir()
|
|
|
|
if compiler_libdir:
|
|
|
|
compiler_rt_libdir_real = os.path.realpath(config.compiler_rt_libdir)
|
|
|
|
if compiler_libdir != compiler_rt_libdir_real:
|
|
|
|
lit_config.warning(
|
|
|
|
'Compiler lib dir != compiler-rt lib dir\n'
|
|
|
|
f'Compiler libdir: "{compiler_libdir}"\n'
|
|
|
|
f'compiler-rt libdir: "{compiler_rt_libdir_real}"')
|
|
|
|
if config.test_standalone_build_libs:
|
|
|
|
# Use just built runtime libraries, i.e. the the libraries this built just built.
|
|
|
|
if not config.test_suite_supports_overriding_runtime_lib_path:
|
|
|
|
# Test suite doesn't support this configuration.
|
2021-05-16 01:52:10 +08:00
|
|
|
# TODO(dliew): This should be an error but it seems several bots are
|
|
|
|
# testing incorrectly and having this as an error breaks them.
|
|
|
|
lit_config.warning(
|
2021-05-01 07:24:33 +08:00
|
|
|
'COMPILER_RT_TEST_STANDALONE_BUILD_LIBS=ON, but this test suite '
|
|
|
|
'does not support testing the just-built runtime libraries '
|
|
|
|
'when the test compiler is configured to use different runtime '
|
|
|
|
'libraries. Either modify this test suite to support this test '
|
|
|
|
'configuration, or set COMPILER_RT_TEST_STANDALONE_BUILD_LIBS=OFF '
|
|
|
|
'to test the runtime libraries included in the compiler instead.'
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
# Use Compiler's resource library directory instead.
|
|
|
|
config.compiler_rt_libdir = compiler_libdir
|
|
|
|
lit_config.note(f'Testing using libraries in "{config.compiler_rt_libdir}"')
|
|
|
|
|
2017-11-13 22:02:27 +08:00
|
|
|
# If needed, add cflag for shadow scale.
|
|
|
|
if config.asan_shadow_scale != '':
|
|
|
|
config.target_cflags += " -mllvm -asan-mapping-scale=" + config.asan_shadow_scale
|
2020-09-04 06:21:20 +08:00
|
|
|
if config.memprof_shadow_scale != '':
|
|
|
|
config.target_cflags += " -mllvm -memprof-mapping-scale=" + config.memprof_shadow_scale
|
2017-11-13 22:02:27 +08:00
|
|
|
|
2020-07-11 01:35:24 +08:00
|
|
|
config.environment = dict(os.environ)
|
|
|
|
|
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']
|
|
|
|
|
2018-07-10 10:02:21 +08:00
|
|
|
config.available_features.add(config.host_os.lower())
|
|
|
|
|
2022-05-21 05:21:58 +08:00
|
|
|
if config.target_triple.startswith("ppc") or config.target_triple.startswith("powerpc"):
|
2022-05-21 04:56:25 +08:00
|
|
|
config.available_features.add("ppc")
|
|
|
|
|
2016-01-28 08:35:17 +08:00
|
|
|
if re.match(r'^x86_64.*-linux', config.target_triple):
|
2018-07-10 10:02:21 +08:00
|
|
|
config.available_features.add("x86_64-linux")
|
2016-01-28 08:35:17 +08:00
|
|
|
|
2020-05-11 02:01:06 +08:00
|
|
|
config.available_features.add("host-byteorder-" + sys.byteorder + "-endian")
|
|
|
|
|
2019-01-29 20:00:01 +08:00
|
|
|
if config.have_zlib == "1":
|
|
|
|
config.available_features.add("zlib")
|
|
|
|
|
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
|
|
|
|
2019-12-15 00:03:48 +08:00
|
|
|
if config.host_os == 'NetBSD':
|
|
|
|
nb_commands_dir = os.path.join(config.compiler_rt_src_root,
|
|
|
|
"test", "sanitizer_common", "netbsd_commands")
|
|
|
|
config.netbsd_noaslr_prefix = ('sh ' +
|
|
|
|
os.path.join(nb_commands_dir, 'run_noaslr.sh'))
|
|
|
|
config.netbsd_nomprotect_prefix = ('sh ' +
|
|
|
|
os.path.join(nb_commands_dir,
|
|
|
|
'run_nomprotect.sh'))
|
|
|
|
config.substitutions.append( ('%run_nomprotect',
|
|
|
|
config.netbsd_nomprotect_prefix) )
|
|
|
|
else:
|
|
|
|
config.substitutions.append( ('%run_nomprotect', '%run') )
|
|
|
|
|
2020-10-14 00:08:19 +08:00
|
|
|
# Copied from libcxx's config.py
|
|
|
|
def get_lit_conf(name, default=None):
|
|
|
|
# Allow overriding on the command line using --param=<name>=<val>
|
|
|
|
val = lit_config.params.get(name, None)
|
|
|
|
if val is None:
|
|
|
|
val = getattr(config, name, None)
|
|
|
|
if val is None:
|
|
|
|
val = default
|
|
|
|
return val
|
|
|
|
|
|
|
|
emulator = get_lit_conf('emulator', None)
|
|
|
|
|
2021-02-24 01:22:01 +08:00
|
|
|
def get_ios_commands_dir():
|
|
|
|
return os.path.join(config.compiler_rt_src_root, "test", "sanitizer_common", "ios_commands")
|
|
|
|
|
2014-05-01 05:32:30 +08:00
|
|
|
# Allow tests to be executed on a simulator or remotely.
|
2020-10-14 00:08:19 +08:00
|
|
|
if emulator:
|
|
|
|
config.substitutions.append( ('%run', emulator) )
|
2017-04-27 04:38:24 +08:00
|
|
|
config.substitutions.append( ('%env ', "env ") )
|
2018-09-17 21:33:44 +08:00
|
|
|
# TODO: Implement `%device_rm` to perform removal of files in the emulator.
|
|
|
|
# For now just make it a no-op.
|
|
|
|
lit_config.warning('%device_rm is not implemented')
|
|
|
|
config.substitutions.append( ('%device_rm', 'echo ') )
|
2017-04-28 12:55:35 +08:00
|
|
|
config.compile_wrapper = ""
|
2018-06-20 21:33:42 +08:00
|
|
|
elif config.host_os == 'Darwin' and config.apple_platform != "osx":
|
|
|
|
# Darwin tests can be targetting macOS, a device or a simulator. All devices
|
|
|
|
# are declared as "ios", even for iOS derivatives (tvOS, watchOS). Similarly,
|
|
|
|
# all simulators are "iossim". See the table below.
|
|
|
|
#
|
|
|
|
# =========================================================================
|
|
|
|
# Target | Feature set
|
|
|
|
# =========================================================================
|
|
|
|
# macOS | darwin
|
|
|
|
# iOS device | darwin, ios
|
|
|
|
# iOS simulator | darwin, ios, iossim
|
|
|
|
# tvOS device | darwin, ios, tvos
|
|
|
|
# tvOS simulator | darwin, ios, iossim, tvos, tvossim
|
|
|
|
# watchOS device | darwin, ios, watchos
|
|
|
|
# watchOS simulator | darwin, ios, iossim, watchos, watchossim
|
|
|
|
# =========================================================================
|
|
|
|
|
|
|
|
ios_or_iossim = "iossim" if config.apple_platform.endswith("sim") else "ios"
|
|
|
|
|
2017-04-28 12:55:35 +08:00
|
|
|
config.available_features.add('ios')
|
2018-09-03 16:40:19 +08:00
|
|
|
device_id_env = "SANITIZER_" + ios_or_iossim.upper() + "_TEST_DEVICE_IDENTIFIER"
|
2018-06-20 21:33:42 +08:00
|
|
|
if ios_or_iossim == "iossim":
|
|
|
|
config.available_features.add('iossim')
|
2018-09-03 16:40:19 +08:00
|
|
|
if device_id_env not in os.environ:
|
|
|
|
lit_config.fatal(
|
|
|
|
'{} must be set in the environment when running iossim tests'.format(
|
|
|
|
device_id_env))
|
2018-06-20 21:33:42 +08:00
|
|
|
if config.apple_platform != "ios" and config.apple_platform != "iossim":
|
|
|
|
config.available_features.add(config.apple_platform)
|
|
|
|
|
2021-02-24 01:22:01 +08:00
|
|
|
ios_commands_dir = get_ios_commands_dir()
|
2018-06-20 21:33:42 +08:00
|
|
|
|
|
|
|
run_wrapper = os.path.join(ios_commands_dir, ios_or_iossim + "_run.py")
|
|
|
|
env_wrapper = os.path.join(ios_commands_dir, ios_or_iossim + "_env.py")
|
|
|
|
compile_wrapper = os.path.join(ios_commands_dir, ios_or_iossim + "_compile.py")
|
|
|
|
prepare_script = os.path.join(ios_commands_dir, ios_or_iossim + "_prepare.py")
|
|
|
|
|
|
|
|
if device_id_env in os.environ:
|
|
|
|
config.environment[device_id_env] = os.environ[device_id_env]
|
2017-04-27 02:59:22 +08:00
|
|
|
config.substitutions.append(('%run', run_wrapper))
|
2017-04-27 04:38:24 +08:00
|
|
|
config.substitutions.append(('%env ', env_wrapper + " "))
|
2018-09-17 21:33:44 +08:00
|
|
|
# Current implementation of %device_rm uses the run_wrapper to do
|
|
|
|
# the work.
|
|
|
|
config.substitutions.append(('%device_rm', '{} rm '.format(run_wrapper)))
|
2017-04-28 12:55:35 +08:00
|
|
|
config.compile_wrapper = compile_wrapper
|
2018-06-20 21:33:42 +08:00
|
|
|
|
2018-09-24 17:30:33 +08:00
|
|
|
try:
|
2020-04-30 05:33:19 +08:00
|
|
|
prepare_output = subprocess.check_output([prepare_script, config.apple_platform, config.clang]).decode().strip()
|
2018-09-24 17:30:33 +08:00
|
|
|
except subprocess.CalledProcessError as e:
|
|
|
|
print("Command failed:")
|
|
|
|
print(e.output)
|
|
|
|
raise e
|
2018-06-20 21:33:42 +08:00
|
|
|
if len(prepare_output) > 0: print(prepare_output)
|
|
|
|
prepare_output_json = prepare_output.split("\n")[-1]
|
|
|
|
prepare_output = json.loads(prepare_output_json)
|
|
|
|
config.environment.update(prepare_output["env"])
|
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 ") )
|
2018-09-17 21:33:44 +08:00
|
|
|
# When running locally %device_rm is a no-op.
|
|
|
|
config.substitutions.append( ('%device_rm', 'echo ') )
|
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
|
|
|
|
2019-04-05 01:25:43 +08:00
|
|
|
libdispatch = getattr(config, 'compiler_rt_intercept_libdispatch', False)
|
2019-03-15 04:59:41 +08:00
|
|
|
if libdispatch:
|
|
|
|
config.available_features.add('libdispatch')
|
2019-03-08 02:15:23 +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')
|
|
|
|
|
2021-09-23 06:25:05 +08:00
|
|
|
if not getattr(config, 'sanitizer_uses_static_cxxabi', False):
|
|
|
|
config.available_features.add('shared_cxxabi')
|
|
|
|
|
2021-10-07 02:09:29 +08:00
|
|
|
if not getattr(config, 'sanitizer_uses_static_unwind', False):
|
|
|
|
config.available_features.add('shared_unwind')
|
|
|
|
|
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')
|
|
|
|
|
2019-06-18 01:45:34 +08:00
|
|
|
if config.gwp_asan:
|
|
|
|
config.available_features.add('gwp_asan')
|
|
|
|
|
2014-06-10 22:22:00 +08:00
|
|
|
lit.util.usePlatformSdkOnDarwin(config, lit_config)
|
2015-05-20 07:50:13 +08:00
|
|
|
|
2020-08-13 06:02:42 +08:00
|
|
|
min_macos_deployment_target_substitutions = [
|
|
|
|
(10, 11),
|
|
|
|
(10, 12),
|
|
|
|
]
|
|
|
|
# TLS requires watchOS 3+
|
|
|
|
config.substitutions.append( ('%darwin_min_target_with_tls_support', '%min_macos_deployment_target=10.12') )
|
2020-02-19 07:43:25 +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:
|
2020-04-30 04:40:58 +08:00
|
|
|
osx_version = subprocess.check_output(["sw_vers", "-productVersion"],
|
|
|
|
universal_newlines=True)
|
2016-03-30 02:54:29 +08:00
|
|
|
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')
|
2021-11-13 06:45:02 +08:00
|
|
|
if osx_version >= (10, 15):
|
|
|
|
config.available_features.add('osx-swift-runtime')
|
2020-04-30 04:40:58 +08:00
|
|
|
except subprocess.CalledProcessError:
|
2016-03-30 02:54:29 +08:00
|
|
|
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
|
|
|
|
|
2018-06-21 23:21:24 +08:00
|
|
|
# 32-bit iOS simulator is deprecated and removed in latest Xcode.
|
|
|
|
if config.apple_platform == "iossim":
|
|
|
|
if config.target_arch == "i386":
|
|
|
|
config.unsupported = True
|
2020-08-13 06:02:42 +08:00
|
|
|
|
|
|
|
def get_macos_aligned_version(macos_vers):
|
|
|
|
platform = config.apple_platform
|
|
|
|
if platform == 'osx':
|
|
|
|
return macos_vers
|
|
|
|
|
|
|
|
macos_major, macos_minor = macos_vers
|
|
|
|
assert macos_major >= 10
|
|
|
|
|
|
|
|
if macos_major == 10: # macOS 10.x
|
|
|
|
major = macos_minor
|
|
|
|
minor = 0
|
|
|
|
else: # macOS 11+
|
|
|
|
major = macos_major + 5
|
|
|
|
minor = macos_minor
|
|
|
|
|
|
|
|
assert major >= 11
|
|
|
|
|
|
|
|
if platform.startswith('ios') or platform.startswith('tvos'):
|
|
|
|
major -= 2
|
|
|
|
elif platform.startswith('watch'):
|
|
|
|
major -= 9
|
|
|
|
else:
|
|
|
|
lit_config.fatal("Unsupported apple platform '{}'".format(platform))
|
|
|
|
|
|
|
|
return (major, minor)
|
|
|
|
|
|
|
|
for vers in min_macos_deployment_target_substitutions:
|
|
|
|
flag = config.apple_platform_min_deployment_target_flag
|
|
|
|
major, minor = get_macos_aligned_version(vers)
|
|
|
|
config.substitutions.append( ('%%min_macos_deployment_target=%s.%s' % vers, '{}={}.{}'.format(flag, major, minor)) )
|
2016-11-22 05:48:25 +08:00
|
|
|
else:
|
2020-08-13 06:02:42 +08:00
|
|
|
for vers in min_macos_deployment_target_substitutions:
|
|
|
|
config.substitutions.append( ('%%min_macos_deployment_target=%s.%s' % vers, '') )
|
2016-11-22 05:48:25 +08:00
|
|
|
|
2017-10-17 02:03:11 +08:00
|
|
|
if config.android:
|
2019-01-16 06:06:48 +08:00
|
|
|
env = os.environ.copy()
|
|
|
|
if config.android_serial:
|
|
|
|
env['ANDROID_SERIAL'] = config.android_serial
|
|
|
|
config.environment['ANDROID_SERIAL'] = config.android_serial
|
2020-10-13 18:02:30 +08:00
|
|
|
|
2017-10-17 02:03:11 +08:00
|
|
|
adb = os.environ.get('ADB', 'adb')
|
2020-10-22 03:07:52 +08:00
|
|
|
|
|
|
|
# These are needed for tests to upload/download temp files, such as
|
|
|
|
# suppression-files, to device.
|
2021-07-21 08:37:36 +08:00
|
|
|
config.substitutions.append( ('%device_rundir/', "/data/local/tmp/Output/") )
|
2020-10-22 03:07:52 +08:00
|
|
|
config.substitutions.append( ('%push_to_device', "%s -s '%s' push " % (adb, env['ANDROID_SERIAL']) ) )
|
|
|
|
config.substitutions.append( ('%adb_shell ', "%s -s '%s' shell " % (adb, env['ANDROID_SERIAL']) ) )
|
2020-11-17 06:53:34 +08:00
|
|
|
config.substitutions.append( ('%device_rm', "%s -s '%s' shell 'rm ' " % (adb, env['ANDROID_SERIAL']) ) )
|
2020-10-22 03:07:52 +08:00
|
|
|
|
2017-10-17 02:03:11 +08:00
|
|
|
try:
|
2019-01-16 06:06:48 +08:00
|
|
|
android_api_level_str = subprocess.check_output([adb, "shell", "getprop", "ro.build.version.sdk"], env=env).rstrip()
|
2020-10-17 13:57:02 +08:00
|
|
|
android_api_codename = subprocess.check_output([adb, "shell", "getprop", "ro.build.version.codename"], env=env).rstrip().decode("utf-8")
|
2017-10-17 02:03:11 +08:00
|
|
|
except (subprocess.CalledProcessError, OSError):
|
|
|
|
lit_config.fatal("Failed to read ro.build.version.sdk (using '%s' as adb)" % adb)
|
|
|
|
try:
|
|
|
|
android_api_level = int(android_api_level_str)
|
|
|
|
except ValueError:
|
|
|
|
lit_config.fatal("Failed to read ro.build.version.sdk (using '%s' as adb): got '%s'" % (adb, android_api_level_str))
|
2020-11-14 17:52:44 +08:00
|
|
|
android_api_level = min(android_api_level, int(config.android_api_level))
|
2021-05-28 05:53:49 +08:00
|
|
|
for required in [26, 28, 29, 30]:
|
2020-11-18 15:43:08 +08:00
|
|
|
if android_api_level >= required:
|
|
|
|
config.available_features.add('android-%s' % required)
|
2020-12-28 13:50:47 +08:00
|
|
|
# FIXME: Replace with appropriate version when availible.
|
2020-11-15 15:22:57 +08:00
|
|
|
if android_api_level > 30 or (android_api_level == 30 and android_api_codename == 'S'):
|
2020-10-17 13:57:02 +08:00
|
|
|
config.available_features.add('android-thread-properties-api')
|
2017-10-17 02:03:11 +08:00
|
|
|
|
2019-01-16 06:06:48 +08:00
|
|
|
# Prepare the device.
|
|
|
|
android_tmpdir = '/data/local/tmp/Output'
|
|
|
|
subprocess.check_call([adb, "shell", "mkdir", "-p", android_tmpdir], env=env)
|
|
|
|
for file in config.android_files_to_push:
|
|
|
|
subprocess.check_call([adb, "push", file, android_tmpdir], env=env)
|
2020-10-22 03:07:52 +08:00
|
|
|
else:
|
2021-07-21 08:37:36 +08:00
|
|
|
config.substitutions.append( ('%device_rundir/', "") )
|
2020-10-22 03:07:52 +08:00
|
|
|
config.substitutions.append( ('%push_to_device', "echo ") )
|
|
|
|
config.substitutions.append( ('%adb_shell', "echo ") )
|
2019-01-16 06:06:48 +08:00
|
|
|
|
2019-01-09 21:27:29 +08:00
|
|
|
if config.host_os == 'Linux':
|
|
|
|
# detect whether we are using glibc, and which version
|
2020-12-28 13:50:47 +08:00
|
|
|
# NB: 'ldd' is just one of the tools commonly installed as part of glibc/musl
|
2019-01-09 21:27:29 +08:00
|
|
|
ldd_ver_cmd = subprocess.Popen(['ldd', '--version'],
|
|
|
|
stdout=subprocess.PIPE,
|
2021-01-02 06:09:13 +08:00
|
|
|
stderr=subprocess.DEVNULL,
|
2019-01-09 21:27:29 +08:00
|
|
|
env={'LANG': 'C'})
|
|
|
|
sout, _ = ldd_ver_cmd.communicate()
|
2020-12-28 13:50:47 +08:00
|
|
|
ver_lines = sout.splitlines()
|
|
|
|
if not config.android and len(ver_lines) and ver_lines[0].startswith(b"ldd "):
|
2019-01-09 21:27:29 +08:00
|
|
|
from distutils.version import LooseVersion
|
2020-12-28 13:50:47 +08:00
|
|
|
ver = LooseVersion(ver_lines[0].split()[-1].decode())
|
2021-11-16 03:18:40 +08:00
|
|
|
for required in ["2.27", "2.30", "2.34"]:
|
2020-11-18 15:43:08 +08:00
|
|
|
if ver >= LooseVersion(required):
|
2020-12-28 13:50:47 +08:00
|
|
|
config.available_features.add("glibc-" + required)
|
2019-01-09 21:27:29 +08:00
|
|
|
|
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) )
|
|
|
|
|
2022-04-20 01:29:44 +08:00
|
|
|
def liblto_path():
|
|
|
|
return os.path.join(config.llvm_shlib_dir, 'libLTO.dylib')
|
|
|
|
|
2015-05-20 07:50:13 +08:00
|
|
|
def is_darwin_lto_supported():
|
2022-04-20 01:29:44 +08:00
|
|
|
return os.path.exists(liblto_path())
|
2015-05-20 07:50:13 +08:00
|
|
|
|
2020-07-23 01:15:51 +08:00
|
|
|
def is_binutils_lto_supported():
|
2015-05-20 07:50:13 +08:00
|
|
|
if not os.path.exists(os.path.join(config.llvm_shlib_dir, 'LLVMgold.so')):
|
|
|
|
return False
|
|
|
|
|
2020-07-23 01:15:51 +08:00
|
|
|
# We require both ld.bfd and ld.gold exist and support plugins. They are in
|
|
|
|
# the same repository 'binutils-gdb' and usually built together.
|
|
|
|
for exe in (config.gnu_ld_executable, config.gold_executable):
|
|
|
|
ld_cmd = subprocess.Popen([exe, '--help'], stdout=subprocess.PIPE, env={'LANG': 'C'})
|
|
|
|
ld_out = ld_cmd.stdout.read().decode()
|
|
|
|
ld_cmd.wait()
|
|
|
|
if not '-plugin' in ld_out:
|
|
|
|
return False
|
2015-05-20 07:50:13 +08:00
|
|
|
|
|
|
|
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
|
2022-04-20 01:29:44 +08:00
|
|
|
config.lto_flags = [ '-Wl,-lto_library,' + liblto_path() ]
|
2020-07-23 01:15:51 +08:00
|
|
|
elif config.host_os in ['Linux', 'FreeBSD', 'NetBSD']:
|
|
|
|
config.lto_supported = False
|
2017-04-22 02:11:23 +08:00
|
|
|
if config.use_lld:
|
2020-07-23 01:15:51 +08:00
|
|
|
config.lto_supported = True
|
|
|
|
if is_binutils_lto_supported():
|
|
|
|
config.available_features.add('binutils_lto')
|
|
|
|
config.lto_supported = True
|
|
|
|
|
|
|
|
if config.lto_supported:
|
|
|
|
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
|
2017-11-18 03:49:41 +08:00
|
|
|
config.lto_flags = ["-fuse-ld=lld"]
|
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"]
|
2018-07-19 23:32:48 +08:00
|
|
|
|
2019-01-15 03:18:34 +08:00
|
|
|
if config.have_rpc_xdr_h:
|
|
|
|
config.available_features.add('sunrpc')
|
|
|
|
|
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)
|
2019-02-27 02:41:55 +08:00
|
|
|
except OSError as e:
|
2019-02-27 02:41:54 +08:00
|
|
|
print("Could not launch llvm-config in " + config.llvm_tools_dir)
|
|
|
|
print(" Failed with error #{0}: {1}".format(e.errno, e.strerror))
|
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
|
|
|
|
2019-02-28 03:06:20 +08:00
|
|
|
# No throttling on non-Darwin platforms.
|
|
|
|
lit_config.parallelism_groups['shadow-memory'] = None
|
2017-10-06 04:00:07 +08:00
|
|
|
|
2019-02-28 03:06:20 +08:00
|
|
|
if platform.system() == 'Darwin':
|
|
|
|
ios_device = config.apple_platform != 'osx' and not config.apple_platform.endswith('sim')
|
|
|
|
# Force sequential execution when running tests on iOS devices.
|
|
|
|
if ios_device:
|
|
|
|
lit_config.warning('Forcing sequential execution for iOS device tests')
|
|
|
|
lit_config.parallelism_groups['ios-device'] = 1
|
|
|
|
config.parallelism_group = 'ios-device'
|
|
|
|
|
|
|
|
# Only run up to 3 processes that require shadow memory simultaneously on
|
|
|
|
# 64-bit Darwin. Using more scales badly and hogs the system due to
|
|
|
|
# inefficient handling of large mmap'd regions (terabytes) by the kernel.
|
2022-03-31 01:24:11 +08:00
|
|
|
else:
|
|
|
|
lit_config.warning('Throttling sanitizer tests that require shadow memory on Darwin')
|
2019-02-28 03:06:20 +08:00
|
|
|
lit_config.parallelism_groups['shadow-memory'] = 3
|
2018-01-20 10:07:30 +08:00
|
|
|
|
2018-06-15 04:29:47 +08:00
|
|
|
# Multiple substitutions are necessary to support multiple shared objects used
|
|
|
|
# at once.
|
|
|
|
# Note that substitutions with numbers have to be defined first to avoid
|
|
|
|
# being subsumed by substitutions with smaller postfix.
|
|
|
|
for postfix in ["2", "1", ""]:
|
|
|
|
if config.host_os == 'Darwin':
|
|
|
|
config.substitutions.append( ("%ld_flags_rpath_exe" + postfix, '-Wl,-rpath,@executable_path/ %dynamiclib' + postfix) )
|
|
|
|
config.substitutions.append( ("%ld_flags_rpath_so" + postfix, '-install_name @rpath/`basename %dynamiclib{}`'.format(postfix)) )
|
2018-07-01 05:35:05 +08:00
|
|
|
elif config.host_os in ('FreeBSD', 'NetBSD', 'OpenBSD'):
|
2018-06-15 04:29:47 +08:00
|
|
|
config.substitutions.append( ("%ld_flags_rpath_exe" + postfix, "-Wl,-z,origin -Wl,-rpath,\$ORIGIN -L%T -l%xdynamiclib_namespec" + postfix) )
|
|
|
|
config.substitutions.append( ("%ld_flags_rpath_so" + postfix, '') )
|
|
|
|
elif config.host_os == 'Linux':
|
|
|
|
config.substitutions.append( ("%ld_flags_rpath_exe" + postfix, "-Wl,-rpath,\$ORIGIN -L%T -l%xdynamiclib_namespec" + postfix) )
|
|
|
|
config.substitutions.append( ("%ld_flags_rpath_so" + postfix, '') )
|
|
|
|
elif config.host_os == 'SunOS':
|
|
|
|
config.substitutions.append( ("%ld_flags_rpath_exe" + postfix, "-Wl,-R\$ORIGIN -L%T -l%xdynamiclib_namespec" + postfix) )
|
|
|
|
config.substitutions.append( ("%ld_flags_rpath_so" + postfix, '') )
|
|
|
|
|
|
|
|
# Must be defined after the substitutions that use %dynamiclib.
|
|
|
|
config.substitutions.append( ("%dynamiclib" + postfix, '%T/%xdynamiclib_filename' + postfix) )
|
|
|
|
config.substitutions.append( ("%xdynamiclib_filename" + postfix, 'lib%xdynamiclib_namespec{}.so'.format(postfix)) )
|
|
|
|
config.substitutions.append( ("%xdynamiclib_namespec", '%basename_t.dynamic') )
|
2017-10-06 04:00:07 +08:00
|
|
|
|
2021-09-04 15:31:34 +08:00
|
|
|
# Provide a substitution that can be used to tell Clang to use a static libstdc++.
|
2018-05-14 23:48:49 +08:00
|
|
|
# The substitution expands to nothing on non Linux platforms.
|
|
|
|
# FIXME: This should check the target OS, not the host OS.
|
|
|
|
if config.host_os == 'Linux':
|
|
|
|
config.substitutions.append( ("%linux_static_libstdcplusplus", "-stdlib=libstdc++ -static-libstdc++") )
|
|
|
|
else:
|
|
|
|
config.substitutions.append( ("%linux_static_libstdcplusplus", "") )
|
|
|
|
|
2017-10-07 04:53:40 +08:00
|
|
|
config.default_sanitizer_opts = []
|
|
|
|
if config.host_os == 'Darwin':
|
|
|
|
# On Darwin, we default to `abort_on_error=1`, which would make tests run
|
|
|
|
# much slower. Let's override this and run lit tests with 'abort_on_error=0'.
|
|
|
|
config.default_sanitizer_opts += ['abort_on_error=0']
|
|
|
|
config.default_sanitizer_opts += ['log_to_syslog=0']
|
2020-03-25 10:39:44 +08:00
|
|
|
if lit.util.which('log'):
|
2020-03-27 09:17:53 +08:00
|
|
|
# Querying the log can only done by a privileged user so
|
|
|
|
# so check if we can query the log.
|
|
|
|
exit_code = -1
|
|
|
|
with open('/dev/null', 'r') as f:
|
|
|
|
# Run a `log show` command the should finish fairly quickly and produce very little output.
|
|
|
|
exit_code = subprocess.call(['log', 'show', '--last', '1m', '--predicate', '1 == 0'], stdout=f, stderr=f)
|
|
|
|
if exit_code == 0:
|
|
|
|
config.available_features.add('darwin_log_cmd')
|
|
|
|
else:
|
|
|
|
lit_config.warning('log command found but cannot queried')
|
2020-03-25 10:39:44 +08:00
|
|
|
else:
|
|
|
|
lit_config.warning('log command not found. Some tests will be skipped.')
|
2017-10-07 04:53:40 +08:00
|
|
|
elif config.android:
|
|
|
|
config.default_sanitizer_opts += ['abort_on_error=0']
|
2017-10-11 07:37:26 +08:00
|
|
|
|
|
|
|
# Allow tests to use REQUIRES=stable-runtime. For use when you cannot use XFAIL
|
|
|
|
# because the test hangs or fails on one configuration and not the other.
|
|
|
|
if config.android or (config.target_arch not in ['arm', 'armhf', 'aarch64']):
|
|
|
|
config.available_features.add('stable-runtime')
|
2017-11-17 07:28:25 +08:00
|
|
|
|
|
|
|
if config.asan_shadow_scale:
|
|
|
|
config.available_features.add("shadow-scale-%s" % config.asan_shadow_scale)
|
|
|
|
else:
|
|
|
|
config.available_features.add("shadow-scale-3")
|
[ubsan] Re-commit: lit changes for lld testing, future lto testing.
Summary:
As discussed in https://github.com/google/oss-fuzz/issues/933,
it would be really awesome to be able to use ThinLTO for fuzzing.
However, as @kcc has pointed out, it is currently undefined (untested)
whether the sanitizers actually function properly with LLD and/or LTO.
This patch is inspired by the cfi test, which already do test with LTO
(and/or LLD), since LTO is required for CFI to function.
I started with UBSan, because it's cmakelists / lit.* files appeared
to be the cleanest. This patch adds the infrastructure to easily add
LLD and/or LTO sub-variants of the existing lit test configurations.
Also, this patch adds the LLD flavor, that explicitly does use LLD to link.
The check-ubsan does pass on my machine. And to minimize the [initial]
potential buildbot breakage i have put some restrictions on this flavour.
Please review carefully, i have not worked with lit/sanitizer tests before.
The original attempt, r319525 was reverted in r319526 due
to the failures in compiler-rt standalone builds.
Reviewers: eugenis, vitalybuka
Reviewed By: eugenis
Subscribers: #sanitizers, pcc, kubamracek, mgorny, llvm-commits, mehdi_amini, inglorion, kcc
Differential Revision: https://reviews.llvm.org/D39508
llvm-svn: 319575
2017-12-02 03:36:29 +08:00
|
|
|
|
2020-09-04 06:21:20 +08:00
|
|
|
if config.memprof_shadow_scale:
|
|
|
|
config.available_features.add("memprof-shadow-scale-%s" % config.memprof_shadow_scale)
|
|
|
|
else:
|
|
|
|
config.available_features.add("memprof-shadow-scale-3")
|
|
|
|
|
2019-12-04 06:34:02 +08:00
|
|
|
if config.expensive_checks:
|
|
|
|
config.available_features.add("expensive_checks")
|
|
|
|
|
[ubsan] Re-commit: lit changes for lld testing, future lto testing.
Summary:
As discussed in https://github.com/google/oss-fuzz/issues/933,
it would be really awesome to be able to use ThinLTO for fuzzing.
However, as @kcc has pointed out, it is currently undefined (untested)
whether the sanitizers actually function properly with LLD and/or LTO.
This patch is inspired by the cfi test, which already do test with LTO
(and/or LLD), since LTO is required for CFI to function.
I started with UBSan, because it's cmakelists / lit.* files appeared
to be the cleanest. This patch adds the infrastructure to easily add
LLD and/or LTO sub-variants of the existing lit test configurations.
Also, this patch adds the LLD flavor, that explicitly does use LLD to link.
The check-ubsan does pass on my machine. And to minimize the [initial]
potential buildbot breakage i have put some restrictions on this flavour.
Please review carefully, i have not worked with lit/sanitizer tests before.
The original attempt, r319525 was reverted in r319526 due
to the failures in compiler-rt standalone builds.
Reviewers: eugenis, vitalybuka
Reviewed By: eugenis
Subscribers: #sanitizers, pcc, kubamracek, mgorny, llvm-commits, mehdi_amini, inglorion, kcc
Differential Revision: https://reviews.llvm.org/D39508
llvm-svn: 319575
2017-12-02 03:36:29 +08:00
|
|
|
# Propagate the LLD/LTO into the clang config option, so nothing else is needed.
|
|
|
|
run_wrapper = []
|
|
|
|
target_cflags = [getattr(config, 'target_cflags', None)]
|
|
|
|
extra_cflags = []
|
|
|
|
|
|
|
|
if config.use_lto and config.lto_supported:
|
|
|
|
extra_cflags += config.lto_flags
|
|
|
|
elif config.use_lto and (not config.lto_supported):
|
|
|
|
config.unsupported = True
|
|
|
|
|
|
|
|
if config.use_lld and config.has_lld and not config.use_lto:
|
|
|
|
extra_cflags += ["-fuse-ld=lld"]
|
|
|
|
elif config.use_lld and (not config.has_lld):
|
|
|
|
config.unsupported = True
|
|
|
|
|
2020-12-08 19:46:36 +08:00
|
|
|
# Append any extra flags passed in lit_config
|
|
|
|
append_target_cflags = lit_config.params.get('append_target_cflags', None)
|
|
|
|
if append_target_cflags:
|
|
|
|
lit_config.note('Appending to extra_cflags: "{}"'.format(append_target_cflags))
|
|
|
|
extra_cflags += [append_target_cflags]
|
|
|
|
|
[ubsan] Re-commit: lit changes for lld testing, future lto testing.
Summary:
As discussed in https://github.com/google/oss-fuzz/issues/933,
it would be really awesome to be able to use ThinLTO for fuzzing.
However, as @kcc has pointed out, it is currently undefined (untested)
whether the sanitizers actually function properly with LLD and/or LTO.
This patch is inspired by the cfi test, which already do test with LTO
(and/or LLD), since LTO is required for CFI to function.
I started with UBSan, because it's cmakelists / lit.* files appeared
to be the cleanest. This patch adds the infrastructure to easily add
LLD and/or LTO sub-variants of the existing lit test configurations.
Also, this patch adds the LLD flavor, that explicitly does use LLD to link.
The check-ubsan does pass on my machine. And to minimize the [initial]
potential buildbot breakage i have put some restrictions on this flavour.
Please review carefully, i have not worked with lit/sanitizer tests before.
The original attempt, r319525 was reverted in r319526 due
to the failures in compiler-rt standalone builds.
Reviewers: eugenis, vitalybuka
Reviewed By: eugenis
Subscribers: #sanitizers, pcc, kubamracek, mgorny, llvm-commits, mehdi_amini, inglorion, kcc
Differential Revision: https://reviews.llvm.org/D39508
llvm-svn: 319575
2017-12-02 03:36:29 +08:00
|
|
|
config.clang = " " + " ".join(run_wrapper + [config.compile_wrapper, config.clang]) + " "
|
|
|
|
config.target_cflags = " " + " ".join(target_cflags + extra_cflags) + " "
|
2021-02-24 01:22:01 +08:00
|
|
|
|
|
|
|
if config.host_os == 'Darwin':
|
|
|
|
config.substitutions.append((
|
2021-07-24 04:19:54 +08:00
|
|
|
"%get_pid_from_output",
|
2021-02-24 01:22:01 +08:00
|
|
|
"{} {}/get_pid_from_output.py".format(
|
2021-07-24 04:19:54 +08:00
|
|
|
sh_quote(config.python_executable),
|
2021-02-24 01:22:01 +08:00
|
|
|
sh_quote(get_ios_commands_dir())
|
|
|
|
))
|
|
|
|
)
|
|
|
|
config.substitutions.append(
|
2021-07-24 04:19:54 +08:00
|
|
|
("%print_crashreport_for_pid",
|
2021-02-24 01:22:01 +08:00
|
|
|
"{} {}/print_crashreport_for_pid.py".format(
|
2021-07-24 04:19:54 +08:00
|
|
|
sh_quote(config.python_executable),
|
2021-02-24 01:22:01 +08:00
|
|
|
sh_quote(get_ios_commands_dir())
|
|
|
|
))
|
|
|
|
)
|