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

unwind: don't build dependency when building for Miri #100532

Merged
merged 1 commit into from
Aug 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion library/unwind/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@ use std::env;

fn main() {
println!("cargo:rerun-if-changed=build.rs");
let target = env::var("TARGET").expect("TARGET was not set");
println!("cargo:rerun-if-env-changed=CARGO_CFG_MIRI");

if env::var_os("CARGO_CFG_MIRI").is_some() {
Copy link
Member Author

Choose a reason for hiding this comment

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

Should there be a rerun-if-changed for this, or does cargo rerun anyway when the cfg flags change?

Copy link
Member

Choose a reason for hiding this comment

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

A dedicated rerun-if-change definitely won't hurt, I think.

That said, presumably you actually don't want to re-run the script (and rebuild the world) when switching between --cfg=miri and not, if you've previously had it build successfully? RUST_CHECK has similar behavior where once we've built LLVM, it never gets passed down (even in check builds).

I admit I've not followed the story around cfg(miri) enough to know where we're setting that or how, can you point me to that?

Copy link
Member Author

@RalfJung RalfJung Aug 15, 2022

Choose a reason for hiding this comment

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

A dedicated rerun-if-change definitely won't hurt, I think.

Done.

I admit I've not followed the story around cfg(miri) enough to know where we're setting that or how, can you point me to that?

Miri sets --cfg miri on all things it builds: here the flag is defined, here it is added.
Miri also uses a separate target dir, so for a given target dir, it should never be the case that it is sometimes built with --cfg miri and sometimes without.

RUST_CHECK has similar behavior where once we've built LLVM, it never gets passed down (even in check builds).

So that is some further extra magic and rustbuild implements?

Copy link
Member

Choose a reason for hiding this comment

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

Ah, okay, if this never differs for a given target dir then it should be OK -- no need for special magic.

Yes, RUST_CHECK is only set by rustbuild (not Cargo or others); definition here.

// Miri doesn't need the linker flags or a libunwind build.
return;
}

let target = env::var("TARGET").expect("TARGET was not set");
if target.contains("android") {
let build = cc::Build::new();

Expand Down