#![no_std] problem

I want to try Rust on STM32 microcontroller. The compiler is rust-1.33 stable. I use #![no_std], and the error:

error: language item required, but not found: eh_personality
error: aborting due to previous error
error: Could not compile blink.

Here is a x86 test code, which writes the same error:

#![no_std]

use core::panic::PanicInfo;
#[panic_handler]
pub fn panic(_panicinfo: &PanicInfo) -> !{
loop {}
}

fn main() {
}

How can I avoid this error?

Put this in Cargo.toml:

[profile.dev]
panic = "abort"

[profile.release]
panic = "abort"

Read about it here A Freestanding Rust Binary | Writing an OS in Rust

1 Like

You may also want to check out The Embedded Book or the older Discovery guide.

Both resources go through the various requirements that a #[no_std] application have and ways they've already been solved by the ecosystem.