-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Closed
Labels
A-featuresArea: features — conditional compilationArea: features — conditional compilationC-bugCategory: bugCategory: bugS-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.Z-bindepsNightly: binary artifact dependenciesNightly: binary artifact dependencies
Description
Problem
Cargo is incorrectly using the features from build-dependencies rather than dependencies when building the crate, in this case it causes a failure as the build target is no_std.
benpye@Bens-MacBook-Pro bindep_repro % cargo build --manifest-path parent/Cargo.toml --target riscv32im-unknown-none-elf -Zbuild-std=core
Compiling compiler_builtins v0.1.101
Compiling core v0.0.0 (/Users/benpye/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/core)
Compiling parent v0.1.0 (/Users/benpye/git/bindep_repro/parent)
Compiling rustc-std-workspace-core v1.99.0 (/Users/benpye/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/rustc-std-workspace-core)
Compiling common_dep v0.1.0 (/Users/benpye/git/bindep_repro/common_dep)
error[E0463]: can't find crate for `std`
|
= note: the `riscv32im-unknown-none-elf` target may not support the standard library
= note: `std` is required by `common_dep` because it does not declare `#![no_std]`
= help: consider building the standard library from source with `cargo build -Zbuild-std`
For more information about this error, try `rustc --explain E0463`.
error: could not compile `common_dep` (lib) due to previous error
warning: build failed, waiting for other jobs to finish...
Steps
A minimal repro is available at https://github.com/benpye/rust_bugs/tree/bindep_feature_resolution_bug
The issue can be reproduced with
cargo build --manifest-path parent/Cargo.toml --target riscv32im-unknown-none-elf -Zbuild-std=core
The repro is made up of three crates.
- A has an artifact dependency on B with
target = "target", and includes an (empty)build.rsscript. - B has both a regular dependency and build dependency on C, the build dependency enables the
stdfeature on C. - C is
no_stdwhen thestdfeature is not-enabled.
Possible Solution(s)
No response
Notes
- This also occurs when the crates are part of a workspace.
- This seems similar to bindep std errors when no_std bindep has a dependency which uses std in a build.rs #11772 but I needed an additional crate to trigger it.
Version
cargo 1.75.0-nightly (8eb8acbb1 2023-10-17)
release: 1.75.0-nightly
commit-hash: 8eb8acbb116e7923ea2ce33a50109933ed5ab375
commit-date: 2023-10-17
host: aarch64-apple-darwin
libgit2: 1.7.1 (sys:0.18.1 vendored)
libcurl: 8.1.2 (sys:0.4.68+curl-8.4.0 system ssl:(SecureTransport) LibreSSL/3.3.6)
ssl: OpenSSL 1.1.1u 30 May 2023
os: Mac OS 14.0.0 [64-bit]
Metadata
Metadata
Assignees
Labels
A-featuresArea: features — conditional compilationArea: features — conditional compilationC-bugCategory: bugCategory: bugS-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.Z-bindepsNightly: binary artifact dependenciesNightly: binary artifact dependencies