Skip to content

Commit 1cc35cc

Browse files
marcpruxfinagolfin
authored andcommitted
Return ENOSYS for posix_spawn_file_actions_addchdir on older Android versions
1 parent 2f6bf50 commit 1cc35cc

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

lib/Basic/Subprocess.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,21 +79,21 @@ int pthread_fchdir_np(int fd)
7979
// Implementation mostly copied from _CFPosixSpawnFileActionsChdir in swift-corelibs-foundation
8080
static int posix_spawn_file_actions_addchdir_polyfill(posix_spawn_file_actions_t * __restrict file_actions,
8181
const char * __restrict path) {
82-
#if defined(__GLIBC__) && !__GLIBC_PREREQ(2, 29)
82+
#if (defined(__GLIBC__) && !__GLIBC_PREREQ(2, 29)) || (defined(__OpenBSD__)) || (defined(__ANDROID__) && __ANDROID_API__ < 34) || (defined(__QNX__))
8383
// Glibc versions prior to 2.29 don't support posix_spawn_file_actions_addchdir_np, impacting:
8484
// - Amazon Linux 2 (EoL mid-2025)
85+
// Currently missing as of:
86+
// - OpenBSD 7.5 (April 2024)
87+
// - QNX 8 (December 2023)
88+
// - Android <= 14
8589
return ENOSYS;
8690
#elif defined(__APPLE__) && defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500
8791
// Conditionally available on macOS if building with a deployment target older than 10.15
8892
if (__builtin_available(macOS 10.15, *)) {
8993
return posix_spawn_file_actions_addchdir_np(file_actions, path);
9094
}
9195
return ENOSYS;
92-
#elif defined(__OpenBSD__)
93-
// Currently missing as of:
94-
// - OpenBSD 7.5 (April 2024)
95-
return ENOSYS;
96-
#elif defined(__GLIBC__) || defined(__APPLE__) || defined(__FreeBSD__) || (defined(__ANDROID__) && __ANDROID_API__ >= 34) || defined(__musl__)
96+
#elif defined(__GLIBC__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__ANDROID__) || defined(__musl__)
9797
// Pre-standard posix_spawn_file_actions_addchdir_np version available in:
9898
// - Solaris 11.3 (October 2015)
9999
// - Glibc 2.29 (February 2019)
@@ -106,7 +106,6 @@ static int posix_spawn_file_actions_addchdir_polyfill(posix_spawn_file_actions_t
106106
// Standardized posix_spawn_file_actions_addchdir version (POSIX.1-2024, June 2024) available in:
107107
// - Solaris 11.4 (August 2018)
108108
// - NetBSD 10.0 (March 2024)
109-
// - QNX 8 (December 2023)
110109
return posix_spawn_file_actions_addchdir((posix_spawn_file_actions_t *)file_actions, path);
111110
#endif
112111
}

0 commit comments

Comments
 (0)