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

Conversation

marcprux
Copy link
Contributor

@marcprux marcprux commented May 7, 2025

This fixes the Android build error introduced in 9087bdf.

According to https://android.googlesource.com/platform/bionic/+/master/docs/status.md, posix_spawn_file_actions_addchdir_np was only added in API level 34. There seems to be no equivalent for earlier versions, so we just return ENOSYS for lower API levels (such as API level 29, which the Android SDK is targeting).

@marcprux marcprux requested a review from dmbryson as a code owner May 7, 2025 14:30
@marcprux
Copy link
Contributor Author

marcprux commented May 7, 2025

Thoughts, @finagolfin and @jakepetroules?

@finagolfin
Copy link
Member

@swift-ci test

@dmbryson
Copy link
Contributor

dmbryson commented May 8, 2025

@swift-ci please smoke test

@@ -102,6 +102,9 @@ static int posix_spawn_file_actions_addchdir_polyfill(posix_spawn_file_actions_t
// - FreeBSD 13.1 (May 2022)
// - Android 14 (October 2023)
return posix_spawn_file_actions_addchdir_np((posix_spawn_file_actions_t *)file_actions, path);
#elif defined(__ANDROID__)
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, would you mind moving this up below the glibc case at the top, and write like:

#elif defined(__ANDROID__) && __ANDROID_API__ < 34

...to keep the "missing" cases consolidated at the top?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, would you mind moving this up below the glibc case at the top

Done!

Copy link
Member

Choose a reason for hiding this comment

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

You missed moving it up. I'd also prefer if you combined it with the glibc and OpenBSD cases, since all return the same error.

You can also remove checking the API level is greater than 34 for the affirmative case above.

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'd also prefer if you combined it with the glibc and OpenBSD cases, since all return the same error.

You mean like this? It seems rather tortuous…

#if (defined(__GLIBC__) && !__GLIBC_PREREQ(2, 29)) || (defined(__OpenBSD__)) || (defined(__ANDROID__) && __ANDROID_API__ < 34)
  return ENOSYS;

Copy link
Member

Choose a reason for hiding this comment

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

Yes, either way, Jake asked to move it up above. I prefer it combined like that too.

// 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

#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.

@marcprux marcprux requested a review from jakepetroules May 10, 2025 13:14
@finagolfin
Copy link
Member

@swift-ci please smoke test

@jakepetroules
Copy link
Contributor

@swift-ci test linux

@jakepetroules jakepetroules enabled auto-merge (rebase) May 17, 2025 18:41
@jakepetroules
Copy link
Contributor

@swift-ci smoke test linux

3 similar comments
@finagolfin
Copy link
Member

@swift-ci smoke test linux

@finagolfin
Copy link
Member

@swift-ci smoke test linux

@finagolfin
Copy link
Member

@swift-ci smoke test linux

@finagolfin
Copy link
Member

@swift-ci smoke test windows

@jakepetroules jakepetroules merged commit 53db07c into swiftlang:main May 21, 2025
5 checks passed
marcprux added a commit to swift-everywhere/swift-package-builds that referenced this pull request May 21, 2025
@finagolfin
Copy link
Member

Marc, please submit to 6.2 next, doesn't look like there's an auto-merger for this repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants