[package]
name = "hello-world"
version = "0.1.0"
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
crate-type = ["cdylib"]
[profile.dev]
panic = "abort"
[profile.release]
panic = "abort"
[dependencies]
src/lib.rs
#![no_std]
use core::panic::PanicInfo;
/// This function is called on panic.
#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
loop {}
}
fn main() {}
error: language item required, but not found: eh_personality
There are a couple of things in your code that come across as odd, so you might need to elaborate on where/how this code is meant to be used.
The cdylib crate type is used when you want to create a shared library that exposes a C API that can be used from other languages, yet you've also defined a main function which is normally used as the entrypoint for an executable
The program defines a main function, yet is #![no_std]. This means you want your code to run without using the operating system (typically on WebAssembly or bare metal devices without an OS), but when you are running without an OS the main function won't be used as your program's entry point (see the blog post linked earlier for more)
In what way doesn't it work? You should use profile.debug not profile.dev, the dev profile is not a standard Cargo thing but is specific to that blog. [edit: this is wrong, I was mistaken about how Cargo works! you should indeed use profile.dev and profile.release]
That's strange, with the Cargo.toml and lib.rs in your post I can compile successfully (you should never have fn main in lib.rs btw). Try running cargo clean and then building again? Or if that doesn't work, what version of rustc are you on?
Here is a repo where I've copied the Cargo.toml and lib.rs in your post. If I clone this and then cargo +1.55.0 build (disclaimer, I'm on x86_64-unknown-linux-gnu), I get no errors. What happens if you do that? If you can build that repo successfully, could you try running diff -q -x '*target*' eh-personality-error/ your-project/ and see if any differences are reported?