Author: Roy Shi
Date: 2026-01-23T09:16:33-08:00
New Revision: e044ad99fed982e953c702dcc9067d156c6e37c5

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

LOG: [lldb] Unconditionally setup posix spawn responsible flag (#177451)

# Problem

The TCC support in LLDB was added by
https://github.com/llvm/llvm-project/commit/041c7b84a4b925476d1e21ed302786033bb6035f.

However, on newer macOS machines, when launching and debugging an
Catalyst app on macOS (see
[Host.mm](https://github.com/llvm/llvm-project/blob/1286de408cc4a3ba1bd6cb6fed7d9517c0429462/lldb/source/Host/macosx/objcxx/Host.mm#L1208-L1219)),
the TCC doesn't work as expected. This is because, even though the
launch info doesn't specify `eLaunchFlagInheritTCCFromParent`, the app
is still launched to inherit TCC from its parent (the LLDB). This
prevents the user from granting privacy access to the Catalyst app,
which is usually reflected in macOS' "Privacy & Security" settings.

For example, in the following screenshot (see PR), even when the microphone
access has already been granted to WhatsApp, trying to use it will still
cause a prompt (as if it's not granted already).


# Fix

On newer macOS versions, the code which was originally inside the `#if
__has_include(<responsibility.h>)` actually works. So the fix is to
unwrap them from the `#if`.

Also, since we already forward declare the type and dlsym the symbol,
the `#include <responsibility.h>` can be removed. Same for the
`@available` check, since the original code handles `dlsym` failure.


See test and screenshots in PR.

Added: 
    

Modified: 
    lldb/source/Host/macosx/objcxx/PosixSpawnResponsible.h

Removed: 
    


################################################################################
diff  --git a/lldb/source/Host/macosx/objcxx/PosixSpawnResponsible.h 
b/lldb/source/Host/macosx/objcxx/PosixSpawnResponsible.h
index 90f8ea9a3be99..23caa4f9a55e0 100644
--- a/lldb/source/Host/macosx/objcxx/PosixSpawnResponsible.h
+++ b/lldb/source/Host/macosx/objcxx/PosixSpawnResponsible.h
@@ -11,33 +11,23 @@
 
 #include <spawn.h>
 
-#if __has_include(<responsibility.h>)
 #include <dispatch/dispatch.h>
 #include <dlfcn.h>
-#include <responsibility.h>
 
-// Older SDKs  have responsibility.h but not this particular function. Let's
-// include the prototype here.
 errno_t responsibility_spawnattrs_setdisclaim(posix_spawnattr_t *attrs,
                                               bool disclaim);
 
-#endif
-
 static inline int setup_posix_spawn_responsible_flag(posix_spawnattr_t *attr) {
-  if (@available(macOS 10.14, *)) {
-#if __has_include(<responsibility.h>)
-    static __typeof__(responsibility_spawnattrs_setdisclaim)
-        *responsibility_spawnattrs_setdisclaim_ptr;
-    static dispatch_once_t pred;
-    dispatch_once(&pred, ^{
-      responsibility_spawnattrs_setdisclaim_ptr =
-          reinterpret_cast<__typeof__(&responsibility_spawnattrs_setdisclaim)>
-          (dlsym(RTLD_DEFAULT, "responsibility_spawnattrs_setdisclaim"));
-    });
-    if (responsibility_spawnattrs_setdisclaim_ptr)
-      return responsibility_spawnattrs_setdisclaim_ptr(attr, true);
-#endif
-  }
+  static __typeof__(responsibility_spawnattrs_setdisclaim)
+      *responsibility_spawnattrs_setdisclaim_ptr;
+  static dispatch_once_t pred;
+  dispatch_once(&pred, ^{
+    responsibility_spawnattrs_setdisclaim_ptr =
+        reinterpret_cast<__typeof__(&responsibility_spawnattrs_setdisclaim)>(
+            dlsym(RTLD_DEFAULT, "responsibility_spawnattrs_setdisclaim"));
+  });
+  if (responsibility_spawnattrs_setdisclaim_ptr)
+    return responsibility_spawnattrs_setdisclaim_ptr(attr, true);
   return 0;
 }
 


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

Reply via email to