From 3f7dabaf1bf98197e5abbfe289fcda8b0f939f9a Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Fri, 24 Oct 2025 22:13:40 -0700 Subject: [PATCH] Call posix_spawnp through a wrapper functions, since the nullability changed in incompatible ways between Android NDK r27 and r28 This will allow the package to build with both r27 and r28, the former of which is currently the default on swiftlang's GitHub Actions CI. --- Sources/TSCBasic/Process/Process.swift | 2 +- Sources/TSCclibc/include/process.h | 2 ++ Sources/TSCclibc/process.c | 4 ++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Sources/TSCBasic/Process/Process.swift b/Sources/TSCBasic/Process/Process.swift index bd946b88..2d0c8d72 100644 --- a/Sources/TSCBasic/Process/Process.swift +++ b/Sources/TSCBasic/Process/Process.swift @@ -742,7 +742,7 @@ public final class Process { } let argv = CStringArray(resolvedArgs) let env = CStringArray(environment.map({ "\($0.0)=\($0.1)" })) - let rv = posix_spawnp(&processID, argv.cArray[0]!, &fileActions, &attributes, argv.cArray, env.cArray) + let rv = SPM_posix_spawnp(&processID, argv.cArray[0]!, &fileActions, &attributes, argv.cArray, env.cArray) guard rv == 0 else { throw SystemError.posix_spawn(rv, arguments) diff --git a/Sources/TSCclibc/include/process.h b/Sources/TSCclibc/include/process.h index 08c57f37..2b9960ec 100644 --- a/Sources/TSCclibc/include/process.h +++ b/Sources/TSCclibc/include/process.h @@ -18,6 +18,8 @@ int SPM_posix_spawn_file_actions_addchdir_np(posix_spawn_file_actions_t *restric // Runtime check for the availability of posix_spawn_file_actions_addchdir_np. Returns 0 if the method is available, -1 if not. bool SPM_posix_spawn_file_actions_addchdir_np_supported(); +int SPM_posix_spawnp(pid_t *pid, const char *file, const posix_spawn_file_actions_t *actions, const posix_spawnattr_t *attr, char *const argv[], char *const env[]); + #ifdef TSC_API_UNAVAILABLE_DEFINED #undef TSC_API_UNAVAILABLE_DEFINED #undef __API_UNAVAILABLE diff --git a/Sources/TSCclibc/process.c b/Sources/TSCclibc/process.c index d6ac2a06..03c94015 100644 --- a/Sources/TSCclibc/process.c +++ b/Sources/TSCclibc/process.c @@ -52,4 +52,8 @@ bool SPM_posix_spawn_file_actions_addchdir_np_supported() { #endif } +int SPM_posix_spawnp(pid_t *pid, const char *file, const posix_spawn_file_actions_t *actions, const posix_spawnattr_t *attr, char *const argv[], char *const env[]) { + return posix_spawnp(pid, file, actions, attr, argv, env); +} + #endif