-Zhost-config
doesn't apply host.rustflags
to build-script-builds #10206
Closed
Description
opened on Dec 16, 2021
Problem
When using -Zhost-config
to add in rustflags
to apply to the host-only builds, these are still not passed to rustc
when building build-scripts.
Steps
> cargo new foo && cd foo
Created binary (application) `foo` package
> echo 'fn main() { assert!(cfg!(foo)); }' > build.rs
> cargo build -Zhost-config -Ztarget-applies-to-host -Zunstable-options --config 'host.rustflags=["--cfg=foo"]'
Compiling foo v0.1.0 (/tmp/tmp.9cICAJ9mce/foo)
error: failed to run custom build command for `foo v0.1.0 (/tmp/tmp.9cICAJ9mce/foo)`
Caused by:
process didn't exit successfully: `/home/nemo157/.cargo/shared-target/debug/build/foo-ba25a7af077036f3/build-script-build` (exit status: 101)
--- stderr
thread 'main' panicked at 'assertion failed: cfg!(foo)', build.rs:1:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Possible Solution(s)
I believe the issue is around here, this should be still applying the host rustflags to the build-script builds
cargo/src/cargo/core/compiler/build_context/target_info.rs
Lines 614 to 619 in 263b169
Notes
Originally mentioned on the tracking issue; but after more thought I'm fairly confident this is a bug.
Version
cargo 1.59.0-nightly (a359ce160 2021-12-14)
release: 1.59.0-nightly
commit-hash: a359ce16073401f28b84840da85b268aa3d37c88
commit-date: 2021-12-14
host: x86_64-unknown-linux-gnu
libgit2: 1.3.0 (sys:0.13.23 vendored)
libcurl: 7.80.0-DEV (sys:0.4.51+curl-7.80.0 vendored ssl:OpenSSL/1.1.1l)
os: Arch Linux [64-bit]
Activity