cargo-xbuild: Build script using std can't compile
I’m trying to use a build.rs file with the cc crate to compile C code as part of a library I’m using in my OS. This doesn’t seem to work when used with cargo-xbuild as the std crate doesn’t exist in the sysroot:
$ env RUST_TARGET_PATH="/home/user/code/rust/0x52a1/polymorphos/splatform/splatform_i686/" cargo xbuild --target=i686-unknown-polymorphos-elf
Compiling libc v0.2.42
Compiling dmm v0.1.0 (file:///home/user/code/rust/0x52a1/polymorphos/dmm)
error[E0463]: can't find crate for `std`=====================> ] 32/38: libc, dmm
|
= note: the `i686-unknown-polymorphos-elf` target may not be installed
error: aborting due to previous error
For more information about this error, try `rustc --explain E0463`.
error: Could not compile `libc`.
warning: build failed, waiting for other jobs to finish...
error: build failed
Is there a way to make the build script compilation use the host’s target and default sysroot (so that the build script can actually do it’s job), and then use the target passed to cargo-xbuild and the newly built sysroot for the compilation of the crate itself?
About this issue
- Original URL
- State: open
- Created 6 years ago
- Comments: 17 (8 by maintainers)
As of nightly 2020-02-23, Cargo should resolve dependencies correctly in this scenario when executed with
-Zfeatures=build_dep. See https://github.com/rust-lang/cargo/issues/5730#issuecomment-590385876 and https://github.com/rust-lang/cargo/issues/7915 for details.Yes, I don’t think there’s a way how
cargo-xbuildcan work around https://github.com/rust-lang/cargo/issues/5730. Cargo-xbuild is just a wrapper that builds the sysroot before invoking cargo build. Changing the fundamental dependency resolution of cargo is not possible for this project.