[cross-project-tests][formatters] Add a LIT feature that tests for a compatible LLDB version (#174812)

Most of this logic is similar to how we add the
`gdb-clang-incompatibility` attribute.

Some LLVM LLDB formatters will rely on LLDB features not available in
older versions of LLDB. This feature will allow those tests to add a
`REQUIRES: lldb-formatters-compatibility`, which will then mark the test
`UNSUPPORTED` for incompatible LLDB versions. I picked `19.0` pretty
arbitrarily based on when approximately the
`SBType::FindDirectNestedType` API was added to LLDB (which a future
formatter will require).
This commit is contained in:
Michael Buch 2026-01-07 18:09:25 +00:00 committed by GitHub
parent b6019f7357
commit 1c123f7766
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -109,6 +109,7 @@ if lldb_dap_path is not None:
if llvm_config.use_llvm_tool("llvm-ar"):
config.available_features.add("llvm-ar")
def configure_dexter_substitutions():
"""Configure substitutions for host platform and return list of dependencies"""
# Produce dexter path, lldb path, and combine into the %dexter substitution
@ -289,6 +290,44 @@ def get_clang_default_dwarf_version_string(triple):
return match.group(1)
def get_lldb_version_string():
"""Return LLDB's version string, or None if lldb cannot be found or the
--version output is formatted unexpectedly.
"""
try:
lldb_vers_lines = (
subprocess.check_output(["lldb", "--version"]).decode().splitlines()
)
except:
return None
if len(lldb_vers_lines) < 1:
print("Unkown LLDB version format (too few lines)", file=sys.stderr)
return None
match = re.search(r"lldb.*[ -]((\d|\.)+)", lldb_vers_lines[0].strip())
if match is None:
print(f"Unkown LLDB version format: {lldb_vers_lines[0]}", file=sys.stderr)
return None
return match.group(1)
def set_lldb_formatters_compatibility_feature():
lldb_version_string = get_lldb_version_string()
if lldb_version_string is None:
return False
try:
from packaging import version
except:
lit_config.fatal("Running lldb tests requires the packaging package")
return False
if version.parse(lldb_version_string) < version.parse("1900.0"):
return False
config.available_features.add("lldb-formatters-compatibility")
return True
# Some cross-project-tests use gdb, but not all versions of gdb are compatible
# with clang's dwarf. Add feature `gdb-clang-incompatibility` to signal that
# there's an incompatibility between clang's default dwarf version for this
@ -310,6 +349,12 @@ if dwarf_version_string and gdb_version_string:
file=sys.stderr,
)
if not set_lldb_formatters_compatibility_feature():
print(
f"Marking some LLDB LLVM data-formatter tests as unsupported: using version {get_lldb_version_string()} whereas a version >= 1900.0 is required",
file=sys.stderr,
)
llvm_config.feature_config([("--build-mode", {"Debug|RelWithDebInfo": "debug-info"})])
# Allow 'REQUIRES: XXX-registered-target' in tests.