[X86][MC,LLD][NFC] Rename R_X86_64_REX2_GOTPCRELX (#116737)
[llvm-project.git] / lld / test / lit.cfg.py
blob859094e2b57dbc3fa7ade2a52797f7b64ff86fc5
1 # -*- Python -*-
3 import os
4 import platform
5 import re
6 import subprocess
7 import locale
9 import lit.formats
10 import lit.util
12 from lit.llvm import llvm_config
14 # Configuration file for the 'lit' test runner.
16 # name: The name of this test suite.
17 config.name = "lld"
19 # testFormat: The test format to use to interpret tests.
21 # For now we require '&&' between commands, until they get globally killed and the test runner updated.
22 config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
24 # suffixes: A list of file extensions to treat as test files.
25 config.suffixes = [".ll", ".s", ".test", ".yaml", ".objtxt"]
27 # excludes: A list of directories to exclude from the testsuite. The 'Inputs'
28 # subdirectories contain auxiliary inputs for various tests in their parent
29 # directories.
30 config.excludes = ["Inputs"]
32 # test_source_root: The root path where tests are located.
33 config.test_source_root = os.path.dirname(__file__)
35 config.test_exec_root = os.path.join(config.lld_obj_root, "test")
37 llvm_config.use_default_substitutions()
38 llvm_config.use_lld()
40 tool_patterns = [
41 "llc",
42 "llvm-as",
43 "llvm-cgdata",
44 "llvm-mc",
45 "llvm-nm",
46 "llvm-objdump",
47 "llvm-otool",
48 "llvm-pdbutil",
49 "llvm-profdata",
50 "llvm-dwarfdump",
51 "llvm-readelf",
52 "llvm-readobj",
53 "obj2yaml",
54 "yaml2obj",
55 "opt",
56 "llvm-dis",
59 llvm_config.add_tool_substitutions(tool_patterns)
61 # LLD tests tend to be flaky on NetBSD, so add some retries.
62 # We don't do this on other platforms because it's slower.
63 if platform.system() in ["NetBSD"]:
64 config.test_retry_attempts = 2
66 # When running under valgrind, we mangle '-vg' onto the end of the triple so we
67 # can check it with XFAIL and XTARGET.
68 if lit_config.useValgrind:
69 config.target_triple += "-vg"
71 llvm_config.feature_config(
74 "--targets-built",
76 "AArch64": "aarch64",
77 "AMDGPU": "amdgpu",
78 "ARM": "arm",
79 "AVR": "avr",
80 "Hexagon": "hexagon",
81 "LoongArch": "loongarch",
82 "Mips": "mips",
83 "MSP430": "msp430",
84 "PowerPC": "ppc",
85 "RISCV": "riscv",
86 "Sparc": "sparc",
87 "SystemZ": "systemz",
88 "WebAssembly": "wasm",
89 "X86": "x86",
92 ("--assertion-mode", {"ON": "asserts"}),
96 # Set a fake constant version so that we get consistent output.
97 config.environment["LLD_VERSION"] = "LLD 1.0"
99 # LLD_IN_TEST determines how many times `main` is run inside each process, which
100 # lets us test that it's cleaning up after itself and resetting global state
101 # correctly (which is important for usage as a library).
102 run_lld_main_twice = lit_config.params.get("RUN_LLD_MAIN_TWICE", False)
103 if not run_lld_main_twice:
104 config.environment["LLD_IN_TEST"] = "1"
105 else:
106 config.environment["LLD_IN_TEST"] = "2"
107 # Many ELF tests fail in this mode.
108 config.excludes.append("ELF")
109 # Some old Mach-O backend tests fail, and it's due for removal anyway.
110 config.excludes.append("mach-o")
111 # Some new Mach-O backend tests fail; give them a way to mark themselves
112 # unsupported in this mode.
113 config.available_features.add("main-run-twice")
115 # Indirectly check if the mt.exe Microsoft utility exists by searching for
116 # cvtres, which always accompanies it. Alternatively, check if we can use
117 # libxml2 to merge manifests.
118 if lit.util.which("cvtres", config.environment["PATH"]) or config.have_libxml2:
119 config.available_features.add("manifest_tool")
121 if config.enable_backtrace:
122 config.available_features.add("backtrace")
124 if config.have_libxml2:
125 config.available_features.add("libxml2")
127 if config.have_dia_sdk:
128 config.available_features.add("diasdk")
130 if config.sizeof_void_p == 8:
131 config.available_features.add("llvm-64-bits")
133 if config.has_plugins:
134 config.available_features.add("plugins")
136 if config.build_examples:
137 config.available_features.add("examples")
139 if config.linked_bye_extension:
140 config.substitutions.append(("%loadbye", ""))
141 config.substitutions.append(("%loadnewpmbye", ""))
142 else:
143 config.substitutions.append(
145 "%loadbye",
146 "-load={}/Bye{}".format(config.llvm_shlib_dir, config.llvm_shlib_ext),
149 config.substitutions.append(
151 "%loadnewpmbye",
152 "-load-pass-plugin={}/Bye{}".format(
153 config.llvm_shlib_dir, config.llvm_shlib_ext
158 tar_executable = lit.util.which("tar", config.environment["PATH"])
159 if tar_executable:
160 env = os.environ
161 env["LANG"] = "C"
162 tar_version = subprocess.Popen(
163 [tar_executable, "--version"],
164 stdout=subprocess.PIPE,
165 stderr=subprocess.PIPE,
166 env=env,
168 sout, _ = tar_version.communicate()
169 if "GNU tar" in sout.decode():
170 config.available_features.add("gnutar")
172 # ELF tests expect the default target for ld.lld to be ELF.
173 if config.ld_lld_default_mingw:
174 config.excludes.append("ELF")