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

Add option to strip binaries #8191

Closed

Conversation

GabrielMajeri
Copy link
Contributor

I want to help add an option to Cargo to strip symbols from built binaries. Currently this PR just adds a linker flag, as suggested in this comment.

Questions for reviewers:

  • I've tried looking at the existing code to add a new Cargo.toml option, and I've added this to the [profile.*] section. Please tell me if it would be better to move it somewhere else.

  • How do we handle this on non-*NIX/non-ld platforms? I'm guessing we'll need to detect the configured linker for the respective platform.

  • How do we test this? I could add a test for the config option, but a real test would check that the produced binaries are stripped.

If merged, this closes #3483.

@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @ehuss (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 1, 2020
@alexcrichton
Copy link
Member

Thanks for the PR!

This might be best done as a rust-lang/rust PR first which has access to target information to know what flag should be passed to the linker. For example this could be added as -C strip or something like that. We could then add a profile setting for Cargo to configure that on the Cargo side of things afterwards.

@GabrielMajeri
Copy link
Contributor Author

Thanks for the suggestion! I am closing this PR for now and opening rust-lang/rust#71757

bors added a commit that referenced this pull request May 19, 2020
Add option to strip binaries

This PR adds a Cargo option for stripping symbols from generated binaries.

This is based on the `-Z strip` flag for `rustc`, which has been [recently implemented](rust-lang/rust#71757).

Notes for reviewers: I'm not entirely sure how we test this, I've created a crate locally and it seems to be working.

Supersedes my previous work in #8191.
Fixes #3483.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Option for stripping binary
4 participants