-
Notifications
You must be signed in to change notification settings - Fork 554
[CoreCLR] link app native runtime/library statically #9938
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
Conversation
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
e21e634
to
4e02da2
Compare
e15ccf6
to
9026080
Compare
4aff532
to
0b7bb8c
Compare
96d8326
to
39031e6
Compare
7cdfb21
to
86691d0
Compare
jonpryor
pushed a commit
that referenced
this pull request
Apr 29, 2025
Context: #9938 PR #9938 is an attempt to build `libnet-android.Debug.so` and `libnet-android.Release.so` so that CoreCLR is *statically linked* in to `libnet-android*.so`. This reduces the number of native libraries that must be placed into the `.apk`, and allows the `.apk` to be smaller, as the native linker can remove unused code. *Note*: CoreCLR is ***not*** yet statically linked into `libnet-android*.so`. This is *preliminary* work to support that. This iteration of static linking also requires that *all* symbols be resolvable, by requiring `lld --no-undefined` by default. This in turn requires that we ship *copies* of `libc.so` et al, so that *all* symbols needed by `libnet-android*.so` can be resolved, including those from the Android NDK. Update `build-tools/xaprepare` to extract required native libraries from the NDK, and add those to the .NET for Android Workload packs. Update `Xamarin.Android.Build.Tasks.dll` to cleanup and refactor `ld` invocation, so that `libnet-android*.so` is built with `ld --no-undefined`. This makes it easier to maintain and update the linker code in the future, as well as ensures that we use consistent linking flags across the board. Updates the LLVM IR code generator bits, also extracted from #9938, which aren't strictly related to native linking, but they are placed here in order to make #9938 smaller.
96649e1
to
75e6902
Compare
29ac51a
to
bfc4af0
Compare
9327572
to
3ba61c3
Compare
…hodSources.cs Co-authored-by: Copilot <[email protected]>
…nts.cs Co-authored-by: Manuel de la Pena <[email protected]>
Co-authored-by: Manuel de la Pena <[email protected]>
Co-authored-by: Jonathan Peppers <[email protected]>
…ts.cs Co-authored-by: Jonathan Peppers <[email protected]>
…ts.cs Co-authored-by: Jonathan Peppers <[email protected]>
Co-authored-by: Jonathan Peppers <[email protected]>
…veAssemblyGenerator.cs Co-authored-by: Jonathan Peppers <[email protected]>
…veAssemblyGenerator.cs Co-authored-by: Jonathan Peppers <[email protected]>
7acf14d
to
36196cb
Compare
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
jonathanpeppers
approved these changes
Jul 16, 2025
jonathanpeppers
approved these changes
Jul 17, 2025
mandel-macaque
approved these changes
Jul 18, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This pull request introduces several enhancements to streamline runtime flavor management, improve native runtime asset handling, and support additional runtime configurations for Android builds. The changes focus on consolidating runtime flavor properties, extending native runtime asset definitions, and refining build processes for CoreCLR and Mono runtimes.
Runtime Flavor Management:
Configuration.props
: Added_MonoRuntimeFlavorDirName
and_CLRRuntimeFlavorDirName
properties to centralize runtime flavor strings, reducing duplication across tools.KnownProperties.cs
: Introduced constants for_MonoRuntimeFlavorDirName
and_CLRRuntimeFlavorDirName
to ensure consistent property access. [1] [2]Native Runtime Asset Handling:
Microsoft.Android.Runtime.proj
: Updated runtime flavor directory names to use centralized properties and added definitions for multiple native runtime assets, including debug and release variants.Step_Android_SDK_NDK.cs
: Added support for copying redistributable files, including CRT files, CPP ABI files, and Clang architecture-specific files, to ensure proper runtime linking. [1] [2]Build Process Enhancements:
Microsoft.Android.Sdk.After.targets
: IntroducedMicrosoft.Android.Sdk.NativeRuntime.targets
for CoreCLR runtime, ensuring proper import order in the build process.Microsoft.Android.Sdk.AssemblyResolution.targets
: Added_KnownRuntimeNativeLibrary
item group to define shared libraries for the CoreCLR runtime pack.Microsoft.Android.Sdk.BuildOrder.targets
: Added_NativeRuntimeLinking
property and integrated it into the build order for CoreCLR runtime linking. [1] [2]These changes collectively improve runtime management, streamline asset handling, and enhance build configurations for Android applications targeting CoreCLR and Mono runtimes.