[native] Make native runtime smaller and allow optional .so stripping #10446
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.
Applications built for .NET10 gained some size because of a number of factors. One of
them is our decision earlier this year to start statically linking
libc++shipped withthe NDK. The reason for this was a desire to start using
std::format, which providesa fully type-safe and it parses format strings at the compilation time, making run time
faster. This added around 200k to the runtime.
However, another side effect of that decision is that the ELF sections used by exception
handling got much bigger and since we don't use exceptions, those sections are a ballast
and nothing else.
This PR does two things:
(
eh_frame,eh_frame_hdrand.gcc_except_table) saving us around 120kBy default we produce shared libraries with the symbol table present, to make potential
native crash stack traces easier to read and interpret. This, however, adds around 400k
to our runtime, so it might not be desirable for everybody to keep that baggage around.
Introduce the
AndroidStripNativeLibrariesboolean MSBuild property, with a defaultvalue of
falsewhich, if set totrue, will cause all the native shared librariesto be stripped of debug symbols at packaging time.