Repository navigation
Description
A large binary size regression appeared between nightly-2026-10-22 and nightly-2026-10-23 on the MSP430 target, increasing binary size by ~40%, from 23KiB to 33KiB. It persists on the latest nightly-2026-10-29 toolchain.
While running CI for the msp430-hal project, I noticed some examples suddenly failing to link due to insufficient space on the target device. For example, building spi_nb.rs:
cd device_examples/msp430fr2355
cargo +nightly-2026-10-22 build --example spi_nb
Analyzing the generated binary shows it's about 23KiB:
$ msp430-elf-size -A target/msp430-none-elf/debug/examples/spi_nb
target/msp430-none-elf/debug/examples/spi_nb :
section size addr
.defmt 3 1
.vector_table 92 65444
.text 9530 32768
.rodata 14100 42300
.bss 2 8192
.data 0 8194
But the same example built with cargo +nightly-2026-10-23 build --example spi_nb produces a binary that's too large to fit in program memory: region 'ROM' overflowed by 548 bytes.
If we modify the memory.x file to pretend to have more space than we actually do, we can see the generated binary would have been about 33KiB:
$ msp430-elf-size -A target/msp430-none-elf/debug/examples/spi_nb
target/msp430-none-elf/debug/examples/spi_nb :
section size addr
.defmt 3 1
.vector_table 92 65444
.text 15590 12288 <--- significantly bigger
.rodata 17596 27880 <--- bigger
.bss 2 8192
.data 0 8194
Removing the possibly fallible .unwrap()s on lines 52 and 58 makes the regression disappear (also reducing the binary size to practically nothing), so I presume this is related to unwrapping an Err variant, and string parsing during a panic.
If you want to replicate this, you will need to download the msp430-hal repo, install the MSP430-GCC toolchain, then the rust toolchains (and rust-src):
rustup install nightly-2026-10-22
rustup component add rust-src --toolchain nightly-2026-10-22-x86_64-unknown-linux-gnu
rustup install nightly-2026-10-23
rustup component add rust-src --toolchain nightly-2026-10-23-x86_64-unknown-linux-gnu
You can then cd into the device_examples/msp430fr2355 folder and build the examples.
Activity
maxdexh commentedon Oct 30, 2026
Do we not have target maintainers for this tier 3 target?
Edit: I suppose not #113739 (comment)
folkertdev commentedon Oct 30, 2026
Something changed in how
Debugimplementations are generated, I think that is the underlying cause. This is not platform-specific, e.g. here it's quite obvious for x86_64 https://godbolt.org/z/z8rTKe6j6.Using "link to binary", the total output size jumps from ~1000 to ~2600 lines. The new output includes
CharSearcher,slice_error_fail_rt, and a whole bunch of unicode/char logic. Based on the commit range and the problem I suspect #162535 is the cause.Jules-Bertholet commentedon Oct 30, 2026
My guess is the
.split(' ')call. We really need a version of that specialized for ASCII…Jules-Bertholet commentedon Oct 30, 2026
@RossPorter506 can you check whether #165195 resolves the issue?
panstromek commentedon Oct 30, 2026
We have
split_ascii_whitespaceat least. I'm doing some experiments with it in #165179panstromek commentedon Oct 30, 2026
For context, apart from #162535, #164726 landed yesterday, it does the same thing for structs.
[edit] #165140 should fix all the issues now (contains fixes from #165195 and two more changes that came up from the following discussions)
Jules-Bertholet commentedon Nov 2, 2026
Should be fixed by #165140
panstromek commentedon Nov 2, 2026
One thing that I find concerning is that there was pretty much no indication that this might be a problem, neither from our test suite, nor from our benchmarks - some even show binary size improvements.
If the interpretation of this issue is that we should never regress this, which I think is reasonable, then that has some significant implications - notably, that we should never use some fairly basic string manipulation primitives in some parts of the core (and maybe we should clarify which parts), and we somehow need to ensure that going forward.
I will mark this as "needs-test" for now. I'm not exactly sure what to do, but I think we can start by adding the spi_nb.rs example from above as benchmark.
@rustbot label +E-needs-test
maxdexh commentedon Nov 2, 2026
We could just test the final binary size, like here: https://github.com/rust-lang/rust/blob/main/tests/run-make/wasm-panic-small/rmake.rs
Otherwise we'd need function coloring to make sure that we don't accidentally call certain functions from certain other functions ^^
Jules-Bertholet commentedon Nov 2, 2026
Long-term, we should have
.split()acceptascii::Char, and a lint that checks for use ofcharwhereascii::Charwould dopanstromek commentedon Nov 2, 2026
That would certainly be nice, but the problem is not only
split, but also just string indexing, which is even more basic.[edit] ..and something somebody might want to use to improve
unwraperror message in the future, for example.RossPorter506 commentedon Nov 3, 2026
Thanks for the quick responses and action! I've tested with
nightly-2026-11-02and the vast majority of the bloat has disappeared. The .rodata segment grew a bit from 14100 -> 14726 when compared tonightly-2026-10-23, but I'm content to write that off as the cost of progress. This is resolved from my side, though I will leave this issue open since there's still discussion about adding testing.Built with
nightly-2026-11-02:panstromek commentedon Nov 17, 2026
That makes sense, I think we can take the Folkert's reproducer and add it as a this kind of test, it reproduces the problem pretty clearly and doesn't have any dependencies.
If somebody wants to pick it up, feel free to do so, I'll add a label ;) I can do it later when I get through the backlog of other tasks.