Skip to content

Commit aea0668

Browse files
authored
[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.
1 parent e9cb440 commit aea0668

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

lldb/packages/Python/lldbsuite/test/builders/builder.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ def getToolchainSpec(self, compiler):
110110
if not cc:
111111
return []
112112

113+
exe_ext = ""
114+
if lldbplatformutil.getHostPlatform() == "windows":
115+
exe_ext = ".exe"
116+
113117
cc = cc.strip()
114118
cc_path = pathlib.Path(cc)
115119

@@ -149,9 +153,9 @@ def getToolchainSpec(self, compiler):
149153
cc_dir = cc_path.parent
150154

151155
def getToolchainUtil(util_name):
152-
return cc_dir / (cc_prefix + util_name + cc_ext)
156+
return os.path.join(configuration.llvm_tools_dir, util_name + exe_ext)
153157

154-
cxx = getToolchainUtil(cxx_type)
158+
cxx = cc_dir / (cc_prefix + cxx_type + cc_ext)
155159

156160
util_names = {
157161
"OBJCOPY": "objcopy",
@@ -161,6 +165,10 @@ def getToolchainUtil(util_name):
161165
}
162166
utils = []
163167

168+
# Required by API TestBSDArchives.py tests.
169+
if not os.getenv("LLVM_AR"):
170+
utils.extend(["LLVM_AR=%s" % getToolchainUtil("llvm-ar")])
171+
164172
if not lldbplatformutil.platformIsDarwin():
165173
if cc_type in ["clang", "cc", "gcc"]:
166174
util_paths = {}

lldb/packages/Python/lldbsuite/test/configuration.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@
118118
# same base name.
119119
all_tests = set()
120120

121+
# Path to LLVM tools to be used by tests.
122+
llvm_tools_dir = None
123+
121124
# LLDB library directory.
122125
lldb_libs_dir = None
123126
lldb_obj_root = None

lldb/packages/Python/lldbsuite/test/dotest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ def parseOptionsAndInitTestdirs():
280280
"xcrun -find -toolchain default dsymutil"
281281
)
282282
if args.llvm_tools_dir:
283+
configuration.llvm_tools_dir = args.llvm_tools_dir
283284
configuration.filecheck = shutil.which("FileCheck", path=args.llvm_tools_dir)
284285
configuration.yaml2obj = shutil.which("yaml2obj", path=args.llvm_tools_dir)
285286

lldb/test/API/functionalities/archives/Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,10 @@ libfoo.a: a.o b.o
1212

1313
# This tests whether lldb can load a thin archive
1414
libbar.a: c.o
15-
$(eval LLVM_AR := $(LLVM_TOOLS_DIR)/llvm-ar)
1615
$(eval LLVM_ARFLAGS := -rcsDT)
1716
$(LLVM_AR) $(LLVM_ARFLAGS) $@ $^
1817

1918
libfoo-thin.a: a.o b.o
20-
$(eval LLVM_AR := $(LLVM_TOOLS_DIR)/llvm-ar)
2119
$(eval LLVM_ARFLAGS := -rcsUT)
2220
$(LLVM_AR) $(LLVM_ARFLAGS) $@ $^
2321

0 commit comments

Comments
 (0)