-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Option for stripping binary #3483
Comments
I would like to have this as well. See also #4122. |
(ugly) workaround is: RUSTFLAGS='-C link-arg=-s' cargo build --release |
Possible solution is the recently released |
That appears to just call |
@dewyatt I'd suggest opening an issue with |
For the record, I was slightly confused why my release binary had 3 MB of size, and I found debug info inside of my release binary. After |
I'm still having cargo optimize for speed, but have configured the following tweaks: - Enable Link Time Optimization (LTO) - Reduce Parallel Code Generation Units There's no way to have cargo strip the binaries automatically, but using the following command will handle it for you: $ RUSTFLAGS='-C link-arg=-s' cargo build --release Putting these changes into place shouldn't affect the speed or behavior of the released binary, but it does increase the compilation time. For size reference, no optimizations resulted in a binary that was ~4.8M,and after these steps, the binary is ~1.8M (a savings of over 60%). See: - https://github.com/johnthagen/min-sized-rust - rust-lang/cargo#3483
It's now possible (with a nightly compiler) to have the linker strip symbols from the final build by adding a |
To be clear, the Cargo support will land in nightly sometime next week. |
When will this feature to be released in stable channel? It seems that this feature is not included in v1.46.0. @ehuss |
@zonyitoo It will not appear in stable until the feature is stabilized. You can follow the tracking issue at rust-lang/rust#72110 to see when it is stabilized. |
I think it would be helpful to have an option for stripping the binary (probably as default in release mode) because executables often get much smaller.
The text was updated successfully, but these errors were encountered: