-
Notifications
You must be signed in to change notification settings - Fork 13.4k
fix rustc_llvm spurious rebuilds #100152
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 rustc_llvm spurious rebuilds #100152
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -780,9 +780,21 @@ pub fn rustc_cargo_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetS | |
cargo.env("LLVM_RUSTLLVM", "1"); | ||
} | ||
let llvm_config = builder.ensure(native::Llvm { target }); | ||
cargo.env("LLVM_CONFIG", &llvm_config); | ||
|
||
// HACK: on windows, paths are case insensitive, so case differences cause spurious rebuilds | ||
if target.contains("windows") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is the target important here? Shouldn't it be the host instead? Because one might cross compile Windows from Linux, which usually happens on a case sensitive file system. Or vice versa. Also, it's an imprecise generalization that windows paths are case insensitive, because you can enable case sensitive directories on Windows. Wouldn't this break in this instance then? |
||
cargo.env("LLVM_CONFIG", llvm_config.as_os_str().to_ascii_lowercase()); | ||
} else { | ||
cargo.env("LLVM_CONFIG", &llvm_config); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It feels like we'll be on a pretty long road to fixing this if we have to make this kind of conversion on every point where Cargo is going to be sensitive to this. Is there a chance this is something we can fix with rust-analyzer or otherwise? It feels a little weird that there's different cases floating around, even if the underlying filesystem is insensitive. |
||
|
||
if let Some(s) = target_config.and_then(|c| c.llvm_config.as_ref()) { | ||
cargo.env("CFG_LLVM_ROOT", s); | ||
// HACK: on windows, paths are case insensitive, so case differences cause spurious rebuilds | ||
if target.contains("windows") { | ||
cargo.env("CFG_LLVM_ROOT", s.as_os_str().to_ascii_lowercase()); | ||
} else { | ||
cargo.env("CFG_LLVM_ROOT", s); | ||
} | ||
} | ||
|
||
// Some LLVM linker flags (-L and -l) may be needed to link `rustc_llvm`. Its build script | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is pretty suspicious -- this env variable should get set by rustbuild only if LLVM hasn't been built and we don't expect to need it (check/clippy run).
So if you build, then on a subsequent x.py check, RUST_CHECK shouldn't be set. I think the fault here lies with the logic around here (
rust/src/bootstrap/builder.rs
Line 1391 in 3830eca