-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
[Android] Link native shared libraries with 16k page alignment #104577
[Android] Link native shared libraries with 16k page alignment #104577
Conversation
Do we need the same fix for native aot too? https://github.com/dotnet/runtime/blob/main/src/coreclr/nativeaot/docs/android-bionic.md |
74938a2
to
11843c0
Compare
If NativeAOT binaries will be shipped to the Play Store, then yes. With MonoAOT it's not necessary to make changes here, .NET for Android build process takes care of that. |
Could you explain this in more details? |
Sure, it's quite simple really. MonoAOT is used via an MSBuild task, which is a front to the "old" Mono AOT interface, described in the Mono manpage (quoting just portions of it):
There are a lot of arguments, but what's relevant to us here is the The code that sets the alignment is still in a PR that's not yet merged, so you won't see it in the above code fragment. The relevant MSBuild target in .NET for Android: https://github.com/dotnet/android/blob/35f41dcc7cf5eb65dc12d7c0a3421e67c2bdb6d6/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.Aot.targets#L74-L175 |
I see, thanks. I was asking this because we have a library mode support for mobile (when users do not target net9.0-android, but instead target net9.0 and use android as the runtime identifier - ref). I think the ld-flags should be updated here:
|
11843c0
to
b8fba62
Compare
@ivanpovazan I added the flag to library builder, but is there a way to tell which architecture is being targeted? It's important not only in this case, but also in cases when some architecture requires some special flags (e.g. |
@grendello for the arch check you can use the |
b8fba62
to
9f8a2ea
Compare
src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets
Outdated
Show resolved
Hide resolved
75da004
to
77bc97a
Compare
Fixes: dotnet#103360 Context: https://developer.android.com/guide/practices/page-sizes Context: https://github.com/android/ndk/wiki/Changelog-r27#announcements Sometime next year Google will start requiring that all the `.so` libraries included in applications submitted to the Play Store to be aligned to 16k page boundary (as opposed to the current one of 4k). Make changes to cmake scripts used to build both the BCL native libraries and the MonoVM so that the resulting shared libraries have the correct alignment.
…e.Unix.targets Co-authored-by: Michal Strehovský <MichalStrehovsky@users.noreply.github.com>
77bc97a
to
675d549
Compare
/ba-g failures are on non-Android platforms and are not related. |
Fixes: #103360
Context: https://developer.android.com/guide/practices/page-sizes
Context: https://github.com/android/ndk/wiki/Changelog-r27#announcements
Sometime next year Google will start requiring that all the
.so
libraries includedin applications submitted to the Play Store to be aligned to 16k page boundary (as
opposed to the current one of 4k).
Make changes to cmake scripts used to build both the BCL native libraries and the
MonoVM so that the resulting shared libraries have the correct alignment.