4 ms·
> Specifically, there are two 'weak lang items' that need to be defined. Lang items are not yet stable. What two specific items? By "lang item" here, do you m
by JoshTriplett 11y ago
> Specifically, there are two 'weak lang items' that need to be defined. Lang items are not yet stable.
What two specific items? By "lang item" here, do you mean roughly "symbol", or something else entirely?
- brson 11y ago'lang item' does roughly mean symbol, but they have their own Rust syntax to communicate their existence to the compiler. Lang items are special functions / types that can only be defined once globally, must be defined for certain features to work. They are how the standard library hooks into the Rust language for a variety of purposes, and to a large extent what makes it possible for Rust to define much of its functionality in libraries instead of in the language. The two lang items that are absolutely required but not defined in core are 'eh_personality' and 'panic_fmt'. Read more here: http://doc.rust-lang.org/nightly/book/no-stdlib.html http://doc.rust-lang.org/nightly/book/no-stdlib.html
- 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.
- deleted 11y ago[deleted]