Skip to content

"hello world" binary size increase in each release #75804

Closed
@tesuji

Description

@tesuji

The binary size of "hello world" program increased in each release:
image
image

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

No one assigned

    Labels

    C-bugCategory: This is a bug.I-heavyIssue: Problems and improvements with respect to binary size of generated code.ICEBreaker-Cleanup-CrewHelping to "clean up" bugs with minimal examples and bisectionsP-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions