The new `per-package-target` feature does not work with `-Zbuild-std`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 15.5k
- Forks
- 3k
- Avg merge
- 23h 30m
- Merged PRs (30d)
- 51
Description
Problem
I just tried to use the new per-package-target feature implemented in https://github.com/rust-lang/cargo/pull/9030 (tracking issue) together with -Zbuild-std, but it results in an error: -Zbuild-std requires --target.
Steps
- Add a
default-targetorforced-targetkey 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: https://github.com/rust-lang/cargo/blob/db741ac733f3744c2d7ee593d5a01b18e6158b69/src/cargo/ops/cargo_compile.rs#L394-L399
But the default-target/forced-target fields are only considered later in generate_targets: https://github.com/rust-lang/cargo/blob/db741ac733f3744c2d7ee593d5a01b18e6158b69/src/cargo/ops/cargo_compile.rs#L925-L943
The generate_targets function is invoked here: https://github.com/rust-lang/cargo/blob/db741ac733f3744c2d7ee593d5a01b18e6158b69/src/cargo/ops/cargo_compile.rs#L470-L488
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/cargo/ops/cargo_compile.rs, comparing the early -Zbuild-std target check with the later generate_targets handling of default-target and forced-target. Reproduce the issue with Cargo.toml containing one of those keys and cargo build -Zbuild-std=core. Done means the command no longer reports that -Zbuild-std requires --target when the per-package target configuration supplies the target.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100