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

fix build.rs invoking RUSTC to do check builds #2436

Merged
merged 3 commits into from
Jul 25, 2022

Conversation

RalfJung
Copy link
Member

@RalfJung RalfJung commented Jul 24, 2022

This makes the Miri driver, when invokved via the RUSTC env var from inside a build script, behave almost entirely like rustc. I had to redo how we propagate sysroot information for this (which is actually back to how we used to do sysroot propagation many years ago).

Fixes #2431

@@ -20,4 +20,9 @@ fn main() {
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-env-changed=MIRITESTVAR");
println!("cargo:rustc-env=MIRITESTVAR=testval");

// Test that autocfg works.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arguably this is testing cargo-miri build script support so having this in test-cargo-miri is the right place IMO.

src/bin/miri.rs Outdated Show resolved Hide resolved
@RalfJung
Copy link
Member Author

Oh interesting, this fails in cross-mode. That is probably a problem even before the recent RUSTC changes, but would be nice to find a way to fix it...

@RalfJung
Copy link
Member Author

@rustbot author

@rustbot rustbot added the S-waiting-on-author Status: Waiting for the PR author to address review comments label Jul 24, 2022
@RalfJung
Copy link
Member Author

Ah, the problem is that it uses the wrong sysroot. That's why we usually forward rustc invocations through cargo-miri -- it adjusts the sysroot.

I had to completely redo the way we manage the sysroot for this, but now it should be working.

@RalfJung RalfJung changed the title only perform interpretation in binary crates fix build.rs invoking RUSTC to do check builds Jul 24, 2022
this requires a change in sysroot handling: miri driver now requires
MIRI_SYSROOT to be set when it is in 'target' mode, rather than relying on
`--sysroot` always being present.
@RalfJung
Copy link
Member Author

Okay this is now quite different from where it started, and also works much better. I have updated the PR title and description accordingly.

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Waiting for a review to complete and removed S-waiting-on-author Status: Waiting for the PR author to address review comments labels Jul 24, 2022
@oli-obk
Copy link
Contributor

oli-obk commented Jul 25, 2022

Oooh you figured out the env var dance with unsetting for recursive cases. I gave up on that. I should make a graph of what invokes what some day...

@oli-obk
Copy link
Contributor

oli-obk commented Jul 25, 2022

@bors r+

@bors
Copy link
Collaborator

bors commented Jul 25, 2022

📌 Commit 9406b6d has been approved by oli-obk

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Jul 25, 2022

⌛ Testing commit 9406b6d with merge 3d237be...

@bors
Copy link
Collaborator

bors commented Jul 25, 2022

☀️ Test successful - checks-actions
Approved by: oli-obk
Pushing 3d237be to master...

@bors bors merged commit 3d237be into rust-lang:master Jul 25, 2022
@RalfJung RalfJung deleted the lib-crates branch July 25, 2022 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Waiting for a review to complete
Projects
None yet
Development

Successfully merging this pull request may close these issues.

autocfg assumes there is no std
4 participants