Skip to content

Conversation

@grendello
Copy link
Contributor

@grendello grendello commented Aug 26, 2025

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 with
the NDK. The reason for this was a desire to start using std::format, which provides
a 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:

  • it removes 3 exception handling sections from the runtimes
    (eh_frame, eh_frame_hdr and .gcc_except_table) saving us around 120k
  • it adds an option to strip all native libraries when packaging the application.

By 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 AndroidStripNativeLibraries boolean MSBuild property, with a default
value of false which, if set to true, will cause all the native shared libraries
to be stripped of debug symbols at packaging time.

@grendello grendello force-pushed the dev/grendel/cpp-no-exceptions-mono branch from e3aa1be to d371eb7 Compare August 27, 2025 09:51
@grendello grendello changed the title Just testing if stuff still works [native] Make native runtime smaller and allow optional .so stripping Aug 27, 2025
@grendello grendello force-pushed the dev/grendel/cpp-no-exceptions-mono branch from d371eb7 to ad46dff Compare August 27, 2025 16:32
@grendello
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

The `-g0` option is probably going to go away, but let's see how it
goes with those changes. Things appear to work locally.
Even though CoreCLR itself uses C++ exceptions, our runtime doesn't.
We don't need these sections and removing them won't affect CoreCLR,
so let's just get rid of them.
@grendello grendello force-pushed the dev/grendel/cpp-no-exceptions-mono branch from affbadf to b7b9bbd Compare August 28, 2025 09:04
@grendello grendello marked this pull request as ready for review August 28, 2025 09:54
Copy link
Member

@jonathanpeppers jonathanpeppers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reran some of the failed test lanes.

@grendello grendello enabled auto-merge (squash) August 28, 2025 14:37
@grendello grendello merged commit 58d7c3d into main Aug 28, 2025
59 checks passed
@grendello grendello deleted the dev/grendel/cpp-no-exceptions-mono branch August 28, 2025 15:00
@github-actions github-actions bot locked and limited conversation to collaborators Sep 28, 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