-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[Android] Support static linking of CoreCLR on Android #114629
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
kotlarmilos
merged 29 commits into
dotnet:main
from
kotlarmilos:feature/coreclr-android-static-libs
May 7, 2025
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
4243eb0
Update ApkBuilder to support static linking
kotlarmilos 43310f2
Add static libs to the framework directory
kotlarmilos 4463fae
Add static libs to the runtime pack
kotlarmilos f08e9fe
Fix formatting
kotlarmilos ffa5351
Add object libraries for Android static linking
kotlarmilos 8507f65
Install libcoreclrpal.a as it is linked using -Wl,--whole-archive
kotlarmilos 76b4d6a
Fix x64 static linking
kotlarmilos 2ef4399
Add gc_vxsort objects
kotlarmilos 1ff51f6
Add static test project
kotlarmilos 0584ea8
Fix MainLibraryFileName in Android.Device_Emulator.JIT.Static.Test pr…
kotlarmilos d6a2893
Update src/coreclr/gc/vxsort/CMakeLists.txt
kotlarmilos 2b3a5ee
Update src/coreclr/gc/unix/CMakeLists.txt
kotlarmilos db2e108
Update CMakeLists.txt to conditionally link gc_pal_objects for Android
kotlarmilos 39dea31
Test static linking on linux
kotlarmilos de2506e
Fix typo
kotlarmilos 1a12a79
Revert gc_pal changes to test the build
kotlarmilos 7f282b6
Revert changes
kotlarmilos 2df2281
Merge branch 'dotnet:main' into feature/coreclr-android-static-libs
kotlarmilos 21b454f
Add gcinfo library
kotlarmilos d17fe7a
Conditionally add gcinfo
kotlarmilos d53aefc
FIx formatting
kotlarmilos cd867ae
Switch from static to object
kotlarmilos a9ac92c
Merge branch 'main' into feature/coreclr-android-static-libs
kotlarmilos e9d5b20
Fix coreclr build
kotlarmilos 7b4efbf
Remove unnecessary static library installation for Android
kotlarmilos ea53d06
Update static libraries to be based on the object libraries
kotlarmilos 4dc57cf
Merge branch 'main' into feature/coreclr-android-static-libs
kotlarmilos 5e6cc7c
Add coreclrpal_objects
kotlarmilos ed47a53
Merge branch 'main' into feature/coreclr-android-static-libs
kotlarmilos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
project(nativeresourcestring) | ||
|
||
add_library_clr(nativeresourcestring_objects | ||
OBJECT | ||
resourcestring.cpp | ||
) | ||
|
||
add_library_clr(nativeresourcestring | ||
STATIC | ||
resourcestring.cpp | ||
$<TARGET_OBJECTS:nativeresourcestring_objects> | ||
) | ||
|
||
install_clr (TARGETS nativeresourcestring DESTINATIONS lib) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...unctionalTests/Android/Device_Emulator/JIT/Android.Device_Emulator.JIT.Static.Test.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<RunAOTCompilation>false</RunAOTCompilation> | ||
<TestRuntime>true</TestRuntime> | ||
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework> | ||
<MainLibraryFileName>Android.Device_Emulator.JIT.Static.Test.dll</MainLibraryFileName> | ||
<ExpectedExitCode>42</ExpectedExitCode> | ||
<StaticLinkedRuntime>true</StaticLinkedRuntime> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Compile Include="Program.cs" /> | ||
</ItemGroup> | ||
</Project> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I think it would be nice to use the same style, either this one in
src/coreclr/gc/unix/CMakeLists.txt
or the other way around.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.
Do you mean to conditionally add gc_vxsort objects if android host?
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.
That or change static to object in gc/unix as well.
Uh oh!
There was an error while loading. Please reload this page.
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.
I added gc_vxsort_objects for the android host. I could also switch it from static to an object library, but I’m not sure if archive is actually being used in other scenarios.
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.
Do we need both, static and objects, for Android? If not, we can use an if-else block.
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.
BTW: vxsort is a ton of code for relatively small performance gain. We may want to disable it on mobile. It is implemented on x64 only for now, but arm64 implementation is in the works #110692 .
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.
Personally, I'd prefer to switch from static to object library here instead of introducing the conditional object for Android. At least for
gc_pal
andgc_vxsort
, since they are pretty isolated (used for coreclr and standalone gc) and I think the conditional object build makes it more complicated that just switching - as opposed to something likecoreclrminipal
, which would fit better as a separate change per #114629 (review).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.
I agree. I haven’t applied these changes to the other libraries in this PR, since I’m not sure whether they’re required as archives on other platforms.