llvm-project
140 строк · 4.2 Кб
1# -*- Python -*-
2
3import os
4import platform
5import re
6import subprocess
7import tempfile
8
9import lit.formats
10import lit.util
11
12from lit.llvm import llvm_config
13from lit.llvm.subst import ToolSubst
14from lit.llvm.subst import FindTool
15
16# Configuration file for the 'lit' test runner.
17
18# name: The name of this test suite.
19config.name = "BOLT"
20
21# testFormat: The test format to use to interpret tests.
22#
23# For now we require '&&' between commands, until they get globally killed and
24# the test runner updated.
25config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
26
27# suffixes: A list of file extensions to treat as test files.
28config.suffixes = [
29".c",
30".cpp",
31".cppm",
32".m",
33".mm",
34".cu",
35".ll",
36".cl",
37".s",
38".S",
39".modulemap",
40".test",
41".rs",
42]
43
44# excludes: A list of directories to exclude from the testsuite. The 'Inputs'
45# subdirectories contain auxiliary inputs for various tests in their parent
46# directories.
47config.excludes = ["Inputs", "CMakeLists.txt", "README.txt", "LICENSE.txt"]
48
49# test_source_root: The root path where tests are located.
50config.test_source_root = os.path.dirname(__file__)
51
52# test_exec_root: The root path where tests should be run.
53config.test_exec_root = os.path.join(config.bolt_obj_root, "test")
54
55# checking if maxIndividualTestTime is available on the platform and sets
56# it to 60sec if so, declares lit-max-individual-test-time feature for
57# further checking by tests.
58supported, errormsg = lit_config.maxIndividualTestTimeIsSupported
59if supported:
60config.available_features.add("lit-max-individual-test-time")
61lit_config.maxIndividualTestTime = 60
62else:
63lit_config.warning(
64"Setting a timeout per test not supported. "
65+ errormsg
66+ " Some tests will be skipped."
67)
68
69if config.bolt_enable_runtime:
70config.available_features.add("bolt-runtime")
71
72if config.gnu_ld:
73config.available_features.add("gnu_ld")
74
75if lit.util.which("fuser"):
76config.available_features.add("fuser")
77
78llvm_config.use_default_substitutions()
79
80llvm_config.config.environment["CLANG"] = config.bolt_clang
81llvm_config.use_clang()
82
83llvm_config.config.environment["LD_LLD"] = config.bolt_lld
84ld_lld = llvm_config.use_llvm_tool("ld.lld", required=True, search_env="LD_LLD")
85llvm_config.config.available_features.add("ld.lld")
86llvm_config.add_tool_substitutions([ToolSubst(r"ld\.lld", command=ld_lld)])
87
88config.substitutions.append(("%cflags", ""))
89config.substitutions.append(("%cxxflags", ""))
90
91link_fdata_cmd = os.path.join(config.test_source_root, "link_fdata.py")
92
93tool_dirs = [config.llvm_tools_dir, config.test_source_root]
94
95tools = [
96ToolSubst("llc", unresolved="fatal"),
97ToolSubst("llvm-dwarfdump", unresolved="fatal"),
98ToolSubst("llvm-bolt", unresolved="fatal"),
99ToolSubst("llvm-boltdiff", unresolved="fatal"),
100ToolSubst("llvm-bolt-heatmap", unresolved="fatal"),
101ToolSubst("llvm-bat-dump", unresolved="fatal"),
102ToolSubst("perf2bolt", unresolved="fatal"),
103ToolSubst("yaml2obj", unresolved="fatal"),
104ToolSubst("llvm-mc", unresolved="fatal"),
105ToolSubst("llvm-nm", unresolved="fatal"),
106ToolSubst("llvm-objdump", unresolved="fatal"),
107ToolSubst("llvm-objcopy", unresolved="fatal"),
108ToolSubst("llvm-strings", unresolved="fatal"),
109ToolSubst("llvm-strip", unresolved="fatal"),
110ToolSubst("llvm-readelf", unresolved="fatal"),
111ToolSubst(
112"link_fdata",
113command=sys.executable,
114unresolved="fatal",
115extra_args=[link_fdata_cmd],
116),
117ToolSubst("merge-fdata", unresolved="fatal"),
118ToolSubst("llvm-readobj", unresolved="fatal"),
119ToolSubst("llvm-dwp", unresolved="fatal"),
120ToolSubst("split-file", unresolved="fatal"),
121]
122llvm_config.add_tool_substitutions(tools, tool_dirs)
123
124
125def calculate_arch_features(arch_string):
126features = []
127for arch in arch_string.split():
128features.append(arch.lower() + "-registered-target")
129return features
130
131
132llvm_config.feature_config(
133[
134("--assertion-mode", {"ON": "asserts"}),
135("--cxxflags", {r"-D_GLIBCXX_DEBUG\b": "libstdcxx-safe-mode"}),
136("--targets-built", calculate_arch_features),
137]
138)
139
140config.targets = frozenset(config.targets_to_build.split(";"))
141