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

cargo-apk: Add strip configuration to manifest #356

Merged
merged 26 commits into from
Nov 1, 2022

Conversation

Jake-Shadle
Copy link
Contributor

@Jake-Shadle Jake-Shadle commented Oct 17, 2022

I've been extremely annoyed with the time that cargo-apk adds onto our build for a long time and today was the day that I got annoyed enough to fix it.

This PR adds a configuration field, package.metadata.android.strip that allows users to configure how they want to treat debug symbols after cargo build has finished, but before the .so libraries are appended to the APK.

  • default - This acts the exact same as the current version of cargo-apk, and is the value used if strip is not explicitly set. The .so produced by cargo is simply copied to the apk output directory with no modification.
  • strip - The library copied into the apk output directory is stripped of debug symbols
  • split - The library copied into the apk output directory is stripped of debug symbols, in addition, the debug symbols are copied into the directory as well with the same filename as the library, but a .dwarf extension.

#355 was closed with the suggestion to just use the strip option in cargo, but unfortunately that doesn't work for our use case. We absolutely do want debug symbols, since we upload all debug symbols to our symbol server so that we can either use them for debugging, or most likely, as the source for the debugging information our error/crash reporting system uses to resolve symbolicated stack traces. Using strip to remove debug info is therefore not an option for us, and unfortunately split-debuginfo doesn't actually do anything when targeting android, at least at the moment. That being said I think this option still makes sense once split-debuginfo does work for android, since it keeps the split symbols next to the library they are paired with, which makes it nicer for any tooling that is doing any kind of processing to handle them, as otherwise they would need to look in the regular target dir as well as the apk dir.

This change make our Android release step, which currently produces ~2.4GiB of DWARF debug data, go from a ridiculous +3m30s (surpassing the time it actually takes the code to build!) to a more reasonable (though still not good) +17s to strip debug symbols and write the stripped binaries and other things to the APK.

@MarijnS95
Copy link
Member

But the $HOME is a lie

This is because the value defaults to $HOME (dirs::home_dir()):

https://github.com/rust-windowing/android-ndk-rs/blob/3ed8ecbb87cbe57715e3d0cedbf84b6c6682dfcf/ndk-build/src/ndk.rs#L55

And that was simply repeated in the example.

There are also 2 other changes I made when doing this change since our build broke when testing.

Please don't make drive-by changes: that's terrible for review, bisecting, proper commit/PR titling (:thinking:) and changelog keeping (which is surprisingly also missing here).

@MarijnS95
Copy link
Member

As for the rest of the change (once separated out into logical PRs), can anyone else pick up review? I currently don't have any bandwidth remaining for android-ndk-rs besides figuring the latest clap upgrade breakage.

Copy link
Contributor

@msiglreith msiglreith left a comment

Choose a reason for hiding this comment

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

looks fine to me, an entry in our example manifest is missing

ndk-build/src/apk.rs Outdated Show resolved Hide resolved
cargo-apk/CHANGELOG.md Show resolved Hide resolved
cargo-apk/CHANGELOG.md Outdated Show resolved Hide resolved
ndk-build/src/apk.rs Outdated Show resolved Hide resolved
ndk-build/src/apk.rs Outdated Show resolved Hide resolved
cargo-apk/README.md Outdated Show resolved Hide resolved
ndk-build/src/apk.rs Outdated Show resolved Hide resolved
ndk-build/src/apk.rs Outdated Show resolved Hide resolved
ndk-build/src/apk.rs Outdated Show resolved Hide resolved
ndk-build/src/apk.rs Show resolved Hide resolved
ndk-build/CHANGELOG.md Outdated Show resolved Hide resolved
cargo-apk/README.md Outdated Show resolved Hide resolved
ndk-build/src/apk.rs Outdated Show resolved Hide resolved
Copy link
Member

@MarijnS95 MarijnS95 left a comment

Choose a reason for hiding this comment

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

Looks good besides some wording issues in doc comments and indentation issues in the README. Feel free to document the effect/affect of Rust's strip option on this cargo-apk strip config.

@MarijnS95 MarijnS95 changed the title Add strip option cargo-apk: Add strip option Oct 25, 2022
@MarijnS95 MarijnS95 changed the title cargo-apk: Add strip option cargo-apk: Add strip configuration to manifest Oct 25, 2022
Copy link
Member

@MarijnS95 MarijnS95 left a comment

Choose a reason for hiding this comment

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

Just bike-shedding the wording now :)

ndk-build/src/apk.rs Outdated Show resolved Hide resolved
cargo-apk/README.md Outdated Show resolved Hide resolved
cargo-apk/README.md Outdated Show resolved Hide resolved
cargo-apk/README.md Outdated Show resolved Hide resolved
cargo-apk/README.md Outdated Show resolved Hide resolved
cargo-apk/README.md Outdated Show resolved Hide resolved
cargo-apk/README.md Outdated Show resolved Hide resolved
cargo-apk/README.md Outdated Show resolved Hide resolved
cargo-apk/CHANGELOG.md Outdated Show resolved Hide resolved
Jake-Shadle and others added 10 commits October 28, 2022 17:55
ndk-build/src/cargo.rs Outdated Show resolved Hide resolved
ndk-build/CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Member

@MarijnS95 MarijnS95 left a comment

Choose a reason for hiding this comment

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

Two more nits, and feel free to add back the <> around markdown links, then we're ready to merge!

ndk-build/src/apk.rs Outdated Show resolved Hide resolved
cargo-apk/README.md Outdated Show resolved Hide resolved
Jake-Shadle and others added 2 commits November 1, 2022 16:01
@MarijnS95 MarijnS95 merged commit b135fb1 into rust-mobile:master Nov 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants