Don Hinton | 3a58f67 | 2017-12-12 16:54:20 +0000 | [diff] [blame] | 1 | import os |
| 2 | import platform |
| 3 | import re |
| 4 | import subprocess |
Jeremy Morse | 984fad2 | 2019-10-31 16:51:53 +0000 | [diff] [blame] | 5 | import sys |
Thomas Lively | 7062094 | 2022-03-17 15:22:17 -0700 | [diff] [blame] | 6 | |
Don Hinton | 3a58f67 | 2017-12-12 16:54:20 +0000 | [diff] [blame] | 7 | import lit.formats |
| 8 | import lit.util |
| 9 | |
| 10 | from lit.llvm import llvm_config |
| 11 | from lit.llvm.subst import ToolSubst |
Don Hinton | 3a58f67 | 2017-12-12 16:54:20 +0000 | [diff] [blame] | 12 | |
| 13 | # Configuration file for the 'lit' test runner. |
| 14 | |
| 15 | # name: The name of this test suite. |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 16 | config.name = "cross-project-tests" |
Don Hinton | 3a58f67 | 2017-12-12 16:54:20 +0000 | [diff] [blame] | 17 | |
| 18 | # testFormat: The test format to use to interpret tests. |
Don Hinton | 3a58f67 | 2017-12-12 16:54:20 +0000 | [diff] [blame] | 19 | config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell) |
| 20 | |
| 21 | # suffixes: A list of file extensions to treat as test files. |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 22 | config.suffixes = [".c", ".cl", ".cpp", ".m"] |
Don Hinton | 3a58f67 | 2017-12-12 16:54:20 +0000 | [diff] [blame] | 23 | |
| 24 | # excludes: A list of directories to exclude from the testsuite. The 'Inputs' |
| 25 | # subdirectories contain auxiliary inputs for various tests in their parent |
| 26 | # directories. |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 27 | config.excludes = ["Inputs"] |
Don Hinton | 3a58f67 | 2017-12-12 16:54:20 +0000 | [diff] [blame] | 28 | |
| 29 | # test_source_root: The root path where tests are located. |
James Henderson | 24af099 | 2021-02-11 15:41:32 +0000 | [diff] [blame] | 30 | config.test_source_root = config.cross_project_tests_src_root |
Don Hinton | 3a58f67 | 2017-12-12 16:54:20 +0000 | [diff] [blame] | 31 | |
| 32 | # test_exec_root: The root path where tests should be run. |
James Henderson | 24af099 | 2021-02-11 15:41:32 +0000 | [diff] [blame] | 33 | config.test_exec_root = config.cross_project_tests_obj_root |
Don Hinton | 3a58f67 | 2017-12-12 16:54:20 +0000 | [diff] [blame] | 34 | |
Jeremy Morse | 984fad2 | 2019-10-31 16:51:53 +0000 | [diff] [blame] | 35 | llvm_config.use_default_substitutions() |
| 36 | |
Augusto Noronha | 7cabcdb | 2025-03-19 12:42:47 -0700 | [diff] [blame] | 37 | lldb_python_path = os.path.join( |
| 38 | config.llvm_libs_dir, |
| 39 | f"python{sys.version_info.major}.{sys.version_info.minor}", |
| 40 | "site-packages", |
| 41 | ) |
| 42 | python_exec_path = sys.executable |
Reid Kleckner | 75d38f1 | 2019-05-28 23:03:33 +0000 | [diff] [blame] | 43 | tools = [ |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 44 | ToolSubst( |
| 45 | "%test_debuginfo", |
Augusto Noronha | 7cabcdb | 2025-03-19 12:42:47 -0700 | [diff] [blame] | 46 | command="PYTHON_EXEC_PATH=" |
| 47 | + python_exec_path |
| 48 | + " LLDB_PYTHON_PATH=" |
| 49 | + lldb_python_path |
| 50 | + " " |
| 51 | + os.path.join( |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 52 | config.cross_project_tests_src_root, |
| 53 | "debuginfo-tests", |
| 54 | "llgdb-tests", |
| 55 | "test_debuginfo.pl", |
| 56 | ), |
| 57 | ), |
Christian Sigg | 60346bd | 2020-01-11 08:47:41 +0100 | [diff] [blame] | 58 | ToolSubst("%llvm_src_root", config.llvm_src_root), |
| 59 | ToolSubst("%llvm_tools_dir", config.llvm_tools_dir), |
Reid Kleckner | 75d38f1 | 2019-05-28 23:03:33 +0000 | [diff] [blame] | 60 | ] |
| 61 | |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 62 | |
Reid Kleckner | 75d38f1 | 2019-05-28 23:03:33 +0000 | [diff] [blame] | 63 | def get_required_attr(config, attr_name): |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 64 | attr_value = getattr(config, attr_name, None) |
Eisuke Kawashima | ca92bdf | 2025-01-13 21:03:04 +0900 | [diff] [blame] | 65 | if attr_value is None: |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 66 | lit_config.fatal( |
| 67 | "No attribute %r in test configuration! You may need to run " |
| 68 | "tests from your build directory or add this attribute " |
| 69 | "to lit.site.cfg " % attr_name |
| 70 | ) |
| 71 | return attr_value |
| 72 | |
Reid Kleckner | 75d38f1 | 2019-05-28 23:03:33 +0000 | [diff] [blame] | 73 | |
| 74 | # If this is an MSVC environment, the tests at the root of the tree are |
| 75 | # unsupported. The local win_cdb test suite, however, is supported. |
| 76 | is_msvc = get_required_attr(config, "is_msvc") |
| 77 | if is_msvc: |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 78 | config.available_features.add("msvc") |
Reid Kleckner | 75d38f1 | 2019-05-28 23:03:33 +0000 | [diff] [blame] | 79 | # FIXME: We should add some llvm lit utility code to find the Windows SDK |
| 80 | # and set up the environment appopriately. |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 81 | win_sdk = "C:/Program Files (x86)/Windows Kits/10/" |
| 82 | arch = "x64" |
| 83 | llvm_config.with_system_environment(["LIB", "LIBPATH", "INCLUDE"]) |
Reid Kleckner | 75d38f1 | 2019-05-28 23:03:33 +0000 | [diff] [blame] | 84 | # Clear _NT_SYMBOL_PATH to prevent cdb from attempting to load symbols from |
| 85 | # the network. |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 86 | llvm_config.with_environment("_NT_SYMBOL_PATH", "") |
| 87 | tools.append( |
| 88 | ToolSubst("%cdb", '"%s"' % os.path.join(win_sdk, "Debuggers", arch, "cdb.exe")) |
| 89 | ) |
Reid Kleckner | 75d38f1 | 2019-05-28 23:03:33 +0000 | [diff] [blame] | 90 | |
James Henderson | 4446a72 | 2021-02-09 14:57:03 +0000 | [diff] [blame] | 91 | # clang_src_dir and lld_src_dir are not used by these tests, but are required by |
| 92 | # use_clang() and use_lld() respectively, so set them to "", if needed. |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 93 | if not hasattr(config, "clang_src_dir"): |
Don Hinton | 3a58f67 | 2017-12-12 16:54:20 +0000 | [diff] [blame] | 94 | config.clang_src_dir = "" |
Amir Ayupov | 9fec33a | 2024-01-18 19:59:09 -0800 | [diff] [blame] | 95 | llvm_config.use_clang(required=("clang" in config.llvm_enabled_projects)) |
James Henderson | 3827600 | 2021-02-09 15:19:27 +0000 | [diff] [blame] | 96 | |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 97 | if not hasattr(config, "lld_src_dir"): |
James Henderson | 4446a72 | 2021-02-09 14:57:03 +0000 | [diff] [blame] | 98 | config.lld_src_dir = "" |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 99 | llvm_config.use_lld(required=("lld" in config.llvm_enabled_projects)) |
Don Hinton | 3a58f67 | 2017-12-12 16:54:20 +0000 | [diff] [blame] | 100 | |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 101 | if "compiler-rt" in config.llvm_enabled_projects: |
| 102 | config.available_features.add("compiler-rt") |
OCHyams | ac0f329 | 2022-02-09 17:08:43 +0000 | [diff] [blame] | 103 | |
OCHyams | 18ee898 | 2021-12-16 13:41:29 +0000 | [diff] [blame] | 104 | # Check which debuggers are available: |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 105 | lldb_path = llvm_config.use_llvm_tool("lldb", search_env="LLDB") |
OCHyams | 18ee898 | 2021-12-16 13:41:29 +0000 | [diff] [blame] | 106 | |
| 107 | if lldb_path is not None: |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 108 | config.available_features.add("lldb") |
| 109 | |
OCHyams | 18ee898 | 2021-12-16 13:41:29 +0000 | [diff] [blame] | 110 | |
| 111 | def configure_dexter_substitutions(): |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 112 | """Configure substitutions for host platform and return list of dependencies""" |
| 113 | # Produce dexter path, lldb path, and combine into the %dexter substitution |
| 114 | # for running a test. |
| 115 | dexter_path = os.path.join( |
| 116 | config.cross_project_tests_src_root, "debuginfo-tests", "dexter", "dexter.py" |
| 117 | ) |
| 118 | dexter_test_cmd = '"{}" "{}" test'.format(sys.executable, dexter_path) |
| 119 | if lldb_path is not None: |
| 120 | dexter_test_cmd += ' --lldb-executable "{}"'.format(lldb_path) |
| 121 | tools.append(ToolSubst("%dexter", dexter_test_cmd)) |
OCHyams | 18ee898 | 2021-12-16 13:41:29 +0000 | [diff] [blame] | 122 | |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 123 | # For testing other bits of dexter that aren't under the "test" subcommand, |
| 124 | # have a %dexter_base substitution. |
| 125 | dexter_base_cmd = '"{}" "{}"'.format(sys.executable, dexter_path) |
| 126 | tools.append(ToolSubst("%dexter_base", dexter_base_cmd)) |
OCHyams | 18ee898 | 2021-12-16 13:41:29 +0000 | [diff] [blame] | 127 | |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 128 | # Set up commands for DexTer regression tests. |
| 129 | # Builder, debugger, optimisation level and several other flags differ |
| 130 | # depending on whether we're running a unix like or windows os. |
| 131 | if platform.system() == "Windows": |
| 132 | # The Windows builder script uses lld. |
| 133 | dependencies = ["clang", "lld-link"] |
Stephen Tozer | 45a40c1 | 2023-09-05 16:04:53 +0100 | [diff] [blame] | 134 | dexter_regression_test_builder = "clang-cl" |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 135 | dexter_regression_test_debugger = "dbgeng" |
Stephen Tozer | 45a40c1 | 2023-09-05 16:04:53 +0100 | [diff] [blame] | 136 | dexter_regression_test_flags = "/Zi /Od" |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 137 | else: |
| 138 | # Use lldb as the debugger on non-Windows platforms. |
| 139 | dependencies = ["clang", "lldb"] |
Stephen Tozer | 45a40c1 | 2023-09-05 16:04:53 +0100 | [diff] [blame] | 140 | dexter_regression_test_builder = "clang++" |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 141 | dexter_regression_test_debugger = "lldb" |
Stephen Tozer | 45a40c1 | 2023-09-05 16:04:53 +0100 | [diff] [blame] | 142 | dexter_regression_test_flags = "-O0 -glldb -std=gnu++11" |
OCHyams | 18ee898 | 2021-12-16 13:41:29 +0000 | [diff] [blame] | 143 | |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 144 | tools.append( |
| 145 | ToolSubst("%dexter_regression_test_builder", dexter_regression_test_builder) |
| 146 | ) |
| 147 | tools.append( |
| 148 | ToolSubst("%dexter_regression_test_debugger", dexter_regression_test_debugger) |
| 149 | ) |
Stephen Tozer | 45a40c1 | 2023-09-05 16:04:53 +0100 | [diff] [blame] | 150 | # We don't need to distinguish cflags and ldflags because for Dexter |
| 151 | # regression tests we use clang to drive the linker, and so all flags will be |
| 152 | # passed in a single command. |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 153 | tools.append( |
Stephen Tozer | 45a40c1 | 2023-09-05 16:04:53 +0100 | [diff] [blame] | 154 | ToolSubst("%dexter_regression_test_flags", dexter_regression_test_flags) |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 155 | ) |
OCHyams | de3f815 | 2022-01-26 11:09:21 +0000 | [diff] [blame] | 156 | |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 157 | # Typical command would take the form: |
Stephen Tozer | 45a40c1 | 2023-09-05 16:04:53 +0100 | [diff] [blame] | 158 | # ./path_to_py/python.exe ./path_to_dex/dexter.py test --fail-lt 1.0 -w --binary %t --debugger lldb --cflags '-O0 -g' |
| 159 | dexter_regression_test_run = " ".join( |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 160 | # "python", "dexter.py", test, fail_mode, builder, debugger, cflags, ldflags |
| 161 | [ |
| 162 | '"{}"'.format(sys.executable), |
| 163 | '"{}"'.format(dexter_path), |
| 164 | "test", |
| 165 | "--fail-lt 1.0 -w", |
| 166 | "--debugger", |
| 167 | dexter_regression_test_debugger, |
| 168 | ] |
| 169 | ) |
Stephen Tozer | 45a40c1 | 2023-09-05 16:04:53 +0100 | [diff] [blame] | 170 | tools.append(ToolSubst("%dexter_regression_test_run", dexter_regression_test_run)) |
OCHyams | 18ee898 | 2021-12-16 13:41:29 +0000 | [diff] [blame] | 171 | |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 172 | # Include build flags for %dexter_regression_test. |
| 173 | dexter_regression_test_build = " ".join( |
| 174 | [ |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 175 | dexter_regression_test_builder, |
Stephen Tozer | 45a40c1 | 2023-09-05 16:04:53 +0100 | [diff] [blame] | 176 | dexter_regression_test_flags, |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 177 | ] |
| 178 | ) |
Stephen Tozer | 45a40c1 | 2023-09-05 16:04:53 +0100 | [diff] [blame] | 179 | tools.append(ToolSubst("%dexter_regression_test_build", dexter_regression_test_build)) |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 180 | return dependencies |
| 181 | |
OCHyams | 18ee898 | 2021-12-16 13:41:29 +0000 | [diff] [blame] | 182 | |
OCHyams | 52bc1c1 | 2021-02-24 11:09:18 +0000 | [diff] [blame] | 183 | def add_host_triple(clang): |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 184 | return "{} --target={}".format(clang, config.host_triple) |
| 185 | |
OCHyams | 52bc1c1 | 2021-02-24 11:09:18 +0000 | [diff] [blame] | 186 | |
| 187 | # The set of arches we can build. |
| 188 | targets = set(config.targets_to_build) |
| 189 | # Add aliases to the target set. |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 190 | if "AArch64" in targets: |
| 191 | targets.add("arm64") |
| 192 | if "ARM" in config.targets_to_build: |
| 193 | targets.add("thumbv7") |
| 194 | |
OCHyams | 52bc1c1 | 2021-02-24 11:09:18 +0000 | [diff] [blame] | 195 | |
| 196 | def can_target_host(): |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 197 | # Check if the targets set contains anything that looks like our host arch. |
| 198 | # The arch name in the triple and targets set may be spelled differently |
| 199 | # (e.g. x86 vs X86). |
| 200 | return any(config.host_triple.lower().startswith(x.lower()) for x in targets) |
| 201 | |
OCHyams | 52bc1c1 | 2021-02-24 11:09:18 +0000 | [diff] [blame] | 202 | |
| 203 | # Dexter tests run on the host machine. If the host arch is supported add |
| 204 | # 'dexter' as an available feature and force the dexter tests to use the host |
| 205 | # triple. |
| 206 | if can_target_host(): |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 207 | if config.host_triple != config.target_triple: |
| 208 | print("Forcing dexter tests to use host triple {}.".format(config.host_triple)) |
| 209 | dependencies = configure_dexter_substitutions() |
| 210 | if all(d in config.available_features for d in dependencies): |
| 211 | config.available_features.add("dexter") |
| 212 | llvm_config.with_environment( |
| 213 | "PATHTOCLANG", add_host_triple(llvm_config.config.clang) |
| 214 | ) |
| 215 | llvm_config.with_environment( |
| 216 | "PATHTOCLANGPP", add_host_triple(llvm_config.use_llvm_tool("clang++")) |
| 217 | ) |
| 218 | llvm_config.with_environment( |
| 219 | "PATHTOCLANGCL", add_host_triple(llvm_config.use_llvm_tool("clang-cl")) |
| 220 | ) |
OCHyams | 52bc1c1 | 2021-02-24 11:09:18 +0000 | [diff] [blame] | 221 | else: |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 222 | print( |
| 223 | "Host triple {} not supported. Skipping dexter tests in the " |
| 224 | "debuginfo-tests project.".format(config.host_triple) |
| 225 | ) |
Jeremy Morse | 984fad2 | 2019-10-31 16:51:53 +0000 | [diff] [blame] | 226 | |
Don Hinton | 3a58f67 | 2017-12-12 16:54:20 +0000 | [diff] [blame] | 227 | tool_dirs = [config.llvm_tools_dir] |
| 228 | |
Don Hinton | 3a58f67 | 2017-12-12 16:54:20 +0000 | [diff] [blame] | 229 | llvm_config.add_tool_substitutions(tools, tool_dirs) |
| 230 | |
| 231 | lit.util.usePlatformSdkOnDarwin(config, lit_config) |
Vedant Kumar | efab30c | 2018-08-04 00:02:48 +0000 | [diff] [blame] | 232 | |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 233 | if platform.system() == "Darwin": |
| 234 | xcode_lldb_vers = subprocess.check_output(["xcrun", "lldb", "--version"]).decode( |
| 235 | "utf-8" |
| 236 | ) |
Eisuke Kawashima | a1a3e01 | 2025-01-13 21:15:22 +0900 | [diff] [blame] | 237 | match = re.search(r"lldb-(\d+)", xcode_lldb_vers) |
Vedant Kumar | efab30c | 2018-08-04 00:02:48 +0000 | [diff] [blame] | 238 | if match: |
| 239 | apple_lldb_vers = int(match.group(1)) |
| 240 | if apple_lldb_vers < 1000: |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 241 | config.available_features.add("apple-lldb-pre-1000") |
| 242 | |
Jeremy Morse | 984fad2 | 2019-10-31 16:51:53 +0000 | [diff] [blame] | 243 | |
OCHyams | 5257efd | 2022-02-09 10:47:07 +0000 | [diff] [blame] | 244 | def get_gdb_version_string(): |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 245 | """Return gdb's version string, or None if gdb cannot be found or the |
| 246 | --version output is formatted unexpectedly. |
| 247 | """ |
| 248 | # See if we can get a gdb version, e.g. |
| 249 | # $ gdb --version |
| 250 | # GNU gdb (GDB) 10.2 |
| 251 | # ...More stuff... |
| 252 | try: |
| 253 | gdb_vers_lines = ( |
| 254 | subprocess.check_output(["gdb", "--version"]).decode().splitlines() |
| 255 | ) |
| 256 | except: |
| 257 | return None # We coudln't find gdb or something went wrong running it. |
| 258 | if len(gdb_vers_lines) < 1: |
| 259 | print("Unkown GDB version format (too few lines)", file=sys.stderr) |
| 260 | return None |
Eisuke Kawashima | a1a3e01 | 2025-01-13 21:15:22 +0900 | [diff] [blame] | 261 | match = re.search(r"GNU gdb \(.*?\) ((\d|\.)+)", gdb_vers_lines[0].strip()) |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 262 | if match is None: |
| 263 | print(f"Unkown GDB version format: {gdb_vers_lines[0]}", file=sys.stderr) |
| 264 | return None |
| 265 | return match.group(1) |
| 266 | |
OCHyams | 5257efd | 2022-02-09 10:47:07 +0000 | [diff] [blame] | 267 | |
| 268 | def get_clang_default_dwarf_version_string(triple): |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 269 | """Return the default dwarf version string for clang on this (host) platform |
| 270 | or None if we can't work it out. |
| 271 | """ |
| 272 | # Get the flags passed by the driver and look for -dwarf-version. |
| 273 | cmd = f'{llvm_config.use_llvm_tool("clang")} -g -xc -c - -v -### --target={triple}' |
| 274 | stderr = subprocess.run(cmd.split(), stderr=subprocess.PIPE).stderr.decode() |
Eisuke Kawashima | a1a3e01 | 2025-01-13 21:15:22 +0900 | [diff] [blame] | 275 | match = re.search(r"-dwarf-version=(\d+)", stderr) |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 276 | if match is None: |
| 277 | print("Cannot determine default dwarf version", file=sys.stderr) |
| 278 | return None |
| 279 | return match.group(1) |
| 280 | |
OCHyams | 5257efd | 2022-02-09 10:47:07 +0000 | [diff] [blame] | 281 | |
| 282 | # Some cross-project-tests use gdb, but not all versions of gdb are compatible |
| 283 | # with clang's dwarf. Add feature `gdb-clang-incompatibility` to signal that |
| 284 | # there's an incompatibility between clang's default dwarf version for this |
| 285 | # platform and the installed gdb version. |
| 286 | dwarf_version_string = get_clang_default_dwarf_version_string(config.host_triple) |
| 287 | gdb_version_string = get_gdb_version_string() |
| 288 | if dwarf_version_string and gdb_version_string: |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 289 | if int(dwarf_version_string) >= 5: |
dyung | 9374216 | 2024-07-22 11:28:11 -0700 | [diff] [blame] | 290 | try: |
| 291 | from packaging import version |
| 292 | except: |
| 293 | lit_config.fatal("Running gdb tests requires the packaging package") |
| 294 | if version.parse(gdb_version_string) < version.parse("10.1"): |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 295 | # Example for llgdb-tests, which use lldb on darwin but gdb elsewhere: |
| 296 | # XFAIL: !system-darwin && gdb-clang-incompatibility |
| 297 | config.available_features.add("gdb-clang-incompatibility") |
| 298 | print( |
| 299 | "XFAIL some tests: use gdb version >= 10.1 to restore test coverage", |
| 300 | file=sys.stderr, |
| 301 | ) |
OCHyams | 5257efd | 2022-02-09 10:47:07 +0000 | [diff] [blame] | 302 | |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 303 | llvm_config.feature_config([("--build-mode", {"Debug|RelWithDebInfo": "debug-info"})]) |
Thomas Lively | 7062094 | 2022-03-17 15:22:17 -0700 | [diff] [blame] | 304 | |
| 305 | # Allow 'REQUIRES: XXX-registered-target' in tests. |
| 306 | for arch in config.targets_to_build: |
Tobias Hieta | f98ee40 | 2023-05-17 16:59:41 +0200 | [diff] [blame] | 307 | config.available_features.add(arch.lower() + "-registered-target") |