Failing to find bootloader dependency when it's conditionally included

Open
#75 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
rust
Domain
build-system

Research direction

Reproduce the failure using the Cargo.toml target-specific dependency and cargo bootimage --target targets/x86_64-unknown-none-softfloat.json --release. Start by tracing how the bootimage command obtains Cargo metadata and locates the bootloader package. Done means the conditional bootloader dependency is found for x86_64 and the image builds without requiring it for other architectures.

Written by the indexing model from the issue text.

Description

I'm writing a kernel that runs on both the Raspberry Pi 3 and x86_64. I'm trying to use bootloader+bootimage exclusively for the x86_64 version, but not any other architecture. As a result, my Cargo.toml looks like this:

[dependencies]
# common, architecture-independent dependencies

[target.'cfg(target_arch = "x86_64")'.dependencies]
bootloader = "^0.9.8"

When I compile this project with cargo bootimage --target targets/x86_64-unknown-none-softfloat.json --release I get this error message:

Error: An error occured while trying to build the bootloader: Could not find required key `packages[name = `bootloader`` in cargo metadata output

However, if I change the bootloader dependency to not be conditional, i.e. if I just put it in the [dependencies] section, the above error goes away and the project boots perfectly.

Is there some extra configuration I need to do to make this work? It would be nice for me to be able to completely exclude the bootloader dependency off of x86.

Dominant language
Rust
Stars
914
Forks
70
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rust-osdev/bootimage

All issues in rust-osdev/bootimage

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.