[Lldb-commits] [PATCH] D143842: [lldb][test] Add check for Xcode binutils version to test-runner

Michael Buch via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Sun Feb 12 02:29:33 PST 2023


Michael137 created this revision.
Herald added a project: All.
Michael137 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Some tests in LLDB require the use of binutils tools. On Darwin,
we need to use the tools that ship with Xcode. Otherwise we risk
crashing in unpredictable ways.

This patch adds a check for this and bails early if the user has
a non-Xcode binutils in their path before the Xcode ones.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143842

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


Index: lldb/packages/Python/lldbsuite/test/dotest.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -869,6 +869,28 @@
     if platform not in ["freebsd", "linux", "netbsd"]:
         configuration.skip_categories.append("fork")
 
+def checkDarwinBinutilsPath():
+    from lldbsuite.test import lldbplatformutil
+
+    if not lldbplatformutil.platformIsDarwin():
+        return
+
+    cmd = ["strip", "--version"]
+    process = subprocess.Popen(
+        cmd,
+        stdout=subprocess.PIPE,
+        stderr=subprocess.STDOUT)
+    cmd_output = process.stdout.read()
+    output_str = cmd_output.decode("utf-8")
+    if "GNU strip (GNU Binutils)" in output_str:
+        print("""
+The tool 'strip' in your path is not the one from the Xcode
+toolchain. Please make sure the Xcode tools are before any
+other tools in your path. Run `xcode -f strip` for the correct
+toolchain path.
+Exiting...
+        """)
+        sys.exit(0)
 
 def run_suite():
     # On MacOS X, check to make sure that domain for com.apple.DebugSymbols defaults
@@ -956,6 +978,7 @@
     checkDebugServerSupport()
     checkObjcSupport()
     checkForkVForkSupport()
+    checkDarwinBinutilsPath()
 
     skipped_categories_list = ", ".join(configuration.skip_categories)
     print("Skipping the following test categories: {}".format(configuration.skip_categories))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143842.496746.patch
Type: text/x-patch
Size: 1466 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230212/84156c27/attachment.bin>


More information about the lldb-commits mailing list