2012-07-31 15:43:11 +00:00
|
|
|
# -*- Python -*-
|
|
|
|
|
|
|
|
# Configuration file for 'lit' test runner.
|
|
|
|
# This file contains common rules for various compiler-rt testsuites.
|
2019-06-27 20:56:04 +00:00
|
|
|
# It is mostly copied from lit.cfg.py used by Clang.
|
2012-07-31 15:43:11 +00:00
|
|
|
import os
|
|
|
|
import platform
|
2015-07-29 18:12:45 +00:00
|
|
|
import re
|
2023-05-11 23:06:01 -07:00
|
|
|
import shlex
|
2015-05-19 23:50:13 +00:00
|
|
|
import subprocess
|
2018-06-20 13:33:42 +00:00
|
|
|
import json
|
2012-07-31 15:43:11 +00:00
|
|
|
|
2013-08-09 22:14:01 +00:00
|
|
|
import lit.formats
|
2014-06-10 14:22:00 +00:00
|
|
|
import lit.util
|
2013-08-09 22:14:01 +00:00
|
|
|
|
2023-05-17 16:59:41 +02:00
|
|
|
|
2024-04-12 13:20:30 -07:00
|
|
|
def get_path_from_clang(args, allow_failure):
|
|
|
|
clang_cmd = [
|
|
|
|
config.clang.strip(),
|
|
|
|
f"--target={config.target_triple}",
|
|
|
|
*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)
|
|
|
|
return path, clang_cmd
|
|
|
|
|
|
|
|
|
2021-04-30 16:24:33 -07: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
|
2023-05-17 16:59:41 +02:00
|
|
|
|
2021-04-30 16:24:33 -07:00
|
|
|
# Try using `-print-runtime-dir`. This is only supported by very new versions of Clang.
|
|
|
|
# so allow failure here.
|
2021-09-15 09:07:47 -07:00
|
|
|
runtime_dir, clang_cmd = get_path_from_clang(
|
|
|
|
shlex.split(config.target_cflags) + ["-print-runtime-dir"], allow_failure=True
|
2021-05-15 11:09:34 -07:00
|
|
|
)
|
2021-04-30 16:24:33 -07:00
|
|
|
if runtime_dir:
|
|
|
|
if os.path.exists(runtime_dir):
|
|
|
|
return os.path.realpath(runtime_dir)
|
2021-05-15 11:09:34 -07: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}."
|
2023-05-17 16:59:41 +02:00
|
|
|
)
|
2021-05-15 11:09:34 -07:00
|
|
|
return None
|
2023-05-17 16:59:41 +02:00
|
|
|
|
2021-04-30 16:24:33 -07: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).
|
2018-06-20 13:33:42 +00:00
|
|
|
if config.host_os == "Darwin":
|
2021-05-15 11:09:34 -07:00
|
|
|
lib_dir, _ = get_path_from_clang(["-print-file-name=lib"], allow_failure=False)
|
2021-04-30 16:24:33 -07: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)
|
2023-05-17 16:59:41 +02:00
|
|
|
|
2021-04-30 16:24:33 -07:00
|
|
|
lit_config.warning("Failed to determine compiler's runtime directory")
|
2021-05-15 11:09:34 -07:00
|
|
|
return None
|
2021-04-30 16:24:33 -07:00
|
|
|
|
|
|
|
|
2023-07-13 14:13:09 +02:00
|
|
|
def push_dynamic_library_lookup_path(config, new_path):
|
|
|
|
if platform.system() == "Windows":
|
|
|
|
dynamic_library_lookup_var = "PATH"
|
|
|
|
elif platform.system() == "Darwin":
|
|
|
|
dynamic_library_lookup_var = "DYLD_LIBRARY_PATH"
|
2024-11-05 09:14:25 +01:00
|
|
|
elif platform.system() == "Haiku":
|
|
|
|
dynamic_library_lookup_var = "LIBRARY_PATH"
|
2023-07-13 14:13:09 +02:00
|
|
|
else:
|
|
|
|
dynamic_library_lookup_var = "LD_LIBRARY_PATH"
|
|
|
|
|
|
|
|
new_ld_library_path = os.path.pathsep.join(
|
|
|
|
(new_path, config.environment.get(dynamic_library_lookup_var, ""))
|
|
|
|
)
|
|
|
|
config.environment[dynamic_library_lookup_var] = new_ld_library_path
|
|
|
|
|
|
|
|
if platform.system() == "FreeBSD":
|
|
|
|
dynamic_library_lookup_var = "LD_32_LIBRARY_PATH"
|
|
|
|
new_ld_32_library_path = os.path.pathsep.join(
|
|
|
|
(new_path, config.environment.get(dynamic_library_lookup_var, ""))
|
|
|
|
)
|
|
|
|
config.environment[dynamic_library_lookup_var] = new_ld_32_library_path
|
|
|
|
|
|
|
|
if platform.system() == "SunOS":
|
|
|
|
dynamic_library_lookup_var = "LD_LIBRARY_PATH_32"
|
|
|
|
new_ld_library_path_32 = os.path.pathsep.join(
|
|
|
|
(new_path, config.environment.get(dynamic_library_lookup_var, ""))
|
|
|
|
)
|
|
|
|
config.environment[dynamic_library_lookup_var] = new_ld_library_path_32
|
|
|
|
|
|
|
|
dynamic_library_lookup_var = "LD_LIBRARY_PATH_64"
|
|
|
|
new_ld_library_path_64 = os.path.pathsep.join(
|
|
|
|
(new_path, config.environment.get(dynamic_library_lookup_var, ""))
|
|
|
|
)
|
|
|
|
config.environment[dynamic_library_lookup_var] = new_ld_library_path_64
|
|
|
|
|
|
|
|
|
2017-03-30 13:33:22 +00: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 11:37:27 +03:00
|
|
|
# Allow expanding substitutions that are based on other substitutions
|
|
|
|
config.recursiveExpansionLimit = 10
|
|
|
|
|
2017-03-30 13:33:22 +00:00
|
|
|
# Setup test format.
|
2012-07-31 15:43:11 +00:00
|
|
|
config.test_format = lit.formats.ShTest(execute_external)
|
2015-08-12 23:49:52 +00:00
|
|
|
if execute_external:
|
|
|
|
config.available_features.add("shell")
|
2012-07-31 15:43:11 +00:00
|
|
|
|
2023-03-27 22:48:17 +08:00
|
|
|
target_is_msvc = bool(re.match(r".*-windows-msvc$", config.target_triple))
|
2024-04-12 13:20:30 -07:00
|
|
|
target_is_windows = bool(re.match(r".*-windows.*$", config.target_triple))
|
2023-03-27 22:48:17 +08:00
|
|
|
|
2014-02-19 15:13:14 +00:00
|
|
|
compiler_id = getattr(config, "compiler_id", None)
|
|
|
|
if compiler_id == "Clang":
|
2023-03-27 22:48:17 +08:00
|
|
|
if not (platform.system() == "Windows" and target_is_msvc):
|
2014-05-14 19:10:43 +00:00
|
|
|
config.cxx_mode_flags = ["--driver-mode=g++"]
|
|
|
|
else:
|
|
|
|
config.cxx_mode_flags = []
|
2014-09-30 23:07:45 +00: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"]
|
2023-03-27 22:48:17 +08:00
|
|
|
if platform.system() == "Windows" and target_is_msvc:
|
|
|
|
# On MSVC, use CodeView with column info instead of DWARF. Both VS and
|
2018-02-26 22:55:33 +00:00
|
|
|
# windbg do not behave well when column info is enabled, but users have
|
|
|
|
# requested it because it makes ASan reports more precise.
|
2015-08-05 22:48:26 +00:00
|
|
|
config.debug_info_flags.append("-gcodeview")
|
2018-02-26 22:55:33 +00:00
|
|
|
config.debug_info_flags.append("-gcolumn-info")
|
2024-09-12 10:30:13 -07:00
|
|
|
elif compiler_id == "MSVC":
|
|
|
|
config.debug_info_flags = ["/Z7"]
|
|
|
|
config.cxx_mode_flags = []
|
2014-02-19 15:13:14 +00:00
|
|
|
elif compiler_id == "GNU":
|
|
|
|
config.cxx_mode_flags = ["-x c++"]
|
2014-09-05 22:05:32 +00:00
|
|
|
config.debug_info_flags = ["-g"]
|
2014-02-19 15:13:14 +00:00
|
|
|
else:
|
|
|
|
lit_config.fatal("Unsupported compiler id: %r" % compiler_id)
|
2014-05-16 20:12:27 +00:00
|
|
|
# Add compiler ID to the list of available features.
|
|
|
|
config.available_features.add(compiler_id)
|
2012-07-31 15:43:11 +00:00
|
|
|
|
2021-09-15 09:07:47 -07: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
|
2024-10-15 10:06:11 +02:00
|
|
|
# host triple as the trailing path component. The value is incorrect for 32-bit
|
|
|
|
# tests on 64-bit hosts and vice versa. Adjust config.compiler_rt_libdir
|
|
|
|
# accordingly.
|
2021-09-15 09:07:47 -07:00
|
|
|
if config.enable_per_target_runtime_dir:
|
2024-10-15 10:06:11 +02:00
|
|
|
if config.target_arch == "i386":
|
2021-09-15 09:07:47 -07:00
|
|
|
config.compiler_rt_libdir = re.sub(
|
|
|
|
r"/x86_64(?=-[^/]+$)", "/i386", config.compiler_rt_libdir
|
|
|
|
)
|
2024-10-15 10:06:11 +02:00
|
|
|
elif config.target_arch == "x86_64":
|
2021-09-15 09:07:47 -07:00
|
|
|
config.compiler_rt_libdir = re.sub(
|
|
|
|
r"/i386(?=-[^/]+$)", "/x86_64", config.compiler_rt_libdir
|
|
|
|
)
|
2024-10-15 10:06:11 +02:00
|
|
|
if config.target_arch == "sparc":
|
|
|
|
config.compiler_rt_libdir = re.sub(
|
|
|
|
r"/sparcv9(?=-[^/]+$)", "/sparc", config.compiler_rt_libdir
|
|
|
|
)
|
|
|
|
elif config.target_arch == "sparcv9":
|
|
|
|
config.compiler_rt_libdir = re.sub(
|
|
|
|
r"/sparc(?=-[^/]+$)", "/sparcv9", config.compiler_rt_libdir
|
|
|
|
)
|
2024-04-12 13:20:30 -07:00
|
|
|
|
|
|
|
# Check if the test compiler resource dir matches the local build directory
|
|
|
|
# (which happens with -DLLVM_ENABLE_PROJECTS=clang;compiler-rt) or if we are
|
|
|
|
# using an installed clang to test compiler-rt standalone. In the latter case
|
|
|
|
# we may need to override the resource dir to match the path of the just-built
|
|
|
|
# compiler-rt libraries.
|
|
|
|
test_cc_resource_dir, _ = get_path_from_clang(
|
|
|
|
shlex.split(config.target_cflags) + ["-print-resource-dir"], allow_failure=True
|
|
|
|
)
|
|
|
|
# Normalize the path for comparison
|
|
|
|
if test_cc_resource_dir is not None:
|
|
|
|
test_cc_resource_dir = os.path.realpath(test_cc_resource_dir)
|
|
|
|
if lit_config.debug:
|
|
|
|
lit_config.note(f"Resource dir for {config.clang} is {test_cc_resource_dir}")
|
|
|
|
local_build_resource_dir = os.path.realpath(config.compiler_rt_output_dir)
|
|
|
|
if test_cc_resource_dir != local_build_resource_dir and config.test_standalone_build_libs:
|
|
|
|
if config.compiler_id == "Clang":
|
|
|
|
if lit_config.debug:
|
|
|
|
lit_config.note(
|
|
|
|
f"Overriding test compiler resource dir to use "
|
|
|
|
f'libraries in "{config.compiler_rt_libdir}"'
|
|
|
|
)
|
|
|
|
# Ensure that we use the just-built static libraries when linking by
|
|
|
|
# overriding the Clang resource directory. Additionally, we want to use
|
|
|
|
# the builtin headers shipped with clang (e.g. stdint.h), so we
|
|
|
|
# explicitly add this as an include path (since the headers are not
|
|
|
|
# going to be in the current compiler-rt build directory).
|
|
|
|
# We also tell the linker to add an RPATH entry for the local library
|
|
|
|
# directory so that the just-built shared libraries are used.
|
|
|
|
config.target_cflags += f" -nobuiltininc"
|
|
|
|
config.target_cflags += f" -I{config.compiler_rt_src_root}/include"
|
|
|
|
config.target_cflags += f" -idirafter {test_cc_resource_dir}/include"
|
|
|
|
config.target_cflags += f" -resource-dir={config.compiler_rt_output_dir}"
|
|
|
|
if not target_is_windows:
|
|
|
|
# Avoid passing -rpath on Windows where it is not supported.
|
|
|
|
config.target_cflags += f" -Wl,-rpath,{config.compiler_rt_libdir}"
|
|
|
|
else:
|
|
|
|
lit_config.warning(
|
|
|
|
f"Cannot override compiler-rt library directory with non-Clang "
|
|
|
|
f"compiler: {config.compiler_id}"
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2021-04-30 16:24:33 -07: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.
|
2024-04-12 13:20:30 -07:00
|
|
|
# Warn about this and handle appropriately.
|
2021-04-30 16:24:33 -07:00
|
|
|
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:
|
2021-05-15 10:52:10 -07:00
|
|
|
lit_config.warning(
|
2021-04-30 16:24:33 -07:00
|
|
|
"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:
|
2024-04-12 13:20:30 -07:00
|
|
|
# Use just built runtime libraries, i.e. the libraries this build just built.
|
2021-04-30 16:24:33 -07:00
|
|
|
if not config.test_suite_supports_overriding_runtime_lib_path:
|
|
|
|
# Test suite doesn't support this configuration.
|
2021-05-15 10:52:10 -07: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-04-30 16:24:33 -07: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."
|
2023-05-17 16:59:41 +02:00
|
|
|
)
|
2021-04-30 16:24:33 -07:00
|
|
|
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 14:02:27 +00: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-03 15:21:20 -07:00
|
|
|
if config.memprof_shadow_scale != "":
|
|
|
|
config.target_cflags += (
|
|
|
|
" -mllvm -memprof-mapping-scale=" + config.memprof_shadow_scale
|
2023-05-17 16:59:41 +02:00
|
|
|
)
|
2017-11-13 14:02:27 +00:00
|
|
|
|
2012-07-31 15:43:11 +00:00
|
|
|
# Clear some environment variables that might affect Clang.
|
2022-08-17 18:44:41 -07:00
|
|
|
possibly_dangerous_env_vars = [
|
|
|
|
"ASAN_OPTIONS",
|
|
|
|
"DFSAN_OPTIONS",
|
|
|
|
"HWASAN_OPTIONS",
|
|
|
|
"LSAN_OPTIONS",
|
|
|
|
"MSAN_OPTIONS",
|
|
|
|
"UBSAN_OPTIONS",
|
2015-06-04 00:12:55 +00:00
|
|
|
"COMPILER_PATH",
|
|
|
|
"RC_DEBUG_OPTIONS",
|
2012-07-31 15:43:11 +00:00
|
|
|
"CINDEXTEST_PREAMBLE_FILE",
|
|
|
|
"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 06:39:33 +00:00
|
|
|
"LIBCLANG_CODE_COMPLETION_LOGGING",
|
|
|
|
"XRAY_OPTIONS",
|
|
|
|
]
|
2023-03-27 22:48:17 +08:00
|
|
|
# Clang/MSVC may refer to %INCLUDE%. vsvarsall.bat sets it.
|
|
|
|
if not (platform.system() == "Windows" and target_is_msvc):
|
2012-07-31 15:43:11 +00:00
|
|
|
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 11:00:19 +00:00
|
|
|
# Tweak PATH to include llvm tools dir.
|
2017-09-15 22:10:46 +00: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 11:00:19 +00:00
|
|
|
config.environment["PATH"] = path
|
|
|
|
|
2014-05-14 19:10:43 +00:00
|
|
|
# Help MSVS link.exe find the standard libraries.
|
2015-02-20 23:35:19 +00:00
|
|
|
# Make sure we only try to use it when targetting Windows.
|
2023-03-27 22:48:17 +08:00
|
|
|
if platform.system() == "Windows" and target_is_msvc:
|
2014-05-14 19:10:43 +00:00
|
|
|
config.environment["LIB"] = os.environ["LIB"]
|
|
|
|
|
2018-07-10 02:02:21 +00:00
|
|
|
config.available_features.add(config.host_os.lower())
|
|
|
|
|
2022-05-20 14:21:58 -07:00
|
|
|
if config.target_triple.startswith("ppc") or config.target_triple.startswith("powerpc"):
|
2022-05-20 13:56:25 -07:00
|
|
|
config.available_features.add("ppc")
|
|
|
|
|
2016-01-28 00:35:17 +00:00
|
|
|
if re.match(r"^x86_64.*-linux", config.target_triple):
|
2018-07-10 02:02:21 +00:00
|
|
|
config.available_features.add("x86_64-linux")
|
2016-01-28 00:35:17 +00:00
|
|
|
|
2020-05-10 11:01:06 -07:00
|
|
|
config.available_features.add("host-byteorder-" + sys.byteorder + "-endian")
|
|
|
|
|
2023-05-25 18:55:47 +00:00
|
|
|
if config.have_zlib:
|
2019-01-29 12:00:01 +00:00
|
|
|
config.available_features.add("zlib")
|
2024-09-09 19:21:59 -07:00
|
|
|
config.substitutions.append(("%zlib_include_dir", config.zlib_include_dir))
|
|
|
|
config.substitutions.append(("%zlib_library", config.zlib_library))
|
2019-01-29 12:00:01 +00:00
|
|
|
|
2023-08-14 17:56:22 -07:00
|
|
|
if config.have_internal_symbolizer:
|
|
|
|
config.available_features.add("internal_symbolizer")
|
|
|
|
|
2025-03-26 04:59:35 +05:30
|
|
|
if config.have_disable_symbolizer_path_search:
|
|
|
|
config.available_features.add("disable_symbolizer_path_search")
|
|
|
|
|
|
|
|
|
2012-07-31 15:43:11 +00: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""",
|
|
|
|
)
|
|
|
|
)
|
2023-05-17 16:59:41 +02:00
|
|
|
|
2019-12-14 17:03:48 +01: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-13 17:08:19 +01: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
|
|
|
|
|
2023-05-17 16:59:41 +02:00
|
|
|
|
2020-10-13 17:08:19 +01:00
|
|
|
emulator = get_lit_conf("emulator", None)
|
2023-05-17 16:59:41 +02:00
|
|
|
|
2020-10-13 17:08:19 +01:00
|
|
|
|
2021-02-23 09:22:01 -08:00
|
|
|
def get_ios_commands_dir():
|
|
|
|
return os.path.join(
|
|
|
|
config.compiler_rt_src_root, "test", "sanitizer_common", "ios_commands"
|
|
|
|
)
|
2023-05-17 16:59:41 +02:00
|
|
|
|
2021-02-23 09:22:01 -08:00
|
|
|
|
2025-03-26 04:59:35 +05:30
|
|
|
# When cmake flag to disable path search is set, symbolizer is not allowed to search in $PATH,
|
|
|
|
# need to specify it via XXX_SYMBOLIZER_PATH
|
|
|
|
tool_symbolizer_path_list = [
|
|
|
|
"ASAN_SYMBOLIZER_PATH",
|
|
|
|
"HWASAN_SYMBOLIZER_PATH",
|
|
|
|
"RTSAN_SYMBOLIZER_PATH",
|
|
|
|
"TSAN_SYMBOLIZER_PATH",
|
|
|
|
"MSAN_SYMBOLIZER_PATH",
|
|
|
|
"LSAN_SYMBOLIZER_PATH",
|
|
|
|
"UBSAN_SYMBOLIZER_PATH",
|
|
|
|
]
|
|
|
|
|
|
|
|
if config.have_disable_symbolizer_path_search:
|
|
|
|
symbolizer_path = os.path.join(config.llvm_tools_dir, "llvm-symbolizer")
|
|
|
|
|
|
|
|
for sanitizer in tool_symbolizer_path_list:
|
|
|
|
if sanitizer not in config.environment:
|
|
|
|
config.environment[sanitizer] = symbolizer_path
|
|
|
|
|
2025-03-27 16:02:40 -04:00
|
|
|
env_utility = "/opt/freeware/bin/env" if config.host_os == "AIX" else "env"
|
2025-03-26 04:59:35 +05:30
|
|
|
env_unset_command = " ".join(f"-u {var}" for var in tool_symbolizer_path_list)
|
|
|
|
config.substitutions.append(
|
2025-03-27 16:02:40 -04:00
|
|
|
("%env_unset_tool_symbolizer_path", f"{env_utility} {env_unset_command}")
|
2025-03-26 04:59:35 +05:30
|
|
|
)
|
|
|
|
|
2014-04-30 21:32:30 +00:00
|
|
|
# Allow tests to be executed on a simulator or remotely.
|
2020-10-13 17:08:19 +01:00
|
|
|
if emulator:
|
|
|
|
config.substitutions.append(("%run", emulator))
|
2017-04-26 20:38:24 +00:00
|
|
|
config.substitutions.append(("%env ", "env "))
|
2018-09-17 13:33:44 +00: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 04:55:35 +00:00
|
|
|
config.compile_wrapper = ""
|
2018-06-20 13:33:42 +00: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.
|
2023-05-17 16:59:41 +02:00
|
|
|
#
|
2018-06-20 13:33:42 +00:00
|
|
|
# =========================================================================
|
|
|
|
# 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
|
|
|
|
# =========================================================================
|
2023-05-17 16:59:41 +02:00
|
|
|
|
2018-06-20 13:33:42 +00:00
|
|
|
ios_or_iossim = "iossim" if config.apple_platform.endswith("sim") else "ios"
|
2023-05-17 16:59:41 +02:00
|
|
|
|
2017-04-28 04:55:35 +00:00
|
|
|
config.available_features.add("ios")
|
2018-09-03 08:40:19 +00:00
|
|
|
device_id_env = "SANITIZER_" + ios_or_iossim.upper() + "_TEST_DEVICE_IDENTIFIER"
|
2018-06-20 13:33:42 +00:00
|
|
|
if ios_or_iossim == "iossim":
|
|
|
|
config.available_features.add("iossim")
|
2018-09-03 08:40:19 +00: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
|
2023-05-17 16:59:41 +02:00
|
|
|
)
|
2018-09-03 08:40:19 +00:00
|
|
|
)
|
2018-06-20 13:33:42 +00:00
|
|
|
if config.apple_platform != "ios" and config.apple_platform != "iossim":
|
|
|
|
config.available_features.add(config.apple_platform)
|
2023-05-17 16:59:41 +02:00
|
|
|
|
2021-02-23 09:22:01 -08:00
|
|
|
ios_commands_dir = get_ios_commands_dir()
|
2023-05-17 16:59:41 +02:00
|
|
|
|
2018-06-20 13:33:42 +00: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")
|
2023-05-17 16:59:41 +02:00
|
|
|
|
2018-06-20 13:33:42 +00:00
|
|
|
if device_id_env in os.environ:
|
|
|
|
config.environment[device_id_env] = os.environ[device_id_env]
|
2017-04-26 18:59:22 +00:00
|
|
|
config.substitutions.append(("%run", run_wrapper))
|
2017-04-26 20:38:24 +00:00
|
|
|
config.substitutions.append(("%env ", env_wrapper + " "))
|
2018-09-17 13:33:44 +00: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 04:55:35 +00:00
|
|
|
config.compile_wrapper = compile_wrapper
|
2023-05-17 16:59:41 +02:00
|
|
|
|
2018-09-24 09:30:33 +00:00
|
|
|
try:
|
2020-04-29 14:33:19 -07:00
|
|
|
prepare_output = (
|
|
|
|
subprocess.check_output(
|
|
|
|
[prepare_script, config.apple_platform, config.clang]
|
2023-05-17 16:59:41 +02:00
|
|
|
)
|
2020-04-29 14:33:19 -07:00
|
|
|
.decode()
|
|
|
|
.strip()
|
2023-05-17 16:59:41 +02:00
|
|
|
)
|
2018-09-24 09:30:33 +00:00
|
|
|
except subprocess.CalledProcessError as e:
|
|
|
|
print("Command failed:")
|
|
|
|
print(e.output)
|
|
|
|
raise e
|
2018-06-20 13:33:42 +00: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 05:13:56 +00: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",
|
|
|
|
)
|
|
|
|
+ " "
|
2023-05-17 16:59:41 +02:00
|
|
|
)
|
2017-09-16 05:13:56 +00:00
|
|
|
config.compile_wrapper = compile_wrapper
|
|
|
|
config.substitutions.append(("%run", ""))
|
|
|
|
config.substitutions.append(("%env ", "env "))
|
2017-04-26 18:59:22 +00:00
|
|
|
else:
|
|
|
|
config.substitutions.append(("%run", ""))
|
2017-04-26 20:38:24 +00:00
|
|
|
config.substitutions.append(("%env ", "env "))
|
2018-09-17 13:33:44 +00:00
|
|
|
# When running locally %device_rm is a no-op.
|
|
|
|
config.substitutions.append(("%device_rm", "echo "))
|
2017-04-28 04:55:35 +00:00
|
|
|
config.compile_wrapper = ""
|
2014-04-30 21:32:30 +00:00
|
|
|
|
2014-08-28 09:25:06 +00:00
|
|
|
# Define CHECK-%os to check for OS-dependent output.
|
|
|
|
config.substitutions.append(("CHECK-%os", ("CHECK-" + config.host_os)))
|
|
|
|
|
2016-10-06 09:58:11 +00:00
|
|
|
# Define %arch to check for architecture-dependent output.
|
|
|
|
config.substitutions.append(("%arch", (config.host_arch)))
|
2023-05-17 16:59:41 +02:00
|
|
|
|
2015-07-02 22:08:38 +00: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 00:24:22 +00:00
|
|
|
config.expect_crash = "not KillTheDoctor "
|
2015-07-02 22:08:38 +00:00
|
|
|
else:
|
2016-06-25 00:24:22 +00:00
|
|
|
config.expect_crash = "not --crash "
|
|
|
|
|
|
|
|
config.substitutions.append(("%expect_crash ", config.expect_crash))
|
2015-07-02 22:08:38 +00:00
|
|
|
|
2016-02-23 01:58:56 +00:00
|
|
|
target_arch = getattr(config, "target_arch", None)
|
|
|
|
if target_arch:
|
|
|
|
config.available_features.add(target_arch + "-target-arch")
|
2017-08-28 20:30:12 +00:00
|
|
|
if target_arch in ["x86_64", "i386"]:
|
2016-02-23 01:58:56 +00:00
|
|
|
config.available_features.add("x86-target-arch")
|
2016-08-27 16:06:36 +00:00
|
|
|
config.available_features.add(target_arch + "-" + config.host_os.lower())
|
2013-10-25 23:03:34 +00: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 14:22:00 +00:00
|
|
|
|
2019-04-04 17:25:43 +00:00
|
|
|
libdispatch = getattr(config, "compiler_rt_intercept_libdispatch", False)
|
2019-03-14 20:59:41 +00:00
|
|
|
if libdispatch:
|
|
|
|
config.available_features.add("libdispatch")
|
2019-03-07 18:15:23 +00:00
|
|
|
|
2015-06-25 00:57:42 +00:00
|
|
|
sanitizer_can_use_cxxabi = getattr(config, "sanitizer_can_use_cxxabi", True)
|
|
|
|
if sanitizer_can_use_cxxabi:
|
|
|
|
config.available_features.add("cxxabi")
|
|
|
|
|
2021-09-22 15:25:05 -07:00
|
|
|
if not getattr(config, "sanitizer_uses_static_cxxabi", False):
|
|
|
|
config.available_features.add("shared_cxxabi")
|
|
|
|
|
2021-10-06 11:09:29 -07:00
|
|
|
if not getattr(config, "sanitizer_uses_static_unwind", False):
|
|
|
|
config.available_features.add("shared_unwind")
|
|
|
|
|
2015-08-11 00:33:07 +00:00
|
|
|
if config.has_lld:
|
2017-04-21 18:11:23 +00:00
|
|
|
config.available_features.add("lld-available")
|
|
|
|
|
2024-01-23 11:19:44 +00:00
|
|
|
if config.aarch64_sme:
|
|
|
|
config.available_features.add("aarch64-sme-available")
|
|
|
|
|
2017-04-21 18:11:23 +00:00
|
|
|
if config.use_lld:
|
2015-08-11 00:33:07 +00:00
|
|
|
config.available_features.add("lld")
|
|
|
|
|
2016-01-22 20:26:10 +00:00
|
|
|
if config.can_symbolize:
|
|
|
|
config.available_features.add("can-symbolize")
|
|
|
|
|
2019-06-17 17:45:34 +00:00
|
|
|
if config.gwp_asan:
|
|
|
|
config.available_features.add("gwp_asan")
|
|
|
|
|
2014-06-10 14:22:00 +00:00
|
|
|
lit.util.usePlatformSdkOnDarwin(config, lit_config)
|
2015-05-19 23:50:13 +00:00
|
|
|
|
2020-08-12 15:02:42 -07: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")
|
|
|
|
)
|
|
|
|
|
[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 08:37:25 +00:00
|
|
|
if config.host_os == "Darwin":
|
2017-03-16 22:35:34 +00:00
|
|
|
osx_version = (10, 0, 0)
|
2023-05-17 16:59:41 +02:00
|
|
|
try:
|
2020-04-29 16:40:58 -04:00
|
|
|
osx_version = subprocess.check_output(
|
|
|
|
["sw_vers", "-productVersion"], universal_newlines=True
|
2023-05-17 16:59:41 +02:00
|
|
|
)
|
2016-03-29 18:54:29 +00:00
|
|
|
osx_version = tuple(int(x) for x in osx_version.split("."))
|
2017-03-16 22:35:34 +00:00
|
|
|
if len(osx_version) == 2:
|
|
|
|
osx_version = (osx_version[0], osx_version[1], 0)
|
2016-03-29 18:54:29 +00:00
|
|
|
if osx_version >= (10, 11):
|
|
|
|
config.available_features.add("osx-autointerception")
|
|
|
|
config.available_features.add("osx-ld64-live_support")
|
2023-04-10 21:17:37 -07:00
|
|
|
if osx_version >= (13, 1):
|
|
|
|
config.available_features.add("jit-compatible-osx-swift-runtime")
|
2020-04-29 16:40:58 -04:00
|
|
|
except subprocess.CalledProcessError:
|
2023-05-17 16:59:41 +02:00
|
|
|
pass
|
|
|
|
|
2017-03-16 22:35:34 +00:00
|
|
|
config.darwin_osx_version = osx_version
|
2023-05-17 16:59:41 +02:00
|
|
|
|
2017-01-06 21:45:05 +00:00
|
|
|
# Detect x86_64h
|
2023-05-17 16:59:41 +02:00
|
|
|
try:
|
2017-01-06 21:45:05 +00:00
|
|
|
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")
|
2023-05-17 16:59:41 +02:00
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
2018-06-21 15:21:24 +00: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
|
2023-05-17 16:59:41 +02:00
|
|
|
|
2020-08-12 15:02:42 -07:00
|
|
|
def get_macos_aligned_version(macos_vers):
|
|
|
|
platform = config.apple_platform
|
|
|
|
if platform == "osx":
|
|
|
|
return macos_vers
|
2023-05-17 16:59:41 +02:00
|
|
|
|
2020-08-12 15:02:42 -07:00
|
|
|
macos_major, macos_minor = macos_vers
|
|
|
|
assert macos_major >= 10
|
2023-05-17 16:59:41 +02:00
|
|
|
|
2020-08-12 15:02:42 -07:00
|
|
|
if macos_major == 10: # macOS 10.x
|
|
|
|
major = macos_minor
|
|
|
|
minor = 0
|
|
|
|
else: # macOS 11+
|
|
|
|
major = macos_major + 5
|
|
|
|
minor = macos_minor
|
2023-05-17 16:59:41 +02:00
|
|
|
|
2020-08-12 15:02:42 -07:00
|
|
|
assert major >= 11
|
2023-05-17 16:59:41 +02:00
|
|
|
|
2020-08-12 15:02:42 -07:00
|
|
|
if platform.startswith("ios") or platform.startswith("tvos"):
|
|
|
|
major -= 2
|
|
|
|
elif platform.startswith("watch"):
|
|
|
|
major -= 9
|
2023-05-17 16:59:41 +02:00
|
|
|
else:
|
2020-08-12 15:02:42 -07:00
|
|
|
lit_config.fatal("Unsupported apple platform '{}'".format(platform))
|
2023-05-17 16:59:41 +02:00
|
|
|
|
2020-08-12 15:02:42 -07:00
|
|
|
return (major, minor)
|
2023-05-17 16:59:41 +02:00
|
|
|
|
2020-08-12 15:02:42 -07:00
|
|
|
for vers in min_macos_deployment_target_substitutions:
|
|
|
|
flag = config.apple_platform_min_deployment_target_flag
|
|
|
|
major, minor = get_macos_aligned_version(vers)
|
2024-06-29 11:06:03 -07:00
|
|
|
apple_device = ""
|
|
|
|
sim = ""
|
|
|
|
if "target" in flag:
|
|
|
|
apple_device = config.apple_platform.split("sim")[0]
|
2022-07-25 20:47:15 -07:00
|
|
|
sim = "-simulator" if "sim" in config.apple_platform else ""
|
2024-06-29 11:06:03 -07:00
|
|
|
|
|
|
|
config.substitutions.append(
|
|
|
|
(
|
|
|
|
"%%min_macos_deployment_target=%s.%s" % vers,
|
|
|
|
"{}={}{}.{}{}".format(flag, apple_device, major, minor, sim),
|
2022-07-25 20:47:15 -07:00
|
|
|
)
|
2024-06-29 11:06:03 -07:00
|
|
|
)
|
2016-11-21 21:48:25 +00:00
|
|
|
else:
|
2020-08-12 15:02:42 -07:00
|
|
|
for vers in min_macos_deployment_target_substitutions:
|
|
|
|
config.substitutions.append(("%%min_macos_deployment_target=%s.%s" % vers, ""))
|
2016-11-21 21:48:25 +00:00
|
|
|
|
2017-10-16 18:03:11 +00:00
|
|
|
if config.android:
|
2019-01-15 22:06:48 +00:00
|
|
|
env = os.environ.copy()
|
|
|
|
if config.android_serial:
|
|
|
|
env["ANDROID_SERIAL"] = config.android_serial
|
|
|
|
config.environment["ANDROID_SERIAL"] = config.android_serial
|
2023-05-17 16:59:41 +02:00
|
|
|
|
2017-10-16 18:03:11 +00:00
|
|
|
adb = os.environ.get("ADB", "adb")
|
2023-05-17 16:59:41 +02:00
|
|
|
|
2020-10-21 12:07:52 -07:00
|
|
|
# These are needed for tests to upload/download temp files, such as
|
|
|
|
# suppression-files, to device.
|
2021-07-20 17:37:36 -07:00
|
|
|
config.substitutions.append(("%device_rundir/", "/data/local/tmp/Output/"))
|
2020-10-21 12:07:52 -07: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-16 17:53:34 -05:00
|
|
|
config.substitutions.append(
|
|
|
|
("%device_rm", "%s -s '%s' shell 'rm ' " % (adb, env["ANDROID_SERIAL"]))
|
|
|
|
)
|
2023-05-17 16:59:41 +02:00
|
|
|
|
2017-10-16 18:03:11 +00:00
|
|
|
try:
|
2019-01-15 22:06:48 +00:00
|
|
|
android_api_level_str = subprocess.check_output(
|
|
|
|
[adb, "shell", "getprop", "ro.build.version.sdk"], env=env
|
|
|
|
).rstrip()
|
2020-10-17 01:57:02 -04:00
|
|
|
android_api_codename = (
|
|
|
|
subprocess.check_output(
|
|
|
|
[adb, "shell", "getprop", "ro.build.version.codename"], env=env
|
2023-05-17 16:59:41 +02:00
|
|
|
)
|
2020-10-17 01:57:02 -04:00
|
|
|
.rstrip()
|
|
|
|
.decode("utf-8")
|
2023-05-17 16:59:41 +02:00
|
|
|
)
|
2017-10-16 18:03:11 +00: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)
|
2023-05-17 16:59:41 +02:00
|
|
|
)
|
2020-11-14 01:52:44 -08:00
|
|
|
android_api_level = min(android_api_level, int(config.android_api_level))
|
2021-05-27 14:53:49 -07:00
|
|
|
for required in [26, 28, 29, 30]:
|
2020-11-17 23:43:08 -08:00
|
|
|
if android_api_level >= required:
|
|
|
|
config.available_features.add("android-%s" % required)
|
2020-12-27 21:50:47 -08:00
|
|
|
# FIXME: Replace with appropriate version when availible.
|
2020-11-14 23:22:57 -08:00
|
|
|
if android_api_level > 30 or (
|
|
|
|
android_api_level == 30 and android_api_codename == "S"
|
|
|
|
):
|
2020-10-17 01:57:02 -04:00
|
|
|
config.available_features.add("android-thread-properties-api")
|
2023-05-17 16:59:41 +02:00
|
|
|
|
2019-01-15 22:06:48 +00: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-21 12:07:52 -07:00
|
|
|
else:
|
2021-07-20 17:37:36 -07:00
|
|
|
config.substitutions.append(("%device_rundir/", ""))
|
2020-10-21 12:07:52 -07:00
|
|
|
config.substitutions.append(("%push_to_device", "echo "))
|
|
|
|
config.substitutions.append(("%adb_shell", "echo "))
|
2023-05-17 16:59:41 +02:00
|
|
|
|
2019-01-09 13:27:29 +00:00
|
|
|
if config.host_os == "Linux":
|
2023-06-26 13:40:22 +00:00
|
|
|
def add_glibc_versions(ver_string):
|
|
|
|
if config.android:
|
|
|
|
return
|
|
|
|
|
2019-01-09 13:27:29 +00:00
|
|
|
from distutils.version import LooseVersion
|
2023-05-17 16:59:41 +02:00
|
|
|
|
2023-06-26 13:40:22 +00:00
|
|
|
ver = LooseVersion(ver_string)
|
2023-05-05 17:11:06 -07:00
|
|
|
any_glibc = False
|
2024-08-02 10:10:15 -07:00
|
|
|
for required in [
|
|
|
|
"2.19",
|
|
|
|
"2.27",
|
|
|
|
"2.30",
|
|
|
|
"2.33",
|
|
|
|
"2.34",
|
|
|
|
"2.37",
|
|
|
|
"2.38",
|
|
|
|
"2.40",
|
|
|
|
]:
|
2020-11-17 23:43:08 -08:00
|
|
|
if ver >= LooseVersion(required):
|
2020-12-27 21:50:47 -08:00
|
|
|
config.available_features.add("glibc-" + required)
|
2023-05-05 17:11:06 -07:00
|
|
|
any_glibc = True
|
|
|
|
if any_glibc:
|
|
|
|
config.available_features.add("glibc")
|
2019-01-09 13:27:29 +00:00
|
|
|
|
2023-06-26 13:40:22 +00:00
|
|
|
# detect whether we are using glibc, and which version
|
|
|
|
cmd_args = [
|
|
|
|
config.clang.strip(),
|
|
|
|
f"--target={config.target_triple}",
|
|
|
|
"-xc",
|
|
|
|
"-",
|
|
|
|
"-o",
|
|
|
|
"-",
|
|
|
|
"-dM",
|
|
|
|
"-E",
|
|
|
|
] + shlex.split(config.target_cflags)
|
|
|
|
cmd = subprocess.Popen(
|
|
|
|
cmd_args,
|
|
|
|
stdout=subprocess.PIPE,
|
|
|
|
stdin=subprocess.PIPE,
|
|
|
|
stderr=subprocess.DEVNULL,
|
|
|
|
env={"LANG": "C"},
|
|
|
|
)
|
|
|
|
try:
|
|
|
|
sout, _ = cmd.communicate(b"#include <features.h>")
|
|
|
|
m = dict(re.findall(r"#define (__GLIBC__|__GLIBC_MINOR__) (\d+)", str(sout)))
|
|
|
|
add_glibc_versions(f"{m['__GLIBC__']}.{m['__GLIBC_MINOR__']}")
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
2017-09-15 22:10:46 +00:00
|
|
|
sancovcc_path = os.path.join(config.llvm_tools_dir, "sancov")
|
2016-01-27 23:51:36 +00:00
|
|
|
if os.path.exists(sancovcc_path):
|
|
|
|
config.available_features.add("has_sancovcc")
|
|
|
|
config.substitutions.append(("%sancovcc ", sancovcc_path))
|
2023-05-17 16:59:41 +02:00
|
|
|
|
2016-01-27 23:51:36 +00:00
|
|
|
|
2022-04-19 13:29:44 -04:00
|
|
|
def liblto_path():
|
|
|
|
return os.path.join(config.llvm_shlib_dir, "libLTO.dylib")
|
2023-05-17 16:59:41 +02:00
|
|
|
|
2022-04-19 13:29:44 -04:00
|
|
|
|
2015-05-19 23:50:13 +00:00
|
|
|
def is_darwin_lto_supported():
|
2022-04-19 13:29:44 -04:00
|
|
|
return os.path.exists(liblto_path())
|
2023-05-17 16:59:41 +02:00
|
|
|
|
2015-05-19 23:50:13 +00:00
|
|
|
|
2020-07-22 10:15:51 -07:00
|
|
|
def is_binutils_lto_supported():
|
2015-05-19 23:50:13 +00:00
|
|
|
if not os.path.exists(os.path.join(config.llvm_shlib_dir, "LLVMgold.so")):
|
2020-07-22 10:15:51 -07:00
|
|
|
return False
|
2023-05-17 16:59:41 +02:00
|
|
|
|
2020-07-22 10:15:51 -07:00
|
|
|
# We require both ld.bfd and ld.gold exist and support plugins. They are in
|
2015-05-19 23:50:13 +00:00
|
|
|
# the same repository 'binutils-gdb' and usually built together.
|
2020-07-22 10:15:51 -07:00
|
|
|
for exe in (config.gnu_ld_executable, config.gold_executable):
|
2023-05-17 16:59:41 +02:00
|
|
|
try:
|
[compiler-rt] [test] Handle missing ld.gold gracefully
Fix the is_binutils_lto_supported() function to handle missing
executables gracefully. Currently, the function does not catch
exceptions from subprocess.Popen() and therefore causes lit to crash
if config.gold_executable does not specify a valid executable:
```
lit: /usr/lib/python3.11/site-packages/lit/TestingConfig.py:136: fatal: unable to parse config file '/tmp/portage/sys-libs/compiler-rt-
15.0.0/work/compiler-rt/test/lit.common.cfg.py', traceback: Traceback (most recent call last):
File "/usr/lib/python3.11/site-packages/lit/TestingConfig.py", line 125, in load_from_path
exec(compile(data, path, 'exec'), cfg_globals, None)
File "/tmp/portage/sys-libs/compiler-rt-15.0.0/work/compiler-rt/test/lit.common.cfg.py", line 561, in <module>
if is_binutils_lto_supported():
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/portage/sys-libs/compiler-rt-15.0.0/work/compiler-rt/test/lit.common.cfg.py", line 543, in is_binutils_lto_supported
ld_cmd = subprocess.Popen([exe, '--help'], stdout=subprocess.PIPE, env={'LANG': 'C'})
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/subprocess.py", line 1022, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.11/subprocess.py", line 1899, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'GOLD_EXECUTABLE-NOTFOUND'
```
Differential Revision: https://reviews.llvm.org/D133358
2022-09-06 15:40:10 +02:00
|
|
|
ld_cmd = subprocess.Popen(
|
|
|
|
[exe, "--help"], stdout=subprocess.PIPE, env={"LANG": "C"}
|
2023-05-17 16:59:41 +02:00
|
|
|
)
|
[compiler-rt] [test] Handle missing ld.gold gracefully
Fix the is_binutils_lto_supported() function to handle missing
executables gracefully. Currently, the function does not catch
exceptions from subprocess.Popen() and therefore causes lit to crash
if config.gold_executable does not specify a valid executable:
```
lit: /usr/lib/python3.11/site-packages/lit/TestingConfig.py:136: fatal: unable to parse config file '/tmp/portage/sys-libs/compiler-rt-
15.0.0/work/compiler-rt/test/lit.common.cfg.py', traceback: Traceback (most recent call last):
File "/usr/lib/python3.11/site-packages/lit/TestingConfig.py", line 125, in load_from_path
exec(compile(data, path, 'exec'), cfg_globals, None)
File "/tmp/portage/sys-libs/compiler-rt-15.0.0/work/compiler-rt/test/lit.common.cfg.py", line 561, in <module>
if is_binutils_lto_supported():
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/portage/sys-libs/compiler-rt-15.0.0/work/compiler-rt/test/lit.common.cfg.py", line 543, in is_binutils_lto_supported
ld_cmd = subprocess.Popen([exe, '--help'], stdout=subprocess.PIPE, env={'LANG': 'C'})
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/subprocess.py", line 1022, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.11/subprocess.py", line 1899, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'GOLD_EXECUTABLE-NOTFOUND'
```
Differential Revision: https://reviews.llvm.org/D133358
2022-09-06 15:40:10 +02:00
|
|
|
ld_out = ld_cmd.stdout.read().decode()
|
|
|
|
ld_cmd.wait()
|
|
|
|
except OSError:
|
2015-05-19 23:50:13 +00:00
|
|
|
return False
|
2020-07-22 10:15:51 -07:00
|
|
|
if not "-plugin" in ld_out:
|
|
|
|
return False
|
2015-05-19 23:50:13 +00:00
|
|
|
|
[compiler-rt] [test] Handle missing ld.gold gracefully
Fix the is_binutils_lto_supported() function to handle missing
executables gracefully. Currently, the function does not catch
exceptions from subprocess.Popen() and therefore causes lit to crash
if config.gold_executable does not specify a valid executable:
```
lit: /usr/lib/python3.11/site-packages/lit/TestingConfig.py:136: fatal: unable to parse config file '/tmp/portage/sys-libs/compiler-rt-
15.0.0/work/compiler-rt/test/lit.common.cfg.py', traceback: Traceback (most recent call last):
File "/usr/lib/python3.11/site-packages/lit/TestingConfig.py", line 125, in load_from_path
exec(compile(data, path, 'exec'), cfg_globals, None)
File "/tmp/portage/sys-libs/compiler-rt-15.0.0/work/compiler-rt/test/lit.common.cfg.py", line 561, in <module>
if is_binutils_lto_supported():
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/portage/sys-libs/compiler-rt-15.0.0/work/compiler-rt/test/lit.common.cfg.py", line 543, in is_binutils_lto_supported
ld_cmd = subprocess.Popen([exe, '--help'], stdout=subprocess.PIPE, env={'LANG': 'C'})
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/subprocess.py", line 1022, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.11/subprocess.py", line 1899, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'GOLD_EXECUTABLE-NOTFOUND'
```
Differential Revision: https://reviews.llvm.org/D133358
2022-09-06 15:40:10 +02:00
|
|
|
return True
|
2015-05-19 23:50:13 +00:00
|
|
|
|
|
|
|
|
2024-06-07 12:29:31 -04:00
|
|
|
def is_lld_lto_supported():
|
|
|
|
# LLD does support LTO, but we require it to be built with the latest
|
|
|
|
# changes to claim support. Otherwise older copies of LLD may not
|
|
|
|
# understand new bitcode versions.
|
|
|
|
return os.path.exists(os.path.join(config.llvm_tools_dir, "lld"))
|
|
|
|
|
|
|
|
|
2015-07-08 22:10:34 +00:00
|
|
|
def is_windows_lto_supported():
|
2023-03-27 22:48:17 +08:00
|
|
|
if not target_is_msvc:
|
|
|
|
return True
|
2015-08-06 18:37:54 +00:00
|
|
|
return os.path.exists(os.path.join(config.llvm_tools_dir, "lld-link.exe"))
|
2020-07-22 10:15:51 -07:00
|
|
|
|
2023-05-17 16:59:41 +02:00
|
|
|
|
2020-07-22 10:15:51 -07:00
|
|
|
if config.host_os == "Darwin" and is_darwin_lto_supported():
|
|
|
|
config.lto_supported = True
|
2022-04-19 13:29:44 -04:00
|
|
|
config.lto_flags = ["-Wl,-lto_library," + liblto_path()]
|
2020-07-22 10:15:51 -07:00
|
|
|
elif config.host_os in ["Linux", "FreeBSD", "NetBSD"]:
|
2015-05-19 23:50:13 +00:00
|
|
|
config.lto_supported = False
|
2024-06-07 12:29:31 -04:00
|
|
|
if config.use_lld and is_lld_lto_supported():
|
2020-07-22 10:15:51 -07:00
|
|
|
config.lto_supported = True
|
|
|
|
if is_binutils_lto_supported():
|
|
|
|
config.available_features.add("binutils_lto")
|
|
|
|
config.lto_supported = True
|
2023-05-17 16:59:41 +02:00
|
|
|
|
[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-01 19:36:29 +00:00
|
|
|
if config.lto_supported:
|
2020-07-22 10:15:51 -07:00
|
|
|
if config.use_lld:
|
|
|
|
config.lto_flags = ["-fuse-ld=lld"]
|
|
|
|
else:
|
|
|
|
config.lto_flags = ["-fuse-ld=gold"]
|
2015-07-08 22:10:34 +00:00
|
|
|
elif config.host_os == "Windows" and is_windows_lto_supported():
|
|
|
|
config.lto_supported = True
|
2017-11-17 19:49:41 +00:00
|
|
|
config.lto_flags = ["-fuse-ld=lld"]
|
2015-05-19 23:50:13 +00:00
|
|
|
else:
|
|
|
|
config.lto_supported = False
|
2015-07-29 18:12:45 +00:00
|
|
|
|
2016-09-14 14:09:18 +00:00
|
|
|
if config.lto_supported:
|
|
|
|
config.available_features.add("lto")
|
2017-04-21 18:11:23 +00:00
|
|
|
if config.use_thinlto:
|
|
|
|
config.available_features.add("thinlto")
|
|
|
|
config.lto_flags += ["-flto=thin"]
|
|
|
|
else:
|
|
|
|
config.lto_flags += ["-flto"]
|
2018-07-19 15:32:48 +00:00
|
|
|
|
2019-01-14 19:18:34 +00:00
|
|
|
if config.have_rpc_xdr_h:
|
|
|
|
config.available_features.add("sunrpc")
|
|
|
|
|
2015-09-02 20:45:36 +00: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 00:25:01 +00:00
|
|
|
|
2019-02-27 19:06:20 +00:00
|
|
|
# No throttling on non-Darwin platforms.
|
|
|
|
lit_config.parallelism_groups["shadow-memory"] = None
|
2023-05-17 16:59:41 +02:00
|
|
|
|
2019-02-27 19:06:20 +00: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"
|
2023-05-17 16:59:41 +02:00
|
|
|
|
2019-02-27 19:06:20 +00:00
|
|
|
# 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-30 10:24:11 -07:00
|
|
|
else:
|
|
|
|
lit_config.warning(
|
|
|
|
"Throttling sanitizer tests that require shadow memory on Darwin"
|
|
|
|
)
|
2019-02-27 19:06:20 +00:00
|
|
|
lit_config.parallelism_groups["shadow-memory"] = 3
|
2018-01-20 02:07:30 +00:00
|
|
|
|
2018-06-14 20:29:47 +00: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),
|
|
|
|
)
|
2023-05-17 16:59:41 +02:00
|
|
|
)
|
2018-06-30 21:35:05 +00:00
|
|
|
elif config.host_os in ("FreeBSD", "NetBSD", "OpenBSD"):
|
2018-06-14 20:29:47 +00:00
|
|
|
config.substitutions.append(
|
|
|
|
(
|
|
|
|
"%ld_flags_rpath_exe" + postfix,
|
2023-11-17 22:40:21 +01:00
|
|
|
r"-Wl,-z,origin -Wl,-rpath,\$ORIGIN -L%T -l%xdynamiclib_namespec"
|
2018-06-14 20:29:47 +00:00
|
|
|
+ postfix,
|
|
|
|
)
|
2023-05-17 16:59:41 +02:00
|
|
|
)
|
2018-06-14 20:29:47 +00:00
|
|
|
config.substitutions.append(("%ld_flags_rpath_so" + postfix, ""))
|
|
|
|
elif config.host_os == "Linux":
|
|
|
|
config.substitutions.append(
|
|
|
|
(
|
|
|
|
"%ld_flags_rpath_exe" + postfix,
|
2023-11-17 22:40:21 +01:00
|
|
|
r"-Wl,-rpath,\$ORIGIN -L%T -l%xdynamiclib_namespec" + postfix,
|
2018-06-14 20:29:47 +00:00
|
|
|
)
|
2023-05-17 16:59:41 +02:00
|
|
|
)
|
2018-06-14 20:29:47 +00:00
|
|
|
config.substitutions.append(("%ld_flags_rpath_so" + postfix, ""))
|
|
|
|
elif config.host_os == "SunOS":
|
|
|
|
config.substitutions.append(
|
|
|
|
(
|
|
|
|
"%ld_flags_rpath_exe" + postfix,
|
2023-11-17 22:40:21 +01:00
|
|
|
r"-Wl,-R\$ORIGIN -L%T -l%xdynamiclib_namespec" + postfix,
|
2018-06-14 20:29:47 +00:00
|
|
|
)
|
2023-05-17 16:59:41 +02:00
|
|
|
)
|
2018-06-14 20:29:47 +00:00
|
|
|
config.substitutions.append(("%ld_flags_rpath_so" + postfix, ""))
|
2023-05-17 16:59:41 +02:00
|
|
|
|
2018-06-14 20:29:47 +00:00
|
|
|
# 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),
|
|
|
|
)
|
2023-05-17 16:59:41 +02:00
|
|
|
)
|
2018-06-14 20:29:47 +00:00
|
|
|
config.substitutions.append(("%xdynamiclib_namespec", "%basename_t.dynamic"))
|
2017-10-05 20:00:07 +00:00
|
|
|
|
2017-10-06 20:53:40 +00: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-24 19:39:44 -07:00
|
|
|
if lit.util.which("log"):
|
2020-03-26 18:17:53 -07: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")
|
2023-05-17 16:59:41 +02:00
|
|
|
else:
|
2020-03-26 18:17:53 -07:00
|
|
|
lit_config.warning("log command found but cannot queried")
|
|
|
|
else:
|
2020-03-24 19:39:44 -07:00
|
|
|
lit_config.warning("log command not found. Some tests will be skipped.")
|
2017-10-06 20:53:40 +00:00
|
|
|
elif config.android:
|
|
|
|
config.default_sanitizer_opts += ["abort_on_error=0"]
|
2017-10-10 23:37:26 +00: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-16 23:28:25 +00: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-01 19:36:29 +00:00
|
|
|
|
2020-09-03 15:21:20 -07: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-03 14: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-01 19:36:29 +00: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
|
|
|
|
|
2024-03-22 15:29:36 -07:00
|
|
|
if config.host_os == "Darwin":
|
|
|
|
if getattr(config, "darwin_linker_version", None):
|
|
|
|
extra_cflags += ["-mlinker-version=" + config.darwin_linker_version]
|
|
|
|
|
2020-12-08 11:46:36 +00: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-01 19:36:29 +00:00
|
|
|
config.clang = (
|
|
|
|
" " + " ".join(run_wrapper + [config.compile_wrapper, config.clang]) + " "
|
2023-05-17 16:59:41 +02:00
|
|
|
)
|
[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-01 19:36:29 +00:00
|
|
|
config.target_cflags = " " + " ".join(target_cflags + extra_cflags) + " "
|
2021-02-23 09:22:01 -08:00
|
|
|
|
|
|
|
if config.host_os == "Darwin":
|
|
|
|
config.substitutions.append(
|
2023-05-17 16:59:41 +02:00
|
|
|
(
|
2021-07-23 13:19:54 -07:00
|
|
|
"%get_pid_from_output",
|
2021-02-23 09:22:01 -08:00
|
|
|
"{} {}/get_pid_from_output.py".format(
|
2023-05-11 23:06:01 -07:00
|
|
|
shlex.quote(config.python_executable),
|
|
|
|
shlex.quote(get_ios_commands_dir()),
|
2023-05-17 16:59:41 +02:00
|
|
|
),
|
2021-02-23 09:22:01 -08:00
|
|
|
)
|
|
|
|
)
|
|
|
|
config.substitutions.append(
|
2021-07-23 13:19:54 -07:00
|
|
|
(
|
|
|
|
"%print_crashreport_for_pid",
|
2021-02-23 09:22:01 -08:00
|
|
|
"{} {}/print_crashreport_for_pid.py".format(
|
2023-05-11 23:06:01 -07:00
|
|
|
shlex.quote(config.python_executable),
|
|
|
|
shlex.quote(get_ios_commands_dir()),
|
2023-05-17 16:59:41 +02:00
|
|
|
),
|
2021-02-23 09:22:01 -08:00
|
|
|
)
|
|
|
|
)
|
2023-02-04 18:04:05 +00:00
|
|
|
|
|
|
|
# It is not realistically possible to account for all options that could
|
|
|
|
# possibly be present in system and user configuration files, so disable
|
|
|
|
# default configs for the test runs. In particular, anything hardening
|
|
|
|
# related is likely to cause issues with sanitizer tests, because it may
|
2023-02-04 18:04:54 +00:00
|
|
|
# preempt something we're looking to trap (e.g. _FORTIFY_SOURCE vs our ASAN).
|
[compiler-rt] [test] Fix using toolchains that rely on Clang default configs (#113491)
The use of CLANG_NO_DEFAULT_CONFIG in the tests was added because some
Linux distributions had a global default config file, that added flags
relating to hardening, which interfere with the sanitizer tests. By
setting CLANG_NO_DEFAULT_CONFIG, the global default config files that
are found are ignored, and the sanitizers get the expected default
compiler behaviour.
(This was https://github.com/llvm/llvm-project/issues/60394, which was
fixed in 8ab762557fb057af1a3015211ee116a975027e78.)
However, some toolchains may rely on default config files for mandatory
parts required for functioning at all - setting things like sysroots,
-rtlib, -unwindlib, -stdlib, -fuse-ld etc. In such a case we can't
forcibly disable any default config, because it will break the otherwise
working toolchain.
Add a test for whether the compiler works while passing
--no-default-config to it. If the option is accepted and the toolchain
still works while that is set, set CLANG_NO_DEFAULT_CONFIG while running
tests.
(This adds a little bit of inconsistency, as we're testing for the
command line option, while using the environment variable. However doing
compile testing with an environment variable isn't quite as easily
doable, and passing an extra command line flag to all compile commands
while testing, is a bit clumsy - therefore this inconsistency.)
2024-10-24 23:45:14 +03:00
|
|
|
#
|
|
|
|
# Only set this if we know we can still build for the target while disabling
|
|
|
|
# default configs.
|
|
|
|
if config.has_no_default_config_flag:
|
|
|
|
config.environment["CLANG_NO_DEFAULT_CONFIG"] = "1"
|
2023-07-13 14:13:09 +02:00
|
|
|
|
2023-08-29 21:37:49 +00:00
|
|
|
if config.has_compiler_rt_libatomic:
|
|
|
|
base_lib = os.path.join(config.compiler_rt_libdir, "libclang_rt.atomic%s.so"
|
|
|
|
% config.target_suffix)
|
|
|
|
if sys.platform in ['win32'] and execute_external:
|
|
|
|
# Don't pass dosish path separator to msys bash.exe.
|
|
|
|
base_lib = base_lib.replace('\\', '/')
|
|
|
|
config.substitutions.append(("%libatomic", base_lib + f" -Wl,-rpath,{config.compiler_rt_libdir}"))
|
|
|
|
else:
|
|
|
|
config.substitutions.append(("%libatomic", "-latomic"))
|
|
|
|
|
2023-07-13 14:13:09 +02:00
|
|
|
# Set LD_LIBRARY_PATH to pick dynamic runtime up properly.
|
|
|
|
push_dynamic_library_lookup_path(config, config.compiler_rt_libdir)
|
|
|
|
|
|
|
|
# GCC-ASan uses dynamic runtime by default.
|
|
|
|
if config.compiler_id == "GNU":
|
|
|
|
gcc_dir = os.path.dirname(config.clang)
|
|
|
|
libasan_dir = os.path.join(gcc_dir, "..", "lib" + config.bits)
|
|
|
|
push_dynamic_library_lookup_path(config, libasan_dir)
|
2024-05-09 16:58:40 -07:00
|
|
|
|
|
|
|
|
|
|
|
# Help tests that make sure certain files are in-sync between compiler-rt and
|
|
|
|
# llvm.
|
|
|
|
config.substitutions.append(("%crt_src", config.compiler_rt_src_root))
|
|
|
|
config.substitutions.append(("%llvm_src", config.llvm_src_root))
|