Skip to content
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

Strip AOT shared libraries when packaging #6840

Closed
grendello opened this issue Mar 17, 2022 · 3 comments · Fixed by #6842
Closed

Strip AOT shared libraries when packaging #6840

grendello opened this issue Mar 17, 2022 · 3 comments · Fixed by #6842
Assignees
Labels
Area: App+Library Build Issues when building Library projects or Application projects.

Comments

@grendello
Copy link
Contributor

grendello commented Mar 17, 2022

#6683 introduced LLVM-based toolchain and it appears that the debug data generated during build is much bigger than before.
We should probably strip AOT (and perhaps other) .so libraries on packaging time.

@grendello grendello added Area: App+Library Build Issues when building Library projects or Application projects. needs-triage Issues that need to be assigned. labels Mar 17, 2022
@grendello
Copy link
Contributor Author

grendello commented Mar 17, 2022

Alternatively, we can pass -S or -s via the LdFlags property of the AotCompiler task (-s strips all the debug symbols and saves around 30%, -S strips just the debug info and saves around 10%)

@jonathanpeppers
Copy link
Member

jonathanpeppers commented Mar 17, 2022

@grendello
Copy link
Contributor Author

It appears it only affects framework libs? I think adding -s to LdFlags would be faster - we'd save running strip X times

@grendello grendello removed the needs-triage Issues that need to be assigned. label Mar 17, 2022
grendello added a commit to grendello/xamarin-android that referenced this issue Mar 17, 2022
Fixes: dotnet#6840
Context: dotnet#6683

Pass the `-s` flag to the native linker in order to produce shared
AOT libraries without debug symbols.  This is controlled by a new
msbuild property `$(AndroidStripAotLibraries)`, which defaults to
`true`
grendello added a commit to grendello/xamarin-android that referenced this issue Mar 17, 2022
Fixes: dotnet#6840
Context: dotnet#6683

Pass the `-s` flag to the native linker in order to produce shared
AOT libraries without debug symbols.  This is controlled by a new
msbuild property `$(AndroidStripAotLibraries)`, which defaults to
`true`
grendello added a commit to grendello/xamarin-android that referenced this issue Mar 17, 2022
Fixes: dotnet#6840
Context: dotnet#6683

Pass the `-s` flag to the native linker in order to produce shared
AOT libraries without debug symbols.  Symbols are stripped unless
the `$(DebugSymbols)` property is set to `True`.
jonpryor pushed a commit that referenced this issue Mar 17, 2022
Context: fd5f31c
Context: #6685
Context: https://github.com/xamarin/xamarin-android-binutils
Context: dotnet/android-native-tools@6d4e3bb
Context: #6840

Changes: dotnet/android-native-tools@2.35.2-XA.1...L_13.0.1-4.0.1

So far, Xamarin.Android has been using a GNU Binutils toolchain to
compile and link native assembler code we generate during application
build.  Unfortunately, Binutils have a problem with certain filename
encodings on Windows -- which required that we downgrade to Binutils
2.35.2 in commit fd5f31c -- so we decided to switch to an LLVM-based
toolchain which handles such file names without issues.

However, as mono/mono & dotnet/runtime AOT expects a
GNU Binutils-compatible toolchain, it was necessary to implement a
GNU Assembler (`gas`) wrapper around the LLVM `llvm-mc` assembler, so
that command lines used by the Mono AOT compiler keep working fine.

Since LLVM utilities are multi-target by default and, unlike GNU
Binutils, LLVM doesn't need separate builds of every utility, we now
provide GNU Binutils architecture-prefixed wrapper scripts which
invoke their LLVM counterparts with appropriate parameters.

The following LLVM utilities are included:

  - `llvm-mc` (assembler)
  - `lld` (linker)
  - `llvm-strip`

Migrating to LLVM from GNU Binutils increases our install size:

  * macOS `.pkg` size increases by ~29MB,
    installation size increases by ~75MB.
  * Windows `.vsix` size increases by ~14MB,
    installation size increases by ~40MB.

Aside: We've updated our unit tests to set
`$(_DisableParallelAot)`=True, because when AOT is done in parallel,
it's very difficult to make sense of the AOT compiler messages, as
messages from multiple processes are all intermixed.  We're disabling
parallel AOT to preserve our sanity when things break.

TODO: the Resulting `.apk` sizes also increase unexpectedly, with
`Xamarin.Forms_Performance_Integration-Signed-Release-Profiled-Aot.apkdesc`
showing a 1.7MB increase in `.apk` size.  We believe that this is
because of more verbose debug symbols.
#6840 will track this.
grendello added a commit to grendello/xamarin-android that referenced this issue Mar 17, 2022
Fixes: dotnet#6840
Context: dotnet#6683

Pass the `-s` flag to the native linker in order to produce shared
AOT libraries without debug symbols.  Symbols are stripped unless
the `$(DebugSymbols)` property is set to `True`.
jonpryor pushed a commit that referenced this issue Mar 22, 2022
Fixes: #6840

Context: b21cbf9

Commit b21cbf9 contained a TODO:

> TODO: the Resulting `.apk` sizes also increase[d] unexpectedly, with
> `Xamarin.Forms_Performance_Integration-Signed-Release-Profiled-Aot.apkdesc`
> showing a 1.7MB increase in `.apk` size.  We believe that this is
> because of more verbose debug symbols.
> #6840 will track this.

Update the `<GetAotArguments/>` MSBuild task to add the `-s` linker
flag to `GetAotArguments.LdFlags`.  This will cause the native linker
to produce shared AOT libraries without debug symbols.

Debug symbols are stripped unless the `$(DebugSymbols)`=True.

This fixes the size regression in
`Xamarin.Forms_Performance_Integration-Signed-Release-Profiled-Aot.apkdesc`,
shrinking PackageSize from 19,475,110 down to 16,061,636.
Compare to the pre-b21cbf94 PackageSize of 17,713,830: we're now
1.6MB *smaller* than b21cbf9!
@ghost ghost locked as resolved and limited conversation to collaborators Jun 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Area: App+Library Build Issues when building Library projects or Application projects.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants