rodrimati1992 / const_panic

const panic with formatting
zlib License
6 stars 2 forks source link

error: values of the type `[u8; 32768]` are too big for the current architecture #7

Open cr1901 opened 1 year ago

cr1901 commented 1 year ago

I have a set of crates for embedding metadata about the current build into a microcontroller. I use this crate as a dep to parse semver info at compile time.

My crates should work on 16-bit archs like MSP430 and AVR. Unfortunately, 32768 bytes for a panic message is a little too large :P:

PS C:\msys64\home\William\Projects\rust-embedded\postcard-infomem> cargo +nightly build -p postcard-infomem-examples --target=msp430-none-elf --features=msp430g2553 -Zbuild-std=core
   ...
   Compiling const_panic v0.2.7
   Compiling konst v0.3.4
   ...
error: values of the type `[u8; 32768]` are too big for the current architecture

error: could not compile `const_panic` due to previous error

Is it possible to decrease the initial size down to 32-64 bytes (minimum amount of MSP430 RAM is 128 bytes) for 16-bit archs?

cr1901 commented 1 year ago

Bad news: I cannot seem to actually duplicate this error at all, even with the commit where I initially saw it. So I can't provide a minimized example (I'm sorry!). That being said, I don't know the conditions where that max panic string size will appear in the final binary (even in debug mode).

Perhaps the size still should be lowered for those archs so code where a panic string needs to be created won't exceed the address space?

rodrimati1992 commented 1 year ago

I have created the 16bit_arch_fix branch, which builds the msp430 target successfully, but I don't know if it would run successfully.

cr1901 commented 1 year ago

I don't know if it would run successfully.

FWIW, the largest MSP430 I have has 8-10kB of RAM (10kB if USB buffers aren't used). So I can't test a 16kB buffer (even if I could duplicate the error, which I can't anymore). But hey, it compiles now :P.

The smallest MSP430s I have have 128 bytes of RAM. That's why I recommended such a low number. Surprisingly enough, I've deployed Rust firmware just fine on those (.text size is a bigger problem than .data/.bss size).

By contrast, the smallest ARM microcontroller I've personally seen has 1kB of RAM (LPC810, which they sadly discontinued :(...).

trandersen-ufst commented 4 months ago

I get this error when trying to build the standard library for an AVR on Ubuntu 22.04.