Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 25, 2024

Conversation

dzhidzhoev
Copy link
Member

@dzhidzhoev dzhidzhoev commented Sep 25, 2024

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.

In llvm#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.
@llvmbot
Copy link
Member

llvmbot commented Sep 25, 2024

@llvm/pr-subscribers-lldb

Author: Vladislav Dzhidzhoev (dzhidzhoev)

Changes

In #102185, toolchain detection for API tests has been rewritten in 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.


Full diff: https://github.com/llvm/llvm-project/pull/109961.diff

5 Files Affected:

  • (modified) lldb/packages/Python/lldbsuite/test/builders/builder.py (+11-2)
  • (modified) lldb/packages/Python/lldbsuite/test/configuration.py (+3)
  • (modified) lldb/packages/Python/lldbsuite/test/dotest.py (+1)
  • (modified) lldb/test/API/functionalities/archives/Makefile (-2)
  • (modified) lldb/test/API/functionalities/archives/TestBSDArchives.py (-1)
diff --git a/lldb/packages/Python/lldbsuite/test/builders/builder.py b/lldb/packages/Python/lldbsuite/test/builders/builder.py
index 564918c58b6dd2..90f11fffbb4928 100644
--- a/lldb/packages/Python/lldbsuite/test/builders/builder.py
+++ b/lldb/packages/Python/lldbsuite/test/builders/builder.py
@@ -110,6 +110,10 @@ def getToolchainSpec(self, compiler):
         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 @@ def getToolchainSpec(self, compiler):
         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,11 @@ def getToolchainUtil(util_name):
         }
         utils = []
 
+        # Required by API TestBSDArchives.py tests.
+        # TODO don't forget to fix the test's Makefile when porting to mainline
+        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 = {}
diff --git a/lldb/packages/Python/lldbsuite/test/configuration.py b/lldb/packages/Python/lldbsuite/test/configuration.py
index 27eef040497d13..1bacd74a968c31 100644
--- a/lldb/packages/Python/lldbsuite/test/configuration.py
+++ b/lldb/packages/Python/lldbsuite/test/configuration.py
@@ -118,6 +118,9 @@
 # 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
diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py b/lldb/packages/Python/lldbsuite/test/dotest.py
index f14a00a2394b0b..b1ae896d3fd3b4 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -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)
 
diff --git a/lldb/test/API/functionalities/archives/Makefile b/lldb/test/API/functionalities/archives/Makefile
index c4c593e6db0519..4b9696e26b5752 100644
--- a/lldb/test/API/functionalities/archives/Makefile
+++ b/lldb/test/API/functionalities/archives/Makefile
@@ -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) $@ $^
 
diff --git a/lldb/test/API/functionalities/archives/TestBSDArchives.py b/lldb/test/API/functionalities/archives/TestBSDArchives.py
index 1bef8e896e0be7..928e9508617ad6 100644
--- a/lldb/test/API/functionalities/archives/TestBSDArchives.py
+++ b/lldb/test/API/functionalities/archives/TestBSDArchives.py
@@ -25,7 +25,6 @@ def setUp(self):
         oslist=["windows"],
         bugnumber="llvm.org/pr24527.  Makefile.rules doesn't know how to build static libs on Windows",
     )
-    @expectedFailureAll(remote=True)
     def test(self):
         """Break inside a() and b() defined within libfoo.a."""
         self.build()

@dzhidzhoev dzhidzhoev changed the title [lldb][test] Use tools from llvm instead of compiler-based tools [lldb][test] Use tools from llvm instead of compiler tools Sep 25, 2024
Copy link
Collaborator

@DavidSpickett DavidSpickett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there some tool that every bot is going to have to add an override for because it's not something in <build>/bin?

If there is such a tool, that doesn't make this change bad, but we may want to delay while that's accounted for.

@DavidSpickett
Copy link
Collaborator

A better version of my question, do you have a list of tools this effects, is it just the ones where you have modified lines in this PR?

If so we probably have nothing to worry about.

@dzhidzhoev
Copy link
Member Author

dzhidzhoev commented Sep 25, 2024

A better version of my question, do you have a list of tools this effects, is it just the ones where you have modified lines in this PR?

If so we probably have nothing to worry about.

These are the tools listed in util_names dictionary

@dzhidzhoev
Copy link
Member Author

Is there some tool that every bot is going to have to add an override for because it's not something in <build>/bin?

AFAIK no. All these tools have llvm alternatives.

Copy link
Collaborator

@DavidSpickett DavidSpickett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decide what to do with the remote test change but otherwise this LGTM.

@dzhidzhoev
Copy link
Member Author

Decide what to do with the remote test change but otherwise this LGTM.

Some other tests are unexpectedly passing on remote config, so they'll need extra attention.

@dzhidzhoev dzhidzhoev merged commit aea0668 into llvm:main Sep 25, 2024
5 of 6 checks passed
dzhidzhoev added a commit to dzhidzhoev/llvm-zorg that referenced this pull request Oct 8, 2024
…buntu" builder

dotest.py flags replaced with CMake flags introduced in
llvm/llvm-project#95986 to run Shell tests remotely.

Also, USE_LLVM_TOOLS is removed since it's implied by default that LLVM
tools will be used for API tests since llvm/llvm-project#109961.
dzhidzhoev added a commit to llvm/llvm-zorg that referenced this pull request Oct 9, 2024
…buntu" builder (#270)

dotest.py flags are replaced with CMake flags introduced in
llvm/llvm-project#95986 to run Shell tests
remotely.

Also, USE_LLVM_TOOLS is removed since it's implied by default that LLVM
tools will be used for API tests since
llvm/llvm-project#109961.
dzhidzhoev added a commit to dzhidzhoev/llvm-project that referenced this pull request Oct 11, 2024
This commit essentially reverts https://reviews.llvm.org/D30453.

In llvm#109961, objcopy util search code was added to dotest.py.
dotest.py should use llvm-X by default if no path to an utility X is
provided externally.

However, it doesn't work out for llvm-objcopy, since objcopy path is
always overriden with the lines being removed here. It causes a problem
with cross-platform testing when objcopy used by cmake doesn't support
targets/executable file formats other than native.

I suppose these lines are not necessary after llvm#109961, so they can be
safely removed.
vvereschaka pushed a commit that referenced this pull request Oct 15, 2024
…111977)

This commit essentially reverts https://reviews.llvm.org/D30453.

In #109961, objcopy util search code was added to dotest.py. dotest.py
should use llvm-X by default if no path to a utility X is provided
externally.

However, it doesn't work out for llvm-objcopy, since objcopy path is
always overridden with the lines being removed here. It causes a problem
with cross-platform testing when objcopy used by cmake doesn't support
targets/executable file formats other than native.

I suppose these lines are unnecessary after #109961, so they can be
safely removed.
DanielCChen pushed a commit to DanielCChen/llvm-project that referenced this pull request Oct 16, 2024
…lvm#111977)

This commit essentially reverts https://reviews.llvm.org/D30453.

In llvm#109961, objcopy util search code was added to dotest.py. dotest.py
should use llvm-X by default if no path to a utility X is provided
externally.

However, it doesn't work out for llvm-objcopy, since objcopy path is
always overridden with the lines being removed here. It causes a problem
with cross-platform testing when objcopy used by cmake doesn't support
targets/executable file formats other than native.

I suppose these lines are unnecessary after llvm#109961, so they can be
safely removed.
qiaojbao pushed a commit to GPUOpen-Drivers/llvm-project that referenced this pull request Oct 31, 2024
…ef4684340

Local branch amd-gfx 617ef46 Merged main:4be1c19a9fbdff02044cd46b703c842bb7a6afdb into amd-gfx:8e51b74fa82f
Remote branch main aea0668 [lldb][test] Use tools from llvm instead of compiler tools (llvm#109961)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants