[lldb][test] Use tools from llvm instead of compiler tools (#109961)

In #102185, toolchain detection for API tests has been rewritten in
Python. Tools paths for tests there are determined from compiler path.

Here tools are taken from `--llvm-tools-dir` dotest.py argument, which
by default refers to the LLVM build directory, unless they are
explicitly redefined in environment variables. It helps to minimize
external dependencies and to maximize the reproducibility of the build.
This commit is contained in:
Vladislav Dzhidzhoev
2024-09-25 16:19:02 +02:00
committed by GitHub
parent e9cb44090f
commit aea0668499
4 changed files with 14 additions and 4 deletions

View File

@@ -110,6 +110,10 @@ class Builder:
if not cc:
return []
exe_ext = ""
if lldbplatformutil.getHostPlatform() == "windows":
exe_ext = ".exe"
cc = cc.strip()
cc_path = pathlib.Path(cc)
@@ -149,9 +153,9 @@ class Builder:
cc_dir = cc_path.parent
def getToolchainUtil(util_name):
return cc_dir / (cc_prefix + util_name + cc_ext)
return os.path.join(configuration.llvm_tools_dir, util_name + exe_ext)
cxx = getToolchainUtil(cxx_type)
cxx = cc_dir / (cc_prefix + cxx_type + cc_ext)
util_names = {
"OBJCOPY": "objcopy",
@@ -161,6 +165,10 @@ class Builder:
}
utils = []
# Required by API TestBSDArchives.py tests.
if not os.getenv("LLVM_AR"):
utils.extend(["LLVM_AR=%s" % getToolchainUtil("llvm-ar")])
if not lldbplatformutil.platformIsDarwin():
if cc_type in ["clang", "cc", "gcc"]:
util_paths = {}

View File

@@ -118,6 +118,9 @@ test_result = None
# same base name.
all_tests = set()
# Path to LLVM tools to be used by tests.
llvm_tools_dir = None
# LLDB library directory.
lldb_libs_dir = None
lldb_obj_root = None

View File

@@ -280,6 +280,7 @@ def parseOptionsAndInitTestdirs():
"xcrun -find -toolchain default dsymutil"
)
if args.llvm_tools_dir:
configuration.llvm_tools_dir = args.llvm_tools_dir
configuration.filecheck = shutil.which("FileCheck", path=args.llvm_tools_dir)
configuration.yaml2obj = shutil.which("yaml2obj", path=args.llvm_tools_dir)

View File

@@ -12,12 +12,10 @@ libfoo.a: a.o b.o
# This tests whether lldb can load a thin archive
libbar.a: c.o
$(eval LLVM_AR := $(LLVM_TOOLS_DIR)/llvm-ar)
$(eval LLVM_ARFLAGS := -rcsDT)
$(LLVM_AR) $(LLVM_ARFLAGS) $@ $^
libfoo-thin.a: a.o b.o
$(eval LLVM_AR := $(LLVM_TOOLS_DIR)/llvm-ar)
$(eval LLVM_ARFLAGS := -rcsUT)
$(LLVM_AR) $(LLVM_ARFLAGS) $@ $^