Skip to content
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

Regression: Trybuild doesn't pass on --target, even when needed #122

Closed
hannobraun opened this issue Aug 10, 2021 · 5 comments · Fixed by #123
Closed

Regression: Trybuild doesn't pass on --target, even when needed #122

hannobraun opened this issue Aug 10, 2021 · 5 comments · Fixed by #123

Comments

@hannobraun
Copy link
Contributor

We're using Trybuild in LPC8xx HAL. We have a .cargo/config.toml there that sets the target to thumbv6m-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:

     Running `/home/hanno/Projects/lpc-rs/lpc8xx-hal/target/x86_64-unknown-linux-gnu/debug/deps/compiletest-a70653e23af66043`

running 1 test
    Checking lpc8xx-hal-tests v0.0.0 (/home/hanno/Projects/lpc-rs/lpc8xx-hal/target/tests/lpc8xx-hal)
error[E0463]: can't find crate for `std`
  |
  = note: the `thumbv6m-none-eabi` target may not support the standard library
  = note: `std` is required by `lpc8xx_hal_tests` because it does not declare `#![no_std]`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: could not compile `lpc8xx-hal-tests`

To learn more, run the command again with --verbose.
test compile_test ... FAILED

failures:

---- compile_test stdout ----
thread 'compile_test' panicked at 'tests failed', /home/hanno/.cargo/registry/src/github.com-1ecc6299db9ec823/trybuild-1.0.44/src/run.rs:51:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    compile_test

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.40s

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

@hannobraun hannobraun changed the title Regression: Trybuild doesn't respect --target in LPC8xx HAL build Regression: Trybuild doesn't pass on --target, even when needed Aug 10, 2021
@dtolnay
Copy link
Owner

dtolnay commented Aug 10, 2021

Thanks -- sorry about the breakage. I've yanked 1.0.44 until someone can send a fix.

@hannobraun
Copy link
Contributor Author

No worries! Thank you for addressing this so quickly!

@taiki-e
Copy link
Contributor

taiki-e commented Aug 10, 2021

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):

trybuild/build.rs

Lines 28 to 31 in 0b33c0b

// - CARGO_ENCODED_RUSTFLAGS, which was introduced in rust-lang/cargo#9601,
// cannot be used for this purpose because it contains the value of
// RUSTFLAGS even if --target is passed and the host and target triples
// are the same.

@taiki-e
Copy link
Contributor

taiki-e commented Aug 10, 2021

The best way for this seems to be rust-lang/cargo#9532, but it may take quite a while before it is merged.

@taiki-e
Copy link
Contributor

taiki-e commented Aug 10, 2021

#123 is not a perfect approach for this because it cannot detect automatically, but it is enough for #115 and #121's use cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants