Skip to content

cargo builder can't detect bootloader when it is declared as a target-dependent dependency #189

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

Closed
PatchMixolydic opened this issue Jul 31, 2021 · 2 comments

Comments

@PatchMixolydic
Copy link

PatchMixolydic commented Jul 31, 2021

While trying to migrate an old project to bootloader 0.10, I ran the following command:

<cargo registry>/bootloader-0.10.6 $ cargo builder --kernel-manifest <correct path>/Cargo.toml --kernel-binary <correct path>/target/x86_64-unknown-spinel_kernel/debug/spinel

which resulted in this error:

   Compiling bootloader v0.10.6 (/home/patchmixolydic/.cargo/registry/src/github.com-1ecc6299db9ec823/bootloader-0.10.6)
error: no bootloader dependency in /home/patchmixolydic/Programming/Rust/Spinel/Cargo.toml

  The `--kernel-manifest` path should point to the `Cargo.toml` of the kernel.
 --> /home/patchmixolydic/.cargo/registry/src/github.com-1ecc6299db9ec823/bootloader-0.10.6/target/x86_64-unknown-uefi/release/build/bootloader-b9ead764961ec1c9/out/bootloader_config.rs:1:81
  |
1 | ... = compile_error ! ("no bootloader dependency in /home/patchmixolydic/Programming/Rust/Spinel/Cargo.toml\n\n  The `--kernel-manifest` path should point to the `Cargo.toml` of the kernel.") ...
  |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This is strange since my kernel does have a bootloader dependency. The source of this error is this check, which looks for the dependency in the [dependencies] section:

bootloader/build.rs

Lines 243 to 246 in c09f94f

if manifest
.get("dependencies")
.and_then(|d| d.get("bootloader"))
.is_some()

Normally this would work, but this misses the case where bootloader is a target-dependent dependency. Indeed, that's exactly what my project's Cargo.toml does:

[target.'cfg(target_arch = "x86_64")'.dependencies]
bootloader = "0.10.6"
x86_64 = "0.14.4"

Ideally, this would be supported to allow for multi-platform kernels.

PatchMixolydic added a commit to PatchMixolydic/spinel that referenced this issue Jul 31, 2021
Now `cargo build` can be used! (`cargo run` needs fixes for the new
`bootloader` build process, see rust-osdev/bootloader#189)
@PatchMixolydic PatchMixolydic changed the title `cargo builder doesn't work when bootloader is declared as a target-dependent dependency cargo builder doesn't work when bootloader is declared as a target-dependent dependency Jul 31, 2021
@PatchMixolydic PatchMixolydic changed the title cargo builder doesn't work when bootloader is declared as a target-dependent dependency cargo builder can't detect bootloader when it is declared as a target-dependent dependency Jul 31, 2021
@yusdacra
Copy link
Contributor

I also faced this issue before (see #181), #182 fixes it for me.

@PatchMixolydic
Copy link
Author

My mistake 😅
Closing as a duplicate of #181

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