3 ms·
$ cargo new example --bin $ cd example $ cat > src/main.rs #![no_std] fn main() {} ^D $ multirust run stable cargo run Compiling example v0.1
by steveklabnik 11y ago
$ cargo new example --bin
$ cd example
$ cat > src/main.rs
#![no_std]
fn main() {}
^D
$ multirust run stable cargo run
Compiling example v0.1.0 (file:///home/steve/tmp/example)
error: language item required, but not found: `panic_fmt`
error: language item required, but not found: `eh_personality`
error: aborting due to 2 previous errors
Could not compile `example`.
In general a "lang item" is some portion of Rust that the language expects to be defined in some manner. They must all be defined for compiling to work. `libcore` defines many of these language items, but does not for these last two. `libstd` does.
You can provide your own:
#[lang = "eh_personality"]
extern "C" fn eh_personality() {
}
#[lang = "panic_fmt"]
fn panic_fmt() -> ! {
loop {}
}
These are enough to get going, but actually using `#[lang]` requires a `#![feature]`, which requires nightly.
You also end up needing #[start], which is also behind a feature gate. The documentation brson linked you to contains an example no_std executable.