Skip to content

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

@PatchMixolydic

Description

@PatchMixolydic

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions