https://github.com/chelcassanova updated 
https://github.com/llvm/llvm-project/pull/151291

>From f764bae8d7977c61abd9aa106cf55f3294af4cdc Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova <chelsea_cassan...@apple.com>
Date: Wed, 30 Jul 2025 00:56:06 -0700
Subject: [PATCH] [lldb][rpc] Add sysroot to lldb-rpc-gen test suite invocation

When running the lldb-rpc-gen tests On Darwin platforms, the sysroot
needs to be added to the test invocation. Without it, basic includes
will not be resolved and the test will fail.
---
 lldb/test/Shell/helper/toolchain.py | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/lldb/test/Shell/helper/toolchain.py 
b/lldb/test/Shell/helper/toolchain.py
index 728f6347242f1..ffef9b01315bb 100644
--- a/lldb/test/Shell/helper/toolchain.py
+++ b/lldb/test/Shell/helper/toolchain.py
@@ -119,6 +119,20 @@ def use_lldb_substitutions(config):
 
     lldb_init = _get_lldb_init_path(config)
 
+    sysroot_arg = ""
+    if platform.system() in ["Darwin"]:
+        if config.cmake_sysroot:
+            sysroot_arg = '--extra-arg="--sysroot=' + config.cmake_sysroot + 
'"'
+        else:
+            try:
+                out = subprocess.check_output(["xcrun", 
"--show-sdk-path"]).strip()
+                res = 0
+            except OSError:
+                res = -1
+                if res == 0 and out:
+                    sdk_path = lit.util.to_string(out)
+                    sysroot_arg = '--extra-arg="--sysroot=' + sdk_path + '"'
+
     primary_tools = [
         ToolSubst(
             "%lldb",
@@ -163,6 +177,7 @@ def use_lldb_substitutions(config):
             extra_args=[
                 "-p " + config.lldb_build_directory + "/..",
                 '--extra-arg="-resource-dir=' + config.clang_resource_dir + 
'"',
+                sysroot_arg,
             ],
             unresolved="ignore",
         ),

_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to