brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.1 KiB · 3299051 Raw
166 lines · python
1# -*- Python -*-2 3import os4import platform5import re6import subprocess7import tempfile8 9import lit.formats10import lit.util11 12from lit.llvm import llvm_config13from lit.llvm.subst import ToolSubst14from lit.llvm.subst import FindTool15 16# Configuration file for the 'lit' test runner.17 18# name: The name of this test suite.19config.name = "BOLT"20 21# TODO: Consolidate the logic for turning on the internal shell by default for all LLVM test suites.22# See https://github.com/llvm/llvm-project/issues/106636 for more details.23#24# We prefer the lit internal shell which provides a better user experience on failures25# and is faster unless the user explicitly disables it with LIT_USE_INTERNAL_SHELL=026# env var.27use_lit_shell = True28lit_shell_env = os.environ.get("LIT_USE_INTERNAL_SHELL")29if lit_shell_env:30    use_lit_shell = lit.util.pythonize_bool(lit_shell_env)31 32# testFormat: The test format to use to interpret tests.33#34# For now we require '&&' between commands, until they get globally killed and35# the test runner updated.36config.test_format = lit.formats.ShTest(execute_external=not use_lit_shell)37 38# suffixes: A list of file extensions to treat as test files.39config.suffixes = [40    ".c",41    ".cpp",42    ".cppm",43    ".m",44    ".mm",45    ".cu",46    ".ll",47    ".cl",48    ".s",49    ".S",50    ".modulemap",51    ".test",52    ".rs",53]54 55# excludes: A list of directories to exclude from the testsuite. The 'Inputs'56# subdirectories contain auxiliary inputs for various tests in their parent57# directories.58config.excludes = ["Inputs", "CMakeLists.txt", "README.txt", "LICENSE.txt"]59 60# test_source_root: The root path where tests are located.61config.test_source_root = os.path.dirname(__file__)62 63# test_exec_root: The root path where tests should be run.64config.test_exec_root = os.path.join(config.bolt_obj_root, "test")65 66# checking if maxIndividualTestTime is available on the platform and sets67# it to 60sec if so, declares lit-max-individual-test-time feature for68# further checking by tests.69supported, errormsg = lit_config.maxIndividualTestTimeIsSupported70if supported:71    config.available_features.add("lit-max-individual-test-time")72    lit_config.maxIndividualTestTime = 6073else:74    lit_config.warning(75        "Setting a timeout per test not supported. "76        + errormsg77        + " Some tests will be skipped."78    )79 80if config.bolt_enable_runtime:81    config.available_features.add("bolt-runtime")82 83if config.gnu_ld:84    config.available_features.add("gnu_ld")85 86if lit.util.which("fuser"):87    config.available_features.add("fuser")88 89llvm_config.use_default_substitutions()90 91llvm_config.config.environment["CLANG"] = config.bolt_clang92llvm_config.use_clang()93 94llvm_config.config.environment["LD_LLD"] = config.bolt_lld95ld_lld = llvm_config.use_llvm_tool("ld.lld", required=True, search_env="LD_LLD")96llvm_config.config.available_features.add("ld.lld")97llvm_config.add_tool_substitutions([ToolSubst(r"ld\.lld", command=ld_lld)])98 99config.substitutions.append(("%cflags", ""))100config.substitutions.append(("%cxxflags", ""))101 102link_fdata_cmd = os.path.join(config.test_source_root, "link_fdata.py")103 104tool_dirs = [config.llvm_tools_dir, config.test_source_root]105 106llvm_bolt_args = []107 108if config.libbolt_rt_instr:109    llvm_bolt_args.append(f"--runtime-instrumentation-lib={config.libbolt_rt_instr}")110 111if config.libbolt_rt_hugify:112    llvm_bolt_args.append(f"--runtime-hugify-lib={config.libbolt_rt_hugify}")113 114tools = [115    ToolSubst("llc", unresolved="fatal"),116    ToolSubst("llvm-dwarfdump", unresolved="fatal"),117    ToolSubst(118        "llvm-bolt",119        unresolved="fatal",120        extra_args=llvm_bolt_args,121    ),122    ToolSubst("llvm-boltdiff", unresolved="fatal"),123    ToolSubst("llvm-bolt-heatmap", unresolved="fatal"),124    ToolSubst("llvm-bolt-binary-analysis", unresolved="fatal"),125    ToolSubst("llvm-bat-dump", unresolved="fatal"),126    ToolSubst("perf2bolt", unresolved="fatal"),127    ToolSubst("yaml2obj", unresolved="fatal"),128    ToolSubst("llvm-mc", unresolved="fatal"),129    ToolSubst("llvm-nm", unresolved="fatal"),130    ToolSubst("llvm-objdump", unresolved="fatal"),131    ToolSubst("llvm-objcopy", unresolved="fatal"),132    ToolSubst("llvm-strings", unresolved="fatal"),133    ToolSubst("llvm-strip", unresolved="fatal"),134    ToolSubst("llvm-readelf", unresolved="fatal"),135    ToolSubst(136        "link_fdata",137        command=sys.executable,138        unresolved="fatal",139        extra_args=[link_fdata_cmd],140    ),141    ToolSubst("process-debug-line", unresolved="fatal"),142    ToolSubst("merge-fdata", unresolved="fatal"),143    ToolSubst("llvm-readobj", unresolved="fatal"),144    ToolSubst("llvm-dwp", unresolved="fatal"),145    ToolSubst("split-file", unresolved="fatal"),146]147llvm_config.add_tool_substitutions(tools, tool_dirs)148 149 150def calculate_arch_features(arch_string):151    features = []152    for arch in arch_string.split():153        features.append(arch.lower() + "-registered-target")154    return features155 156 157llvm_config.feature_config(158    [159        ("--assertion-mode", {"ON": "asserts"}),160        ("--cxxflags", {r"-D_GLIBCXX_DEBUG\b": "libstdcxx-safe-mode"}),161        ("--targets-built", calculate_arch_features),162    ]163)164 165config.targets = frozenset(config.targets_to_build.split(";"))166