Description
It's unclear if this should be a bug report for Rust's bootstrap or not, but it feels like it's appropriate if only for tracking the problem for when others run into the same. I think closing this is also reasonable.
When RUSTFLAGS_BOOTSTRAP
/RUSTFLAGS_NOT_BOOSTRAP
is passed to to x.py
(gets picked up here), those variables are forwarded as RUSTFLAGS
here:
Line 1856 in c5c610a
This works most of the time. However, there is a known bug in Cargo (rust-lang/cargo#5754 / rust-lang/cargo#4423) that makes it so that if --target
is passed to a cargo
invocation, even if the passed triple is the same as the host triple, RUSTFLAGS
is not passed to build scripts. And since bootstrap always passes --target
, RUSTFLAGS_*_BOOTSTRAP
do not take effect for builds scripts:
Line 1001 in c5c610a
This is problematic when RUSTFLAGS
includes arguments that are critical to building, most notably in the form of -Clink-arg
s without which any attempt to link may fail.
There isn't an obvious fix to the problem beyond fixing the upstream problem(s) in Cargo. One possibility is to detect when target == host
in the bootstrap logic and avoid passing --target
to cargo
in that instance. That way build scripts will respect RUSTFLAGS
again, though it may still pose a problem for cross-compiling use-cases, I'm not sure?
Meta
rustc --version --verbose
:
rustc 1.58.1 (db9d1b20b 2022-01-20)
binary: rustc
commit-hash: db9d1b20bba1968c1ec1fc49616d4742c1725b4b
commit-date: 2022-01-20
host: x86_64-unknown-linux-gnu
release: 1.58.1
LLVM version: 13.0.0