Skip to content

Return ENOSYS for posix_spawn_file_actions_addchdir on older Android versions #985

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions lib/Basic/Subprocess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,19 @@ int pthread_fchdir_np(int fd)
// Implementation mostly copied from _CFPosixSpawnFileActionsChdir in swift-corelibs-foundation
static int posix_spawn_file_actions_addchdir_polyfill(posix_spawn_file_actions_t * __restrict file_actions,
const char * __restrict path) {
#if defined(__GLIBC__) && !__GLIBC_PREREQ(2, 29)
#if (defined(__GLIBC__) && !__GLIBC_PREREQ(2, 29)) || (defined(__OpenBSD__)) || (defined(__ANDROID__) && __ANDROID_API__ < 34)
// Glibc versions prior to 2.29 don't support posix_spawn_file_actions_addchdir_np, impacting:
// - Amazon Linux 2 (EoL mid-2025)
// Currently missing as of:
// - OpenBSD 7.5 (April 2024)
// - Android <= 14
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While you're here, could you move the QNX 8 comment here too?. The function is actually missing on that platform. It is mistakenly labeled as supported due to an error in earlier refactoring.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume you also want to add a check for defined(__QNX__) for that block? I've moved the comment and added the check in 2cfc9eb

return ENOSYS;
#elif defined(__APPLE__) && defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500
// Conditionally available on macOS if building with a deployment target older than 10.15
if (__builtin_available(macOS 10.15, *)) {
return posix_spawn_file_actions_addchdir_np(file_actions, path);
}
return ENOSYS;
#elif defined(__OpenBSD__)
// Currently missing as of:
// - OpenBSD 7.5 (April 2024)
return ENOSYS;
#elif defined(__GLIBC__) || defined(__APPLE__) || defined(__FreeBSD__) || (defined(__ANDROID__) && __ANDROID_API__ >= 34) || defined(__musl__)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ANDROID_API >= 34 bit is no longer needed.

// Pre-standard posix_spawn_file_actions_addchdir_np version available in:
// - Solaris 11.3 (October 2015)
Expand Down