-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Support 16 KB page sizes on Android #81596
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
Conversation
Android 15+ requires that native libraries be compiled with a linker flag to support 16 KB page sizes. See: https://developer.android.com/guide/practices/page-sizes#compile-r26-lower
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is also incompatible with 4K pages, which is still supported I believe. Unless Google has stated that they are going to prevent 4K pages on ARM64, we should have two separate runtimes.
I don't think the OS will require this, only the Play store. I see conflicting reports on whether such 16 KB-aligned shared libraries will continue working with older 4 KB devices: have you built and tested Swift packages using this flag in 16 KB and 4 KB emulators? Until we've done so, no point in applying this flag. |
It’s fully compatible with devices that use 4K pages. In fact, starting from Android NDK 28, this linker flag is enabled by default and cannot be disabled. We only need to set this flag manually because we are using NDK 27.
No, the binary will crash on startup if it is not properly aligned when running on a device with 16 KB pages. Google provides an emulator image for 16 KB page size devices, so this can be tested even without real hardware. Mark pushed it a little bit early. We are still in the process of testing our toolchain on both 4 KB and 16 KB devices, but so far, no issues have been detected - it runs smoothly on both. |
Right, but he said "Android 15+ requires," not just devices with 16 KB pages. I think they will continue supporting the 4 KB kernel and old 4 KB-aligned apps on the majority of Android 15+ devices, hence it is not a requirement of the Android 15+ OS yet. |
I should have clarified that there are two separate requirements:
Footnotes |
Given that the only objection was based on an incorrect assumption, what is blocking this? If we don't get 16KB support for the Android SDK, the Play Store is going to block any app submissions that use Swift in a few months. |
Should be fine, but we should apply it to the corelibs also here, |
That got us a lot closer. Running the handy
I don't think we need to worry about Any suggestions on where to add the flag for those? |
Those are the remaining C/C++ libraries, plus Testing, that we distribute. Testing is currently not supported officially for Android, which is why I still patch it in for our SDK bundles. I'm looking at properly adding build config for that in this repo, so I will add this linker flag separately for it then. As for C/C++ libraries, I believe the right way to pass that in was long with the I suggest we get this in and punt those last few libraries for whenever we get those CMake issues figured out. |
@swift-ci smoke test |
An alternative way to activate the 16KB page support is to specify |
That's if using the NDK's CMake config, which we don't use. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works fine on my Android CI in testing on an Android x86_64 emulator with the old 4K pages.
Gave others time to review, passed CI and only affects Android, so merging. |
Android 15+ requires that native libraries be compiled with a linker flag to support 16 KB page sizes. See: https://developer.android.com/guide/practices/page-sizes#compile-r26-lower