-
Notifications
You must be signed in to change notification settings - Fork 12.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
no_std: binary size blowup using Result::unwrap since 1.49.0 #83925
Comments
Bisected this regression to nightly-2020-10-17. |
@rustbot label: +I-heavy +regression-from-stable-to-beta |
@rustbot label: -regression-from-stable-to-beta +regression-from-stable-to-stable |
rust-lang/rust#83925 For now we just remove the one instance of .unwrap() that is used in the bootloader, removing most of the bootloader size increase.
rust-lang/rust#83925 For now we just remove the one instance of .unwrap() that is used in the bootloader, removing most of the bootloader size increase.
rust-lang/rust#83925 For now we just remove the one instance of .unwrap() that is used in the bootloader, removing most of the bootloader size increase.
We have the nighty where this regressed, can we try to go down a specific commit where this happened? @rustbot ping icebreakers-cleanup-crew |
Hey Cleanup Crew ICE-breakers! This bug has been identified as a good cc @AminArria @camelid @chrissimpkins @contrun @DutchGhost @elshize @h-michael @HallerPatrick @hdhoang @hellow554 @henryboisdequin @imtsuki @JamesPatrickGill @kanru @KarlK90 @LeSeulArtichaut @MAdrianMattocks @matheus-consoli @mental32 @nmccarty @Noah-Kennedy @pard68 @PeytonT @pierreN @Redblueflame @RobbieClarken @RobertoSnap @robjtede @SarthakSingh31 @shekohex @sinato @smmalis37 @steffahn @Stupremee @tamuhey @turboladen @woshilapin @yerke |
Assigning priority as discussed as part of the Prioritization Working Group procedure and removing @rustbot label -I-prioritize +P-medium |
Unfortunately the CI artifacts from back then are no longer available (to me, at least); so this would entail manually compiling those specific commits... compiling rustc is very slow for me, but I'll see what I can do.
|
|
This broke due to the change merged at a78a62f which was intended to fix #28728. In particular, it adds a side effect call to empty loops, which would be triggered here. I'm not familiar enough with the behaviour of the compiler to say for certain, but I think the side effect inhibits the compiler from optimising away the associated loop / callers and as a result the symbols are left in the binary. I'm also not quite able to replicate the nightly build with my locally built compiler so there may be some other surprises here. In case some more details would be of use: Here's the LLVM IR I get from 7f58716 (i.e. the last good commit):
Whereas here's what I get from e2efec8 (i.e. the commit that broke this):
Here we see |
It looks like this is the same theory discussed in the Zulip thread. |
For embedded developers finding this issue: if you're using a halt/abort panic handler anyway, building with |
Needed toolchains and targets to run the examples (nightly instead of 1.49.0 also works, 1.49.0 is the first release with the regression):
Code
Compiled with:
I expected the all functions related to panics to be optimized away and the binary size to be relatively small:
Output with toolchain 1.48.0, everything is as expected:
The same output when compiled with 1.49.0:
The binary size blew up by ~10kb. For my embedded program, this increase is too large and for my target and I cannot run the program anymore.
When I inline the code from
unwrap()
and callpanic!()
manually, the binary size reduces against drastically, though the symbols list still has apanic_fmt
entry that is not optimized away since 1.49.0 (previous toolchains produce a minimal binary with no panic-related code in the binary, as expected):Version it worked on
Toolchains below 1.49.0
Version with regression
Toolchains since 1.49.0, including today's nightly.
The text was updated successfully, but these errors were encountered: