Change:
This includes on and The former has an incorrect signature on and the latter doesn't mention that you need a annotation. The relationship between and (the former is a lang item, and the latter is a symbol that the former produces) has been confusing people on recently, and should probably be documented as well. For reference, the correct way to define it is: Every part of that signature (except the function name) is necessary; any omission can cause unclear or misleading errors, or lead to the function being called with the wrong ABI.
related:
Sigh, I just ran into this today. Will send a PR tomorrow.
apparently tomorrow never came. I am willing to mentor anyone who wants to add this
It seems is no longer exists So what is preferred way of declaring lang item?
Thanks!

Discussion:
```toml [dependencies] <del> libc = { version = "0.2.11", default-features = false } </del> <ins> libc = { version = "0.2.14", default-features = false } </ins> ``` Note that the default features have been disabled. This is a critical step -

The function marked `#[start]` is passed the command line parameters in the same format as C: <del> ```rust # #![feature(libc)] </del> <ins> ```rust,ignore </ins> #![feature(lang_items)] #![feature(start)] #![no_std]

0 } <del> // These functions and traits are used by the compiler, but not </del> <ins> // These functions are used by the compiler, but not </ins> // for a bare-bones hello world. These are normally // provided by libstd. <del> #[lang = "eh_personality"] extern fn eh_personality() {} #[lang = "panic_fmt"] extern fn panic_fmt() -> ! { loop {} } # #[lang = "eh_unwind_resume"] extern fn rust_eh_unwind_resume() {} # #[no_mangle] pub extern fn rust_eh_register_frames () {} # #[no_mangle] pub extern fn rust_eh_unregister_frames () {} # // fn main() {} tricked you, rustdoc! </del> <ins> #[lang = "eh_personality"] #[no_mangle] pub extern fn eh_personality() { } #[lang = "panic_fmt"] #[no_mangle] pub extern fn rust_begin_panic(_msg: core::fmt::Arguments, _file: &'static str, _line: u32) -> ! { loop {} } </ins> ``` To override the compiler-inserted `main` shim, one has to disable it

correct ABI and the correct name, which requires overriding the compiler's name mangling too: <del> ```rust # #![feature(libc)] </del> <ins> ```rust,ignore </ins> #![feature(lang_items)] #![feature(start)] #![no_std] #![no_main] <ins> // Pull in the system libc library for what crt0.o likely requires </ins> extern crate libc; <ins> // Entry point for this program </ins> #[no_mangle] // ensure that this symbol is called `main` in the output <del> pub extern fn main(argc: i32, argv: *const *const u8) -> i32 { </del> <ins> pub extern fn main(_argc: i32, _argv: *const *const u8) -> i32 { </ins> 0 } <del> #[lang = "eh_personality"] extern fn eh_personality() {} #[lang = "panic_fmt"] extern fn panic_fmt() -> ! { loop {} } # #[lang = "eh_unwind_resume"] extern fn rust_eh_unwind_resume() {} # #[no_mangle] pub extern fn rust_eh_register_frames () {} # #[no_mangle] pub extern fn rust_eh_unregister_frames () {} # // fn main() {} tricked you, rustdoc! </del> <ins> // These functions and traits are used by the compiler, but not // for a bare-bones hello world. These are normally // provided by libstd. #[lang = "eh_personality"] #[no_mangle] pub extern fn eh_personality() { } #[lang = "panic_fmt"] #[no_mangle] pub extern fn rust_begin_panic(_msg: core::fmt::Arguments, _file: &'static str, _line: u32) -> ! { loop {} } </ins> ``` <del> The compiler currently makes a few assumptions about symbols which are available in the executable to call. Normally these functions are provided by the standard library, but without it you must define your own. </del> <ins> ## More about the langauge items The compiler currently makes a few assumptions about symbols which are available in the executable to call. Normally these functions are provided by the standard library, but without it you must define your own. These symbols are called "language items", and they each have an internal name, and then a signature that an implementation must conform to. </ins> The first of these two functions, `eh_personality`, is used by the failure mechanisms of the compiler. This is often mapped to GCC's personality function (see the [libstd implementation][unwind] for more information), but crates which do not trigger a panic can be assured that this function is never <del> called. The second function, `panic_fmt`, is also used by the failure mechanisms of the compiler. </del> <ins> called. Both the language item and the symbol name are `eh_personality`. </ins> [unwind]: https://github.com/rust-lang/rust/blob/master/src/libpanic_unwind/gcc.rs <ins> The second function, `panic_fmt`, is also used by the failure mechanisms of the compiler. When a panic happens, this controls the message that's displayed on the screen. While the language item's name is `panic_fmt`, the symbol name is `rust_begin_panic`. </ins>

//! //! # How to use the core library //! <ins> //! Please note that all of these details are currently not considered stable. //! </ins> // FIXME: Fill me in with more detail when the interface settles //! This library is built on the assumption of a few existing symbols: //!

//!   These functions are often provided by the system libc, but can also be //!   provided by the [rlibc crate](https://crates.io/crates/rlibc). //! <del> //! * `rust_begin_unwind` - This function takes three arguments, a //!   `fmt::Arguments`, a `&str`, and a `u32`. These three arguments dictate //!   the panic message, the file at which panic was invoked, and the line. //!   It is up to consumers of this core library to define this panic //!   function; it is only required to never return. </del> <ins> //! * `rust_begin_panic` - This function takes three arguments, a //!   `fmt::Arguments`, a `&'static str`, and a `u32`. These three arguments //!   dictate the panic message, the file at which panic was invoked, and the //!   line. It is up to consumers of this core library to define this panic //!   function; it is only required to never return. This requires a `lang` //!   attribute named `panic_fmt`. </ins> // Since libcore defines many fundamental lang items, all tests live in a // separate crate, libcoretest, to avoid bizarre issues.