Skip to content

Commit 025276a

Browse files
committed
[lldb][test] Use tools from llvm instead of compiler-based tools
In #102185, toolchain detection for API tests has been rewritten to Python. However, tools paths for tests 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 f43ad88 commit 025276a

File tree

5 files changed

+15
-5
lines changed

5 files changed

+15
-5
lines changed

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

Lines changed: 11 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,11 @@ def getToolchainUtil(util_name):
161165
}
162166
utils = []
163167

168+
# Required by API TestBSDArchives.py tests.
169+
# TODO don't forget to fix the test's Makefile when porting to mainline
170+
if not os.getenv("LLVM_AR"):
171+
utils.extend(["LLVM_AR=%s" % getToolchainUtil("llvm-ar")])
172+
164173
if not lldbplatformutil.platformIsDarwin():
165174
if cc_type in ["clang", "cc", "gcc"]:
166175
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

lldb/test/API/functionalities/archives/TestBSDArchives.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ def setUp(self):
2525
oslist=["windows"],
2626
bugnumber="llvm.org/pr24527. Makefile.rules doesn't know how to build static libs on Windows",
2727
)
28-
@expectedFailureAll(remote=True)
2928
def test(self):
3029
"""Break inside a() and b() defined within libfoo.a."""
3130
self.build()

0 commit comments

Comments
 (0)