[compiler-rt] [compiler-rt] Disable building sanitizers on platforms without fork(). (PR #83485)

via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 29 18:25:01 PST 2024


https://github.com/rohit-rao updated https://github.com/llvm/llvm-project/pull/83485

>From 645701b66d2e8cef323536e838763ff2a5d8cbef Mon Sep 17 00:00:00 2001
From: Rohit Rao <rohitrao at google.com>
Date: Thu, 29 Feb 2024 16:09:23 -0500
Subject: [PATCH 1/2] [compiler-rt] Disable building sanitizers on platforms
 without fork().

The watchOS and tvOS sanitizers do not compile with publicly-available
SDKs, failing on calls such as fork() and posix_spawn(). Updating the
darwin_test_archs test program to include a call to fork() allows
cmake to exclude those platforms when compiling runtimes. This allows
public builds to enable watchOS/tvOS and compile builtins but not
sanitizers.
---
 compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake b/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
index 6a62d3bf7adced..9b4d6d487259ba 100644
--- a/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
+++ b/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
@@ -116,7 +116,7 @@ function(darwin_test_archs os valid_archs)
   if(NOT TEST_COMPILE_ONLY)
     message(STATUS "Finding valid architectures for ${os}...")
     set(SIMPLE_C ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/src.c)
-    file(WRITE ${SIMPLE_C} "#include <stdio.h>\nint main(void) { printf(__FILE__); return 0; }\n")
+    file(WRITE ${SIMPLE_C} "#include <stdio.h>\nint main(void) { printf(__FILE__); fork(); return 0; }\n")
 
     set(os_linker_flags)
     foreach(flag ${DARWIN_${os}_LINK_FLAGS})

>From 2f997086e5cd746a5ebcd58706639ff8e5a1175c Mon Sep 17 00:00:00 2001
From: Rohit Rao <rohitrao at google.com>
Date: Thu, 29 Feb 2024 21:23:19 -0500
Subject: [PATCH 2/2] #include <unistd.h>

---
 compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake b/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
index 9b4d6d487259ba..1882893ad42c0c 100644
--- a/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
+++ b/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
@@ -116,7 +116,7 @@ function(darwin_test_archs os valid_archs)
   if(NOT TEST_COMPILE_ONLY)
     message(STATUS "Finding valid architectures for ${os}...")
     set(SIMPLE_C ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/src.c)
-    file(WRITE ${SIMPLE_C} "#include <stdio.h>\nint main(void) { printf(__FILE__); fork(); return 0; }\n")
+    file(WRITE ${SIMPLE_C} "#include <stdio.h>\n#include <unistd.h>\nint main(void) { printf(__FILE__); fork(); return 0; }\n")
 
     set(os_linker_flags)
     foreach(flag ${DARWIN_${os}_LINK_FLAGS})



More information about the llvm-commits mailing list