<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/125309>125309</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            compiler_rt build for watchOS/tvOS
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          DmT021
      </td>
    </tr>
</table>

<pre>
    compiler_rt doesn't build for watchOS/tvOS, because the following functions are explicitly marked unavailable.
```C
pid_t    fork(void) __WATCHOS_PROHIBITED __TVOS_PROHIBITED;
int      execve(const char * __file, char * const * __argv, char * const * __envp) __WATCHOS_PROHIBITED __TVOS_PROHIBITED;
int posix_spawn_file_actions_init(posix_spawn_file_actions_t *) __API_AVAILABLE(macos(10.5), ios(2.0)) __API_UNAVAILABLE(watchos, tvos);
int posix_spawn_file_actions_destroy(posix_spawn_file_actions_t *) __API_AVAILABLE(macos(10.5), ios(2.0)) __API_UNAVAILABLE(watchos, tvos);
int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t *, int,
 int) __API_AVAILABLE(macos(10.5), ios(2.0)) __API_UNAVAILABLE(watchos, tvos);
int     posix_spawn_file_actions_addclose(posix_spawn_file_actions_t *, int) __API_AVAILABLE(macos(10.5), ios(2.0)) __API_UNAVAILABLE(watchos, tvos);
int     posix_spawnattr_init(posix_spawnattr_t *) __API_AVAILABLE(macos(10.5), ios(2.0)) __API_UNAVAILABLE(watchos, tvos);
int posix_spawnattr_destroy(posix_spawnattr_t *) __API_AVAILABLE(macos(10.5), ios(2.0)) __API_UNAVAILABLE(watchos, tvos);
int posix_spawnattr_setflags(posix_spawnattr_t *, short) __API_AVAILABLE(macos(10.5), ios(2.0)) __API_UNAVAILABLE(watchos, tvos);
int posix_spawn(pid_t * __restrict, const char * __restrict,
    const posix_spawn_file_actions_t *,
    const posix_spawnattr_t * __restrict,
 char *const __argv[__restrict],
    char *const __envp[__restrict]) __API_AVAILABLE(macos(10.5), ios(2.0)) __API_UNAVAILABLE(watchos, tvos);
```

<details>
  <summary>Log</summary>
  
  ```
[4675/5208][ 89%][1646.297s] Performing build step for 'compiler-rt'
[6522/8323][ 78%][135.376s] Building CXX object lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.watchossim.dir/sanitizer_mac.cpp.o
FAILED: lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.watchossim.dir/sanitizer_mac.cpp.o
/opt/homebrew/bin/sccache /Users/dmt021/w/swift-project/build/Ninja-RelWithDebInfoAssert/llvm-macosx-arm64/bin/clang++ -DHAVE_RPC_XDR_H=1 -I/Users/dmt021/w/swift-project/llvm-project/compiler-rt/lib/sanitizer_common/.. -Wall -Wno-unused-parameter -O2 -g -DNDEBUG -std=c++17 -arch arm64 -arch i386 -arch x86_64 -isysroot /Applications/Xcode16.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk -stdlib=libc++ -mwatchos-simulator-version-min=2.0 -isysroot /Applications/Xcode16.2.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator11.2.sdk -fPIC -fno-builtin -fno-exceptions -funwind-tables -fno-stack-protector -fno-sanitize=safe-stack -fvisibility=hidden -fno-lto -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta -O3 -g -Wno-gnu -Wno-variadic-macros -Wno-c99-extensions -nostdinc++ -Wno-format -fno-rtti -Wframe-larger-than=570 -Wglobal-constructors -MD -MT lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.watchossim.dir/sanitizer_mac.cpp.o -MF lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.watchossim.dir/sanitizer_mac.cpp.o.d -o lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.watchossim.dir/sanitizer_mac.cpp.o -c /Users/dmt021/w/swift-project/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
/Users/dmt021/w/swift-project/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp:253:10: error: 'fork' is unavailable: not available on watchOS
  253 |   return fork();
      | ^
/Applications/Xcode16.2.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator11.2.sdk/usr/include/unistd.h:447:8: note: 'fork' has been explicitly marked unavailable here
  447 | pid_t fork(void) __WATCHOS_PROHIBITED __TVOS_PROHIBITED;
      | ^
/Users/dmt021/w/swift-project/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp:299:9: error: 'posix_spawn_file_actions_init' is unavailable: not available on watchOS
  299 |   res = posix_spawn_file_actions_init(&acts);
      | ^
/Applications/Xcode16.2.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator11.2.sdk/usr/include/spawn.h:83:9: note: 'posix_spawn_file_actions_init' has been explicitly marked unavailable here
   83 | int posix_spawn_file_actions_init(posix_spawn_file_actions_t *) __API_AVAILABLE(macos(10.5), ios(2.0)) __API_UNAVAILABLE(watchos, tvos);
 | ^
/Users/dmt021/w/swift-project/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp:303:5: error: 'posix_spawn_file_actions_destroy' is unavailable: not available on watchOS
  303 |     posix_spawn_file_actions_destroy(&acts);
      | ^
/Applications/Xcode16.2.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator11.2.sdk/usr/include/spawn.h:81:9: note: 'posix_spawn_file_actions_destroy' has been explicitly marked unavailable here
   81 | int posix_spawn_file_actions_destroy(posix_spawn_file_actions_t *) __API_AVAILABLE(macos(10.5), ios(2.0)) __API_UNAVAILABLE(watchos, tvos);
 | ^
/Users/dmt021/w/swift-project/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp:306:9: error: 'posix_spawn_file_actions_adddup2' is unavailable: not available on watchOS
  306 |   res = posix_spawn_file_actions_adddup2(&acts, secondary_fd, STDIN_FILENO) ||
      | ^
/Applications/Xcode16.2.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator11.2.sdk/usr/include/spawn.h:74:9: note: 'posix_spawn_file_actions_adddup2' has been explicitly marked unavailable here
   74 | int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t *, int,
      | ^
/Users/dmt021/w/swift-project/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp:307:9: error: 'posix_spawn_file_actions_adddup2' is unavailable: not available on watchOS
  307 |         posix_spawn_file_actions_adddup2(&acts, secondary_fd, STDOUT_FILENO) ||
      | ^
/Applications/Xcode16.2.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator11.2.sdk/usr/include/spawn.h:74:9: note: 'posix_spawn_file_actions_adddup2' has been explicitly marked unavailable here
   74 | int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t *, int,
      | ^
/Users/dmt021/w/swift-project/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp:308:9: error: 'posix_spawn_file_actions_addclose' is unavailable: not available on watchOS
  308 |         posix_spawn_file_actions_addclose(&acts, secondary_fd);
      | ^
/Applications/Xcode16.2.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator11.2.sdk/usr/include/spawn.h:72:9: note: 'posix_spawn_file_actions_addclose' has been explicitly marked unavailable here
   72 | int posix_spawn_file_actions_addclose(posix_spawn_file_actions_t *, int) __API_AVAILABLE(macos(10.5), ios(2.0)) __API_UNAVAILABLE(watchos, tvos);
 | ^
/Users/dmt021/w/swift-project/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp:313:9: error: 'posix_spawnattr_init' is unavailable: not available on watchOS
  313 |   res = posix_spawnattr_init(&attrs);
      | ^
/Applications/Xcode16.2.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator11.2.sdk/usr/include/spawn.h:99:9: note: 'posix_spawnattr_init' has been explicitly marked unavailable here
 99 | int     posix_spawnattr_init(posix_spawnattr_t *) __API_AVAILABLE(macos(10.5), ios(2.0)) __API_UNAVAILABLE(watchos, tvos);
 | ^
/Users/dmt021/w/swift-project/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp:317:5: error: 'posix_spawnattr_destroy' is unavailable: not available on watchOS
 317 |     posix_spawnattr_destroy(&attrs);
      | ^
/Applications/Xcode16.2.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator11.2.sdk/usr/include/spawn.h:85:9: note: 'posix_spawnattr_destroy' has been explicitly marked unavailable here
 85 | int     posix_spawnattr_destroy(posix_spawnattr_t *) __API_AVAILABLE(macos(10.5), ios(2.0)) __API_UNAVAILABLE(watchos, tvos);
 | ^
/Users/dmt021/w/swift-project/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp:322:9: error: 'posix_spawnattr_setflags' is unavailable: not available on watchOS
 322 |   res = posix_spawnattr_setflags(&attrs, POSIX_SPAWN_CLOEXEC_DEFAULT);
      | ^
/Applications/Xcode16.2.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator11.2.sdk/usr/include/spawn.h:104:9: note: 'posix_spawnattr_setflags' has been explicitly marked unavailable here
  104 | int     posix_spawnattr_setflags(posix_spawnattr_t *, short) __API_AVAILABLE(macos(10.5), ios(2.0)) __API_UNAVAILABLE(watchos, tvos);
 | ^
/Users/dmt021/w/swift-project/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp:328:9: error: 'posix_spawn' is unavailable: not available on watchOS
  328 |   res = posix_spawn(pid, argv[0], &acts, &attrs, argv_casted, envp_casted);
 | ^
/Applications/Xcode16.2.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator11.2.sdk/usr/include/spawn.h:60:9: note: 'posix_spawn' has been explicitly marked unavailable here
   60 | int posix_spawn(pid_t * __restrict, const char * __restrict,
      | ^
/Users/dmt021/w/swift-project/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp:379:10: error: 'execve' is unavailable: not available on watchOS
  379 |   return execve(filename, argv, envp);
      | ^
/Applications/Xcode16.2.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator11.2.sdk/usr/include/unistd.h:445:6: note: 'execve' has been explicitly marked unavailable here
  445 | int execve(const char * __file, char * const * __argv, char * const * __envp) __WATCHOS_PROHIBITED __TVOS_PROHIBITED;
      |          ^
  ```
 
</details>


</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzsmllzo7rywD-N8qKCAslsD37AxvzH9c8kqUlmkjdKFrKtMyBRkuwk99PfEnjLajvnTpZTJ5VKQDRSq_XrprUQrflMMNYHwQAE2QlZmLlU_ay-8pB_MpHlfZ_KuuEVU4UysJRMC4AiAycLXpVwKhW8JYbOzy8Bys3S_hvCCaNkoRk0cwansqrkLRczOF0IargUGhLFILtrKk65qe5hTdRvVsKFIEvCKzKpmAu8FIRe9zsEXtrwsjDAS2yDvwGKl5KXACWwKK7Tq-G388vi4sf5t_FgfDXKYFFc_XpQAvAAeCkXbQ3sjtElAyimUmgD6ZwoCFAKi2LKK2bV3xR1Et1DombLFx8ysWzeoA5spOZ3hW7IrWhbL0hnoYILbgCKX3zeNty1mF6Mi_RXOj5NB6cjgOKaUKkBin3PDQBKrM68LUCu196vX_p5tvtaO4pWbgjN0v5PDlCzZNooef8FNCVlWS4adICmQ2hBQZa67uqdVLc_r6lPK6nZ4fp_jNbEGPUMvG3xh5HQtv4sqp9AL83MtCIz_bJiQ6jnUr3fkO6oYZWykXcV5pS1IaemjYOPo-fOQ-s6EK5E9vL6kvTWBk9rX7fbvbSKzsFgRy7Idqp-JN2G6yfS72DezTfNXnspwMOSGcIrDfCo1RXgoV7UNVH3AI9O5QzgIUD5tqgTav_sVhUMemEUAJQHyIttZ4IBjBOAgu7aD3uhi5JIgyCDF0xNpartF7n7hmvDmvZDDlC0_tY7lreoqzoMEAIojzHCq6qjeFs1DlwchW3NA1udrXd4cwPl5C9G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