Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
strip = true
alone reduces the size by 40MB!I have unfortunately not been able to measure the effect of the other settings, but in my experience they reduce the size drastically on projects that have a lot of dependencies (like this one).
LTO (Link-Time optimizations): This should help out trim code from dependencies that is not used, that can be detected at link time, which I believe there is a lot of. Note: Depending on the project, this might add a substantial amount of time to the release builds, but I have not been able to test it at the time of writing. Any help to get that working to measure the time vs size gains is welcome :)
Optimize for size: As the option implies, it will optimize the binary for size rather than for speed. It is the equivalent of
-02
with some more precautions to make the binary smaller. In rustc 1.18.0+, usingopt-level = s
is a combination of LLVM flags, setting speed optimization to 2 (ending in the same optimizations as opt-level = 2) and size optimization to 1 (2 being aggressive). I generally prefer this than'z'
as it can actually degrade performance.Further paths to reduce the size of the binary would be to trim down those dependencies and cleanup the code with a tool like
cargo-bloat
.Relates to #6