Rollup merge of #130918 - onur-ozkan:better-llvm-submodule-handling, r=Kobzol
simplify LLVM submodule handling Fixes #130906.
This commit is contained in:
commit
f33fa3f57b
@ -1205,7 +1205,8 @@ pub fn rustc_cargo_env(
|
||||
// busting caches (e.g. like #71152).
|
||||
if builder.config.llvm_enabled(target) {
|
||||
let building_is_expensive =
|
||||
crate::core::build_steps::llvm::prebuilt_llvm_config(builder, target).should_build();
|
||||
crate::core::build_steps::llvm::prebuilt_llvm_config(builder, target, false)
|
||||
.should_build();
|
||||
// `top_stage == stage` might be false for `check --stage 1`, if we are building the stage 1 compiler
|
||||
let can_skip_build = builder.kind == Kind::Check && builder.top_stage == stage;
|
||||
let should_skip_build = building_is_expensive && can_skip_build;
|
||||
|
@ -2036,7 +2036,7 @@ fn maybe_install_llvm(
|
||||
}
|
||||
!builder.config.dry_run()
|
||||
} else if let llvm::LlvmBuildStatus::AlreadyBuilt(llvm::LlvmResult { llvm_config, .. }) =
|
||||
llvm::prebuilt_llvm_config(builder, target)
|
||||
llvm::prebuilt_llvm_config(builder, target, true)
|
||||
{
|
||||
let mut cmd = command(llvm_config);
|
||||
cmd.arg("--libfiles");
|
||||
|
@ -87,10 +87,14 @@ fn push_all(&mut self, s: impl AsRef<OsStr>) {
|
||||
///
|
||||
/// This will return the llvm-config if it can get it (but it will not build it
|
||||
/// if not).
|
||||
pub fn prebuilt_llvm_config(builder: &Builder<'_>, target: TargetSelection) -> LlvmBuildStatus {
|
||||
// If we have llvm submodule initialized already, sync it.
|
||||
builder.update_existing_submodule("src/llvm-project");
|
||||
|
||||
pub fn prebuilt_llvm_config(
|
||||
builder: &Builder<'_>,
|
||||
target: TargetSelection,
|
||||
// Certain commands (like `x test mir-opt --bless`) may call this function with different targets,
|
||||
// which could bypass the CI LLVM early-return even if `builder.config.llvm_from_ci` is true.
|
||||
// This flag should be `true` only if the caller needs the LLVM sources (e.g., if it will build LLVM).
|
||||
handle_submodule_when_needed: bool,
|
||||
) -> LlvmBuildStatus {
|
||||
builder.config.maybe_download_ci_llvm();
|
||||
|
||||
// If we're using a custom LLVM bail out here, but we can only use a
|
||||
@ -109,9 +113,10 @@ pub fn prebuilt_llvm_config(builder: &Builder<'_>, target: TargetSelection) -> L
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize the llvm submodule if not initialized already.
|
||||
// If submodules are disabled, this does nothing.
|
||||
builder.config.update_submodule("src/llvm-project");
|
||||
if handle_submodule_when_needed {
|
||||
// If submodules are disabled, this does nothing.
|
||||
builder.config.update_submodule("src/llvm-project");
|
||||
}
|
||||
|
||||
let root = "src/llvm-project/llvm";
|
||||
let out_dir = builder.llvm_out(target);
|
||||
@ -284,7 +289,7 @@ fn run(self, builder: &Builder<'_>) -> LlvmResult {
|
||||
};
|
||||
|
||||
// If LLVM has already been built or been downloaded through download-ci-llvm, we avoid building it again.
|
||||
let Meta { stamp, res, out_dir, root } = match prebuilt_llvm_config(builder, target) {
|
||||
let Meta { stamp, res, out_dir, root } = match prebuilt_llvm_config(builder, target, true) {
|
||||
LlvmBuildStatus::AlreadyBuilt(p) => return p,
|
||||
LlvmBuildStatus::ShouldBuild(m) => m,
|
||||
};
|
||||
|
@ -1537,7 +1537,9 @@ fn cargo(
|
||||
// rustc_llvm. But if LLVM is stale, that'll be a tiny amount
|
||||
// of work comparatively, and we'd likely need to rebuild it anyway,
|
||||
// so that's okay.
|
||||
if crate::core::build_steps::llvm::prebuilt_llvm_config(self, target).should_build() {
|
||||
if crate::core::build_steps::llvm::prebuilt_llvm_config(self, target, false)
|
||||
.should_build()
|
||||
{
|
||||
cargo.env("RUST_CHECK", "1");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user