rust-osdev / cargo-xbuild

Automatically cross-compiles the sysroot crates core, compiler_builtins, and alloc.
Apache License 2.0
256 stars 25 forks source link

error: parsing package.metadata.cargo-xbuild section failed #60

Closed parasyte closed 4 years ago

parasyte commented 4 years ago

I get this new error message (introduced in #57) with no additional way to diagnose the cause.

error: parsing package.metadata.cargo-xbuild section failed
note: run with `RUST_BACKTRACE=1` for a backtrace

Setting RUST_BACKTRACE=1 hides the second line from the error message and produces no backtrace.

This causes my CI to fail. E.g. https://travis-ci.org/rust-console/cargo-n64/builds/650914215

FWIW, the cargo-n64 repo is setup with a workspace manifest, and I do not have a package.metadata.cargo-xbuild section in any of the crate manifests. cargo xbuild is invoked something like this:

cargo xbuild --target=/tmp/mips-nintendo64-none.json --package=hello-ipl3font --release
Where the contents of the target JSON file is: ```json { "arch": "mips", "cpu": "mips3", "data-layout": "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S64", "disable-redzone": true, "env": "unknown", "executables": true, "features": "+mips3,+gp64,+fpxx,+nooddspreg", "linker": "rust-lld", "linker-flavor": "ld.lld", "llvm-target": "mips-unknown-unknown", "os": "none", "panic-strategy": "abort", "pre-link-args": { "ld.lld": [ "--script=/tmp/linker.ld" ] }, "relocation-model": "static", "target-c-int-width": "32", "target-endian": "big", "target-pointer-width": "32", "vendor": "nintendo64" } ```
And the contents of the linker script: ```ld ENTRY(_start) SECTIONS { . = 0x80000400; __boot_start = .; .boot : { *(.boot) } .text : { *(.text .text.*) } .rodata : { *(.rodata .rodata.*) } .data : { *(.data .data.*) } .bss : { . = ALIGN(4); __bss_start = .; *(.bss .bss.*) __bss_end = .; } . = ALIGN(2); __rom_end = . - __boot_start + 0xB0001000; /DISCARD/ : { *(.MIPS.*) *(.comment) *(.mdebug.*) *(.pdr) *(.reginfo) /* * We may need the global offset table some day. * Our target is currently set with a static relocation-model, so this * might not be needed after all. */ *(.got) } } ```
parasyte commented 4 years ago

I've inserted some print statements to help debug, and it is failing here: https://github.com/rust-osdev/cargo-xbuild/blob/8508ef80d9092b980ad65f61361a2d5a971f9aa5/src/config.rs#L27

cc @ascjones

phil-opp commented 4 years ago

Thanks for reporting this! I can reproduce this error with your repository and I'm trying to fix it.

phil-opp commented 4 years ago

I think I found the error. The problem is that your project is using a virtual manifest at the workspace root, which we forgot to handle in the code introduced in #57. I opened #61 to fix this. Unfortunately, we can't load any config for such projects since it's not clear which Cargo.toml should be used for loading the config. For this reason we print a warning and use the default config.

Could you try the code in #61 and test whether this approach works for you? You can install the version through:

cargo install cargo-xbuild --git https://github.com/rust-osdev/cargo-xbuild.git --branch fix-60 --debug --force
parasyte commented 4 years ago

Thanks for the quick turnaround on this. I'll give it a shot and report back.

Side note: I'm also considering pulling cargo-xbuild as a library dependency, instead of calling the binary through the system interface. That will take care of the virtual manifest problem, since the correct manifest can be passed directly.

phil-opp commented 4 years ago

@parasyte Did you try whether it works for you now?

parasyte commented 4 years ago

It works! We also got it integrated as a library. 👍

phil-opp commented 4 years ago

Perfect, thanks for the update!