Description
Problem
I just tried to use the new per-package-target
feature implemented in #9030 (tracking issue) together with -Zbuild-std
, but it results in an error: -Zbuild-std requires --target
.
Steps
- Add a
default-target
orforced-target
key inCargo.toml
. - Try to compile by running
cargo build -Zbuild-std=core
.
Possible Solution(s)
I think the issue is that the target check already happens here:
cargo/src/cargo/ops/cargo_compile.rs
Lines 394 to 399 in db741ac
But the default-target
/forced-target
fields are only considered later in generate_targets
:
cargo/src/cargo/ops/cargo_compile.rs
Lines 925 to 943 in db741ac
The generate_targets
function is invoked here:
cargo/src/cargo/ops/cargo_compile.rs
Lines 470 to 488 in db741ac
Notes
Output of cargo version
:
cargo 1.53.0-nightly (4369396ce 2021-04-27)
release: 1.53.0
commit-hash: 4369396ce7d270972955d876eaa4954bea56bcd9
commit-date: 2021-04-27
cc @Ekleog