From 6e5a41acb0ffc95f3a5756e4dfe25bc189a22389 Mon Sep 17 00:00:00 2001
From: "Kirill A. Korinsky" <kirill@korins.ky>
Date: Wed, 17 Aug 2022 13:57:02 +0200
Subject: [PATCH] compiler-rt: add some defs missing in older SDKs

---
 compiler-rt/lib/fuzzer/FuzzerUtilDarwin.cpp        | 8 ++++++++
 compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp | 5 +++++
 2 files changed, 13 insertions(+)

diff --git a/compiler-rt/lib/fuzzer/FuzzerUtilDarwin.cpp b/compiler-rt/lib/fuzzer/FuzzerUtilDarwin.cpp
index a5bed658a446..b853462df3d2 100644
--- a/compiler-rt/lib/fuzzer/FuzzerUtilDarwin.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerUtilDarwin.cpp
@@ -19,6 +19,14 @@
 #include <sys/wait.h>
 #include <unistd.h>
 
+// add definition missing on older systems
+#ifndef POSIX_SPAWN_SETSIGMASK
+#define POSIX_SPAWN_SETSIGMASK          0x0008
+#endif
+#ifndef POSIX_SPAWN_SETSIGDEF
+#define POSIX_SPAWN_SETSIGDEF           0x0004
+#endif
+
 // There is no header for this on macOS so declare here
 extern "C" char **environ;
 
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
index 7a3dfbcc2760..651fe0c35625 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
@@ -110,6 +110,11 @@ extern "C" int __munmap(void *, size_t) SANITIZER_WEAK_ATTRIBUTE;
 #define VM_MEMORY_SANITIZER 99
 #endif
 
+// From <sys/spawn.h> but not in some SDKs
+#ifndef POSIX_SPAWN_CLOEXEC_DEFAULT
+#define	POSIX_SPAWN_CLOEXEC_DEFAULT	0x4000
+#endif
+
 // XNU on Darwin provides a mmap flag that optimizes allocation/deallocation of
 // giant memory regions (i.e. shadow memory regions).
 #define kXnuFastMmapFd 0x4
-- 
2.37.2

