Closed
Description
The binary size of "hello world" program increased in each release:
Detail table
Rust version | debug | debug - stripped | release | release - stripped |
---|---|---|---|---|
1.32.0 | 2382904 | 199096 | 2375720 | 199016 |
1.40.0 | 2595400 | 215464 | 2588264 | 215384 |
1.41.0 | 2637336 | 215464 | 2629832 | 215384 |
1.42.0 | 2659672 | 211368 | 2652488 | 211288 |
1.43.0 | 2729192 | 223584 | 2722128 | 223504 |
1.44.0 | 2584120 | 248160 | 2579144 | 248080 |
1.45.0 | 2847440 | 244064 | 2842464 | 243984 |
beta | 2848152 | 244064 | 2843168 | 243984 |
nightly | 3210208 | 293200 | 3203712 | 293112 |
main.rs
fn main() {
println!("hello world");
}
Script to reproduce
rustup set profile minimal
rustup toolchain install 1.{40..45}.0 beta nightly
RUST_DBG_FLAGS='-C debuginfo=1 -C panic=abort -C opt-level=0'
RUST_REL_FLAGS='-C debuginfo=0 -C panic=abort -C opt-level=3'
mkdir -p build/debug
mkdir -p build/release
for ver in 1.{40..45}.0 beta nightly; do
bin_dbg=build/debug/main-$ver
bin_rel=build/release/main-$ver
rustc +$ver $RUST_DBG_FLAGS main.rs -o $bin_dbg
echo "-- $ver"
before=$(stat --printf="%s" $bin_dbg)
strip $bin_dbg
after=$(stat --printf="%s" $bin_dbg)
printf " dbg: %d, stripped: %d\n" $before $after
rustc +$ver $RUST_REL_FLAGS main.rs -o $bin_rel
before=$(stat --printf="%s" $bin_rel)
strip $bin_rel
after=$(stat --printf="%s" $bin_rel)
printf " release: %d, stripped: %d\n" $before $after
done
# rustup toolchain uninstall 1.{40..45}.0 beta nightly
Meta
beta:
rustc 1.46.0-beta.5 (cfbc6d4cf 2020-08-21)
binary: rustc
commit-hash: cfbc6d4cf1acbac5c025acf8ed68929caa551df3
commit-date: 2020-08-21
host: x86_64-unknown-linux-gnu
release: 1.46.0-beta.5
LLVM version: 10.0
nightly:
rustc 1.47.0-nightly (de521cbb3 2020-08-21)
binary: rustc
commit-hash: de521cbb303c08febd9fa3755caccd4f3e491ea3
commit-date: 2020-08-21
host: x86_64-unknown-linux-gnu
release: 1.47.0-nightly
LLVM version: 10.0
Metadata
Metadata
Assignees
Labels
Category: This is a bug.Issue: Problems and improvements with respect to binary size of generated code.Helping to "clean up" bugs with minimal examples and bisectionsMedium priorityRelevant to the compiler team, which will review and decide on the PR/issue.Performance or correctness regression from one stable version to another.
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
spastorino commentedon Aug 27, 2020
Assigning
P-medium
as discussed as part of the Prioritization Working Group procedure and removingI-prioritize
.Would be nice to see where (if it's just one PR) this has regressed ...
@rustbot ping cleanup
And also if this affects more complex programs too.
For now considering it as
P-medium
but feel free to re-assign a different priority or comment on the issue explaining why should we prioritize it higher.rustbot commentedon Aug 27, 2020
Hey Cleanup Crew ICE-breakers! This bug has been identified as a good
"Cleanup ICE-breaking candidate". In case it's useful, here are some
instructions for tackling these sorts of bugs. Maybe take a look?
Thanks! <3
cc @AminArria @camelid @chrissimpkins @contrun @DutchGhost @elshize @ethanboxx @h-michael @HallerPatrick @hdhoang @hellow554 @imtsuki @kanru @KarlK90 @LeSeulArtichaut @MAdrianMattocks @matheus-consoli @mental32 @nmccarty @Noah-Kennedy @pard68 @PeytonT @pierreN @Redblueflame @RobbieClarken @RobertoSnap @robjtede @SarthakSingh31 @senden9 @shekohex @sinato @spastorino @turboladen @woshilapin @yerke
tesuji commentedon Aug 27, 2020
I think a high regression in nightly is from #74682 . Not that I think we should revert it, but it is worth investigating
to improve the situation somehow.
eddyp commentedon Feb 15, 2021
I just saw this on Windows (x86_64-pc-windows-msvc) in one of my applications on the upgrade from 1.49 to 1.50 and explored if this issue is known and reported.
I just did a adaptation of the script to run on windows using cygwin (not using WSL as that would pick up Linux's version and I'm interested in Windows for this particular app).
I installed all versions since 1.45 (I didn't force the usage of 1.x.0), cygwin's strip has no effect on the binaries, so kept only one column.
I got these results:
hellow554 commentedon Feb 15, 2021
Can anybody explain why there is a huge drop in current beta? 😊
eddyp commentedon Feb 15, 2021
Also similar results on my application (on x86_64-pc-windows-msvc) which is a parser using pest:
Sizes are as follow:
The Cargo.lock I have has some slightly older versions pinned but I don't think it shouldn't matter as clearly the compiler affects the size.For reference here are the crates my app depends on:L.E.: if older versions of the crates below, only the nightly debug is
576.512
instead of577.024
, but the others are exactly the same:1.46.0
to1.51.0
#86610tesuji commentedon Apr 28, 2024
Closed as this seems to be taken care by https://perf.rust-lang.org/index.html.