-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build scripts are not informed of rustflags or rustc wrapper #9600
Comments
So those would be the target-specific flags, right? (i.e. matching the This would be a real boon to |
Yes, my thinking was that they'd be set based on how Cargo decides to build the build script itself. See also the implementation of this in #9601, which is really quite simple. |
I don't think that's quite the same thing, since the build script runs on the host. But AFAICT the call you added does use the current |
Without this, environments that configure `RUSTFLAGS` or the `RUSTC_WRAPPER` in ways that break compilation with `backtrace` will fail to compile anyhow (see dtolnay#156). With this, the compiler probe takes into account that Cargo configuration, and thus (more) accurately represents whether the `backtrace` feature can be safely enabled. Requires rust-lang/cargo#9600. Fixes dtolnay#156.
Inform build scripts of rustc compiler context Fixes #9600.
Describe the problem you are trying to solve
I recently came across a bug in anyhow whose root cause is that it does "test compile" to see whether it can make use of some nightly features, but that test compile does not take into account Cargo configuration like
[build] rustflags =
. Looking through the environment variables Cargo sets for build scripts it doesn't appear that things like the rustc wrapper or the final rustflags is actually passed to the build script. Specifically, this can be seen by runningThen, observe that "wrap", which appears in both
build.rustflags
andbuild.rustc-wrapper
, does not appear in the build output:$ grep wrap build-output.log $
Describe the solution you'd like
The rust compiler is given to the build script in the form of the
RUSTC
environment variable, but that alone is not sufficient for a build script that wants to inspect (or use) the target Rust compilation context. The rustc configuration (the wrapper and RUSTFLAGS) should be passed to the build script as well, likely through two new environment variables:CARGO_RUSTC_WRAPPER
CARGO_RUSTFLAGS
Note that these do not include
_BUILD
to avoid overlap with the environment variables Cargo reads.The text was updated successfully, but these errors were encountered: