]> git.proxmox.com Git - cargo.git/commitdiff
Auto merge of #10395 - jonhoo:fix-10206, r=alexcrichton
authorbors <bors@rust-lang.org>
Mon, 28 Feb 2022 19:29:07 +0000 (19:29 +0000)
committerbors <bors@rust-lang.org>
Mon, 28 Feb 2022 19:29:07 +0000 (19:29 +0000)
Enable propagating host rustflags to build scripts

### What does this PR try to resolve?

This PR primarily fixes #10206, but in doing so it also slightly modifies the interface for the unstable `target-applies-to-host` feature (#9453), and adds the unstable `target-applies-to-host-kind` flag to mirror `target-applies-to-host` for build scripts and other host artifacts.

The commit messages have more in-depth discussion.

### How should we test and review this PR?

The test case from #10206 now works rather than producing an error. It has also been added a regression test case. A few additional test cases have also been added to handle the expected behavior around rustflags for build scripts with and without `target-applies-to-host-kind` enabled.

### Additional information

1. This changes the interface for `target-applies-to-host` so that it does not need to be specified twice to be used. And it can still be set through configuration files using the `[unstable]` table. However, we may(?) want to pick a stable format for in-file configuration of this setting unless we intend for it to only ever be a command-line flag.
2. It may be that `target-applies-to-host-kind` is never behavior we want users to turn on, and that it should therefore simply be removed and hard-coded as being `false`.
3. It's not entirely clear how `target-applies-to-host-kind` should interact with `-Zmultitarget`. If, for example, `requested_kinds = [HostTarget, SomeOtherTarget]` and `kind.is_host()`, should `RUSTFLAGS` take effect or not? For the time being I've just hard-coded the behavior for single targets, and the answer would be "no".

1  2 
src/cargo/core/compiler/build_context/target_info.rs
src/doc/src/reference/unstable.md
tests/testsuite/rustflags.rs

Simple merge
Simple merge