- Notifications
You must be signed in to change notification settings - Fork564
[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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
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 to4e02da2Comparee15ccf6 to9026080Compare4aff532 to0b7bb8cCompare96d8326 to39031e6Compare7cdfb21 to86691d0Comparejonpryor pushed a commit that referenced this pull requestApr 29, 2025
Context:#9938PR#9938 is an attempt to build `libnet-android.Debug.so` and`libnet-android.Release.so` so that CoreCLR is *statically linked* into `libnet-android*.so`. This reduces the number of native librariesthat must be placed into the `.apk`, and allows the `.apk` to besmaller, 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 beresolvable, by requiring `lld --no-undefined` by default. This inturn requires that we ship *copies* of `libc.so` et al, so that *all*symbols needed by `libnet-android*.so` can be resolved, includingthose from the Android NDK.Update `build-tools/xaprepare` to extract required native librariesfrom 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 thelinker code in the future, as well as ensures that we use consistentlinking 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 placedhere in order to make#9938 smaller.
96649e1 to75e6902Compare29ac51a tobfc4af0Compare9327572 to3ba61c3Compare This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
…nts.csCo-authored-by: Manuel de la Pena <mandel@microsoft.com>
Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
Co-authored-by: Jonathan Peppers <jonathan.peppers@microsoft.com>
…ts.csCo-authored-by: Jonathan Peppers <jonathan.peppers@microsoft.com>
…ts.csCo-authored-by: Jonathan Peppers <jonathan.peppers@microsoft.com>
Co-authored-by: Jonathan Peppers <jonathan.peppers@microsoft.com>
…veAssemblyGenerator.csCo-authored-by: Jonathan Peppers <jonathan.peppers@microsoft.com>
…veAssemblyGenerator.csCo-authored-by: Jonathan Peppers <jonathan.peppers@microsoft.com>
7acf14d to36196cbCompareContributorAuthor
grendello commentedJul 15, 2025
/azp run |
| Azure Pipelines successfully started running 1 pipeline(s). |
jonathanpeppers approved these changesJul 16, 2025
jonathanpeppers approved these changesJul 17, 2025
mandel-macaque approved these changesJul 18, 2025
2adcf2a intomain 59 checks passed
Uh oh!
There was an error while loading.Please reload this page.
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
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.
Uh oh!
There was an error while loading.Please reload this page.
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_MonoRuntimeFlavorDirNameand_CLRRuntimeFlavorDirNameproperties to centralize runtime flavor strings, reducing duplication across tools.KnownProperties.cs: Introduced constants for_MonoRuntimeFlavorDirNameand_CLRRuntimeFlavorDirNameto 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.targetsfor CoreCLR runtime, ensuring proper import order in the build process.Microsoft.Android.Sdk.AssemblyResolution.targets: Added_KnownRuntimeNativeLibraryitem group to define shared libraries for the CoreCLR runtime pack.Microsoft.Android.Sdk.BuildOrder.targets: Added_NativeRuntimeLinkingproperty 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.