Error when compiling using bootimage
wwestlake opened this issue · 5 comments
I have installed the nightly build, xbuild, and bootimage and checked that the versions all seem correct. Everything works up to the point of creating an image, the project even builds with cargo xbuild --target...but when I run bootimage build --target ... I get this error, here is the backtrace:
wwestlake@kali:~/Projects/rust/os-dev$ RUST_BACKTRACE=1 bootimage build --target x86_64-hacker-os.json
thread 'main' panicked at 'Could not read crate name from cargo metadata', src/libcore/option.rs:1038:5
stack backtrace:
0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
1: std::sys_common::backtrace::_print
at src/libstd/sys_common/backtrace.rs:70
2: std::panicking::default_hook::{{closure}}
at src/libstd/sys_common/backtrace.rs:58
at src/libstd/panicking.rs:200
3: std::panicking::default_hook
at src/libstd/panicking.rs:215
4: std::panicking::rust_panic_with_hook
at src/libstd/panicking.rs:478
5: std::panicking::continue_panic_fmt
at src/libstd/panicking.rs:385
6: rust_begin_unwind
at src/libstd/panicking.rs:312
7: core::panicking::panic_fmt
at src/libcore/panicking.rs:85
8: core::option::expect_failed
at src/libcore/option.rs:1038
9: bootimage::build::build_impl
10: bootimage::build::build
11: bootimage::main
12: std::rt::lang_start::{{closure}}
13: std::panicking::try::do_call
at src/libstd/rt.rs:49
at src/libstd/panicking.rs:297
14: __rust_maybe_catch_panic
at src/libpanic_unwind/lib.rs:92
15: std::rt::lang_start_internal
at src/libstd/panicking.rs:276
at src/libstd/panic.rs:388
at src/libstd/rt.rs:48
16: main
17: __libc_start_main
18: _start
Thank you for the code example, it was really helpful!
The problem was that bootimage defaulted to the workspace root if no --manifest-path
was passed. I published a new version (0.6.0) that defaults to the current directory instead.
Perfect, thanks for testing! There is still a bug with bootimage test
on Windows, but it should be fixed tomorrow.
I'm not sure if I understand your question correctly. If the other crates are dependencies of your OS, cargo should build them automatically with your OS. If you want to invoke bootimage
from the workspace root, you can still do this: bootimage
(and also cargo xbuild
and cargo build
) support a --manifest-path
argument to specify which project to build. To build your OS crate from the workspace root, run bootimage build --manifest-path hacker-os/Cargo.toml
.
Wow, that's a lot of experience! Let me know if something in the book is unclear. Thanks again for the bug report!