Closed hannobraun closed 3 years ago
Thanks -- sorry about the breakage. I've yanked 1.0.44 until someone can send a fix.
No worries! Thank you for addressing this so quickly!
Sorry for the breakage! It seems the heuristic using RUSTFLAGS was not enough.
On lpc-rs/lpc8xx-hal, If rustflags is not set, it will succeed.
cargo +stable test +stable --features 82x,no-target-warning,trybuild --target x86_64-apple-darwin
If rustflags is set, it will fail.
RUSTFLAGS="-D warnings" cargo +stable test --features 82x,no-target-warning,trybuild --target x86_64-apple-darwin
Therefore, it seems that my understanding here was incorrect (not only CARGO_ENCODED_RUSTFLAGS, but also RUSTFLAGS seems to have the same nature):
https://github.com/dtolnay/trybuild/blob/0b33c0b7209bb8791a3923097cc6b230de4e02d3/build.rs#L28-L31
The best way for this seems to be https://github.com/rust-lang/cargo/pull/9532, but it may take quite a while before it is merged.
https://github.com/dtolnay/trybuild/pull/123 is not a perfect approach for this because it cannot detect automatically, but it is enough for #115 and #121's use cases.
We're using Trybuild in LPC8xx HAL. We have a
.cargo/config.toml
there that sets the target tothumbv6m-none-eabi
.We override the target to run the Trybuild tests using
--target
in our build script (specifically these lines). This works perfectly with Trybuild 1.0.43 (and earlier), but fails with Trybuild 1.0.44:This error indicates that
--target
didn't take, and that the target from.cargo/config.toml
is used.121 seems to be the culprit here. I think the code it added wrongly assumes that Trybuild doesn't need to pass
--target
, if the--target
it receives is the same as the host. This is not true, if--target
is used to override a target set in.cargo/config.toml
/.cargo/config
.cc @taiki-e, @dtolnay