Skip to content

[native] Common infrastructure for native shared library linking #9990

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 12 commits into from
Apr 29, 2025

Conversation

grendello
Copy link
Contributor

Context: #9938

Code extracted from #9938, which provides one place to run the native linker and specify all the required
flags and options. 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.

Additionally, updates some 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.

@grendello
Copy link
Contributor Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@grendello
Copy link
Contributor Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@grendello grendello force-pushed the dev/grendel/native-compilation branch from 56a838d to b14eb54 Compare April 1, 2025 08:02
@grendello
Copy link
Contributor Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@grendello grendello force-pushed the dev/grendel/native-compilation branch 2 times, most recently from 5efbf29 to 0ac713d Compare April 2, 2025 20:47
@grendello grendello force-pushed the dev/grendel/native-compilation branch from 0ac713d to 7490091 Compare April 9, 2025 18:20
@grendello
Copy link
Contributor Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@grendello
Copy link
Contributor Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@grendello grendello force-pushed the dev/grendel/native-compilation branch from 51cfdc0 to f92503f Compare April 28, 2025 07:47
@jonpryor
Copy link
Contributor

Context: https://github.com/dotnet/android/pull/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.

@jonpryor jonpryor merged commit 8372461 into main Apr 29, 2025
60 checks passed
@jonpryor jonpryor deleted the dev/grendel/native-compilation branch April 29, 2025 11:17
@github-actions github-actions bot locked and limited conversation to collaborators May 30, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants