Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Where does the dependency on bootloader have to be placed? #58

Closed
jschwe opened this issue May 19, 2020 · 2 comments
Closed

Where does the dependency on bootloader have to be placed? #58

jschwe opened this issue May 19, 2020 · 2 comments

Comments

@jschwe
Copy link

jschwe commented May 19, 2020

I'm currently trying to build rusty-hermit with bootimage in order to use your bootloader and custom test framework. However I can't seem to figure out where to place the dependency for bootloader.
In rusty-hermit the library containing the kernel libhermit-rs is built via a build script, since the application and the kernel are built with different targets. The library is then linked with the application.

Where exactly does bootimage expect the bootloader dependency? The Top level Cargo.toml is just a workspace, which also leads to WARNING: There is no root package to read the cargo-xbuild config from.
Also do I need to modify the build script to use cargo-xbuild ? I'm not sure if I'm doing something wrong in that regard but it doesn't seem to make a difference whether I use xbuild or build in the build script for the kernel. In both cases I have to pass "-Z build-std=core,alloc"

I tried:

  • putting bootloader = "0.9.2" in every single Cargo.toml file (except for the workspace one). For the 2015 edition crates I also added extern crate bootloader; to the lib.rs file. I ran cargo bootimage --target x86_64-unknown-hermit -Z build-std=std,core,alloc,panic_abort
Error

Created bootimage for `rusty_demo` at `/home/xxx/Dev/rusty-hermit/target/x86_64-unknown-hermit/debug/bootimage-rusty_demo.bin`
Error: An error occured while trying to build the bootloader: Bootloader dependency not found

You need to add a dependency on a crate named `bootloader` in your Cargo.toml.

Caused by:
    Bootloader dependency not found
    
    You need to add a dependency on a crate named `bootloader` in your Cargo.toml.

  • I also tried building the bootloader as described in the bootloader README with ~/Dev/rusty-hermit$ KERNEL=target/x86_64-unknown-hermit/debug/rusty_demo KERNEL_MANIFEST=libhermit-rs/Cargo.toml cargo xbuild --release --features binary --target x86_64-unknown-hermit-kernel. Here rusty_demo is the Kernel linked together with a demo application. The error is error: --features is not allowed in the root of a virtual workspace.
  • Running that command in the demo directory: error: Package `rusty_demo v0.1.0 (/home/xxx/Dev/rusty-hermit/demo)` does not have these features: `binary` .

Do you have any ideas / hints on what I could do or look at to get this running?

@phil-opp
Copy link
Member

The bootloader dependency needs to be in the Cargo.toml of the executable, so for example in demo/Cargo.toml if you want to build the rusty_demo executable.

The problem you are seeing occurs because cargo build builds all binaries in the project by default. In this situation, bootimage tries to also create bootable disk images for all built binaries, but some of the binaries have no bootimage dependency. (In the error message you posted, you see that bootimage successfully created the bootable disk image for the rusty_demo binary but failed afterwards when it tried to created the bootable disk image for the next binary. We should definitely improve the error message to make this more clear.)

To fix this problem, either add a bootimage dependency to all your binaries in the workspace if you want to build them all with bootimage. Alternatively, try building from the subdirectory of an executable or specifying a single executable to build by passing e.g. --bin rusty_demo.

@jschwe
Copy link
Author

jschwe commented May 19, 2020

Thanks a lot, that was very helpful!

@jschwe jschwe closed this as completed May 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants