Working on Stanford’s CS140e on my free-time I’m running into some issues compiling my kernel for the first time. Many of the issues seem to be related to changes in the Rust nightly compiler since the class was first created.
This project aims to create a #[no_std] freestanding binary (a kernel, in this case).
To build our kernel we cd into the kernel directory and run make, which at first gives me a number of warnings related to a few unused symbols in the pi directory because I haven’t implemented those drivers yet. Here’s the error I get:
➜ kernel git:(master) ✗ make
+ Building target/aarch64-none-elf/release/libkernel.a [xargo --release]
warning: `panic` setting is ignored for `test` profile
Compiling kernel v0.1.0 (file:///home/isaak/Documents/code/cs140e/os/kernel)
error[E0463]: can't find crate for `panic_abort`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0463`.
error: Could not compile `kernel`.
To learn more, run the command again with --verbose.
Makefile:38: recipe for target 'target/aarch64-none-elf/release/libkernel.a' failed
make: *** [target/aarch64-none-elf/release/libkernel.a] Error 101
There’s no reference to a panic_abort crate anywhere in the codebase outside of the Cargo.toml configs that set panic = "abort" to disable the generation of unwinding symbol information. This is nice as it’s supposed to decrease the size of the binary and compile time.
I’m not sure what I’m missing here and any pointers would be helpful. Thanks for reading!
Yikes, I’d just sat back down to look at this and was going down the path of copying over libpanic_abort from Rust’s official repo but eventually ran into this error:
error: failed to load bc of "panic_abort.clvndode-cgu.1"
Having now idea what that meant I came here to ask about it and I saw just saw your post!
The panic-abort was not in my dependencies section and it did in fact help! Thanks for your simple suggestion - I should have thought of it myself. However, I did have to make a few changes to that crate to get it working as I originally intended my panic_implementation language item to. Namely I had to change the #[panic_handler] to #[panic_implementation] and also indicate that the crate was a runtime implementation of panics with #![panic_runtime] - both supported features. Now my kernel finally compiles.
Though, the weird thing is, why was the panic_abort crate being sought out in the first place? I already had a lang item written in kernel/src/lang_items.rs of a custom panic implementation that I had to comment out s.t. there wasn’t a duplicate.
Kinda weird that you had to change it to #[panic_implementation], since iirc that attribute was deprecated in favor of #[panic_handler] and that’s what’s going to be stable as of the next version of Rust.
Yes, that’s what I thought too which was why I was confused. I’m leaving this as a mystery for now for the sake of moving on with my main project but I should at least post the version of xargo and rustc I’m using: