Author: Adrian Prantl
Date: 2026-07-29T08:30:13-07:00
New Revision: 312aa8cf8ccd97c0d2a6980c0a0fb9ee0ee5290e

URL: 
https://github.com/llvm/llvm-project/commit/312aa8cf8ccd97c0d2a6980c0a0fb9ee0ee5290e
DIFF: 
https://github.com/llvm/llvm-project/commit/312aa8cf8ccd97c0d2a6980c0a0fb9ee0ee5290e.diff

LOG: [LLDB] Remove Xcode sdk guessing from Makefile.rules (NFC) (#212378)

This cleanup patch pushes the auto-detection of the `macosx` SDK from
Makefile.rules up into `dotest.py` and unifies it with the existing SDK
handling for other Apple platforms.

Assisted-by: claude

Added: 
    

Modified: 
    lldb/packages/Python/lldbsuite/test/builders/builder.py
    lldb/packages/Python/lldbsuite/test/dotest.py
    lldb/packages/Python/lldbsuite/test/lldbtest.py
    lldb/packages/Python/lldbsuite/test/make/Makefile.rules

Removed: 
    


################################################################################
diff  --git a/lldb/packages/Python/lldbsuite/test/builders/builder.py 
b/lldb/packages/Python/lldbsuite/test/builders/builder.py
index 93ce4cc732bd3..b5f0f28a8df8a 100644
--- a/lldb/packages/Python/lldbsuite/test/builders/builder.py
+++ b/lldb/packages/Python/lldbsuite/test/builders/builder.py
@@ -209,15 +209,6 @@ def getToolchainUtil(util_name):
             "CXX=%s" % cxx,
         ] + utils
 
-    def getSDKRootSpec(self):
-        """
-        Helper function to return the key-value string to specify the SDK root
-        used for the make system.
-        """
-        if configuration.sdkroot:
-            return ["SDKROOT={}".format(configuration.sdkroot)]
-        return []
-
     def getModuleCacheSpec(self):
         """
         Helper function to return the key-value string to specify the clang
@@ -302,7 +293,6 @@ def getBuildCommand(
             self.getTripleSpec(),
             self.getToolchainSpec(compiler),
             self.getExtraMakeArgs(),
-            self.getSDKRootSpec(),
             self.getModuleCacheSpec(),
             self.getLibCxxArgs(),
             self.getLLDBObjRoot(),

diff  --git a/lldb/packages/Python/lldbsuite/test/dotest.py 
b/lldb/packages/Python/lldbsuite/test/dotest.py
index caa5c81b82cbb..604fb98b1e2e5 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -326,15 +326,15 @@ def parseOptionsAndInitTestdirs():
     if args.out_of_tree_debugserver:
         lldbtest_config.out_of_tree_debugserver = args.out_of_tree_debugserver
 
-    # Set SDKROOT if we are using an Apple SDK
     if args.sysroot:
         configuration.sdkroot = args.sysroot
-    elif platform_system == "Darwin" and args.apple_sdk:
+    elif platform_system == "Darwin":
+        sdk = args.apple_sdk if args.apple_sdk else "macosx"
         configuration.sdkroot = seven.get_command_output(
-            'xcrun --sdk "%s" --show-sdk-path 2> /dev/null' % (args.apple_sdk)
+            'xcrun --sdk "%s" --show-sdk-path 2> /dev/null' % (sdk)
         )
         if not configuration.sdkroot:
-            logging.error("No SDK found with the name %s; aborting...", 
args.apple_sdk)
+            logging.error('xcrun found no SDK for "%s"', sdk)
             sys.exit(-1)
 
     if args.triple:

diff  --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index f1dfee1714981..a0056f0054c06 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1685,8 +1685,11 @@ def build_and_run(
 
     def runBuildCommand(self, command):
         self.trace(shlex.join(command))
+        env = dict(os.environ)
+        if configuration.sdkroot:
+            env["SDKROOT"] = configuration.sdkroot
         try:
-            output = check_output(command, stderr=STDOUT, errors="replace")
+            output = check_output(command, stderr=STDOUT, errors="replace", 
env=env)
         except CalledProcessError as cpe:
             raise build_exception.BuildError(cpe)
         self.trace(output)

diff  --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules 
b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
index 51729959fdf62..dc799cb454704 100644
--- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -174,8 +174,7 @@ endif
 
 ifeq "$(OS)" "Darwin"
     ifeq "$(SDKROOT)" ""
-       # We haven't otherwise set the SDKROOT, so set it now to macosx
-       SDKROOT := $(shell xcrun --sdk macosx --show-sdk-path)
+        $(error SDKROOT must be set on Darwin)
     endif
     SYSROOT_FLAGS := -isysroot "$(SDKROOT)"
     GCC_TOOLCHAIN_FLAGS :=


        
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to