[compiler-rt] Allow building the profiler runtime on tvOS and watchOS (PR #180704)

Mads Marquart via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 10 00:49:08 PST 2026


https://github.com/madsmtm created https://github.com/llvm/llvm-project/pull/180704

These platforms do not have `fork`, it is marked as `__TVOS_PROHIBITED` and `__WATCHOS_PROHIBITED` in the header.

Allows Rust to ship a prebuilt profiler runtime, see https://github.com/rust-lang/rust/issues/152426.

CC @isanbard. I don't have the ability to merge the PR myself.

>From 9aa33e8fe0b470ef92e35d5322739c80d5e192f1 Mon Sep 17 00:00:00 2001
From: Mads Marquart <mads at marquart.dk>
Date: Tue, 10 Feb 2026 09:37:22 +0100
Subject: [PATCH] Allow building the profiler runtime on tvOS and watchOS

These platforms do not have `fork`, it is marked as `__TVOS_PROHIBITED`
and `__WATCHOS_PROHIBITED` in the header.
---
 compiler-rt/lib/profile/GCDAProfiling.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/compiler-rt/lib/profile/GCDAProfiling.c b/compiler-rt/lib/profile/GCDAProfiling.c
index 523ade5eafc15..da2cfdcf14eaf 100644
--- a/compiler-rt/lib/profile/GCDAProfiling.c
+++ b/compiler-rt/lib/profile/GCDAProfiling.c
@@ -44,6 +44,13 @@
 #include <unistd.h>
 #endif
 
+#if defined(__APPLE__)
+#include <TargetConditionals.h>
+#else
+#define TARGET_OS_TV 0
+#define TARGET_OS_WATCH 0
+#endif
+
 #include "InstrProfiling.h"
 #include "InstrProfilingUtil.h"
 
@@ -589,7 +596,8 @@ void llvm_reset_counters(void) {
   }
 }
 
-#if !defined(_WIN32) && !defined(__wasm__)
+// `fork` is not available on Windows, WASM, tvOS or watchOS.
+#if !defined(_WIN32) && !defined(__wasm__) && !TARGET_OS_TV && !TARGET_OS_WATCH
 COMPILER_RT_VISIBILITY
 pid_t __gcov_fork() {
   pid_t parent_pid = getpid();



More information about the llvm-commits mailing list