Skip to content

[android] Use emulated thread-local storage for API 28 and earlier #78591

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 1 commit into from
Jan 15, 2025

Conversation

finagolfin
Copy link
Member

Explanation: Android before API 29 and a few other platforms don't support native TLS, so fall back to LLVM's emulated TLS there, just like clang does. Also, make sure -Xcc -f{no-,}emulated-tls flags passed in are applied to control what the Swift compiler does.

Scope: Has no effect by default, except on Android API 28 or older, OpenBSD, and a couple other platforms Swift doesn't support

Issue: None

Original PR: #77883

Risk: very low

Testing: Passed all CI on trunk and now on my Android CI running at API 24, when built with the latest Jan. 10 trunk snapshot tag containing this commit

Reviewer: @compnerd

This will allow Foundation in my Android SDK bundle and native toolchain for Android to support APIs 24-28 again, finagolfin/swift-android-sdk#175.

Android before API 29 and a few other platforms don't support native TLS, so
fall back to LLVM's emulated TLS there, just like clang does. Also, make sure
`-Xcc -f{no-,}emulated-tls` flags passed in are applied to control what the
Swift compiler does.
@finagolfin finagolfin added 🍒 release cherry pick Flag: Release branch cherry picks swift 6.0 labels Jan 12, 2025
@finagolfin finagolfin requested a review from a team as a code owner January 12, 2025 10:15
@finagolfin
Copy link
Member Author

@swift-ci please test

Copy link
Member

@DougGregor DougGregor left a comment

Choose a reason for hiding this comment

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

This looks reasonable. Is this the only thing change needed for API levels 24-28?

@finagolfin
Copy link
Member Author

Is this the only thing change needed for API levels 24-28?

Yes, I make a few more changes to the CMake config or Android module map that've been merged into trunk also, such as #76460 and #78241, but those are for all API versions and can be added easily on my CI. This change can't, as my Android CI uses the official prebuilt compiler for linux to cross-compile the stdlib and corelibs, so I'm trying to get this compiler change in for that.

@finagolfin finagolfin merged commit 9090bb3 into swiftlang:release/6.0 Jan 15, 2025
5 checks passed
@finagolfin finagolfin deleted the tls branch January 15, 2025 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks swift 6.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants