-
-
Notifications
You must be signed in to change notification settings - Fork 15.5k
Assorted bootstrap LLVM refactors (part 4/N) #161290
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
base: main
Are you sure you want to change the base?
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 |
|---|---|---|
|
|
@@ -32,7 +32,7 @@ use crate::utils::helpers::{ | |
| /// Path where a file containing the link type (dynamic or static) is stored in the LLVM CI tarball. | ||
| pub const LLVM_CI_LINK_TYPE_PATH: &str = "link-type.txt"; | ||
|
|
||
| #[derive(Copy, Clone)] | ||
| #[derive(Copy, Clone, PartialEq, Eq)] | ||
| pub enum LlvmKind { | ||
| /// The LLVM was built from in-tree sources | ||
| BuiltLocally, | ||
|
|
@@ -256,26 +256,45 @@ fn llvm_output_dir(builder: &Builder<'_>, target: TargetSelection) -> PathBuf { | |
| } | ||
|
|
||
| fn try_download_ci_llvm(builder: &Builder<'_>, target: TargetSelection) -> Option<DownloadedLlvm> { | ||
| match builder.config.llvm_ci_mode { | ||
| LlvmCiMode::BuildLocally => return None, | ||
| LlvmCiMode::DownloadFromCi => {} | ||
| if builder.config.llvm_ci_mode.requests_download_from_ci() | ||
| && let Some(config) = builder.config.target_config.get(&target) | ||
| { | ||
| if config.llvm_config.is_some() { | ||
| panic!( | ||
| "Cannot configure `llvm-config` for {target} when using `llvm.download-ci-llvm`", | ||
| ); | ||
| } | ||
| if config.llvm_filecheck.is_some() { | ||
| panic!( | ||
| "Cannot configure `llvm-filecheck` for {target} when using `llvm.download-ci-llvm`" | ||
| ); | ||
| } | ||
| } | ||
|
Comment on lines
+259
to
+272
Member
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. Without per-target
Previously, did we just use external LLVM for the target when host != target, when CI LLVM was available for host and requested? Or did this just never work? This logic seems a bit fishy, won't in-tree default profiles (compiler/tools/libs) also hit this with
Member
Author
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. Previously this check was only done for the host, so the case you described worked. What about this:
Member
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. This seems more intuitive to me yeah. 👍 |
||
|
|
||
| // FIXME: this should eventually be relaxed | ||
| if target != builder.host_target { | ||
| crate::debug!("LLVM not available on CI for non-host target {target}"); | ||
| return None; | ||
| match builder.config.llvm_ci_mode { | ||
| LlvmCiMode::BuildLocally => return None, | ||
| LlvmCiMode::Download => {} | ||
| LlvmCiMode::DownloadIfUnchanged => { | ||
| builder.config.update_submodule("src/llvm-project"); | ||
|
|
||
| // Check for untracked changes in `src/llvm-project` and other important places. | ||
| let has_changes = builder.config.has_changes_from_upstream(LLVM_INVALIDATION_PATHS); | ||
| if has_changes { | ||
| builder.info("Warning: LLVM will not be downloaded because of local changes"); | ||
| return None; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if !is_ci_llvm_available_for_target(&target, builder.config.llvm_assertions) { | ||
| crate::debug!( | ||
| "LLVM not available on CI for target={target} and assertions={}", | ||
| builder.info(&format!( | ||
| "Warning: LLVM not available on CI for target={target} and assertions={}", | ||
| builder.config.llvm_assertions | ||
| ); | ||
| )); | ||
| return None; | ||
| } | ||
|
|
||
| let ci_llvm = builder.config.maybe_download_host_ci_llvm()?; | ||
| let ci_llvm = builder.config.maybe_download_ci_llvm(target)?; | ||
| let link_shared = if !builder.config.dry_run() { | ||
| let link_type = t!( | ||
| std::fs::read_to_string(ci_llvm.join(LLVM_CI_LINK_TYPE_PATH)), | ||
|
|
@@ -288,7 +307,7 @@ fn try_download_ci_llvm(builder: &Builder<'_>, target: TargetSelection) -> Optio | |
|
|
||
| Some(DownloadedLlvm { | ||
| output: LlvmOutput { | ||
| llvm_config: ci_llvm.join("bin").join(exe("llvm-config", builder.host_target)), | ||
| llvm_config: ci_llvm.join("bin").join(exe("llvm-config", target)), | ||
| link_shared, | ||
| llvm_root_dir: ci_llvm, | ||
| kind: LlvmKind::DownloadedFromCi, | ||
|
|
@@ -405,8 +424,12 @@ impl Step for LlvmFromCi { | |
|
|
||
| fn run(self, builder: &Builder<'_>) -> Self::Output { | ||
| let llvm_ci = try_download_ci_llvm(builder, self.target)?; | ||
|
|
||
| // Sanity check | ||
| check_llvm_version(builder, llvm_ci.output.llvm_config()); | ||
| if builder.host_target == self.target { | ||
| check_llvm_version(builder, llvm_ci.output.llvm_config()); | ||
| } | ||
|
Kobzol marked this conversation as resolved.
|
||
|
|
||
| Some(llvm_ci) | ||
| } | ||
| } | ||
|
|
||
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.
I'm on board with option (4) but with a caveat:
download-ci-llvm = "if-unchanged") or if they explicitly specifieddownload-ci-llvm = "if-unchanged", then "try to download, build if missing" fallback feels reasonable.download-ci-llvm = true, we should fail the build if no CI LLVM is available.I think this matches what currently
download-ci-llvm = "if-unchanged"for host targets do?To clarify, I think what you mean here is for
download-ci-llvm = "if-unchanged"?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.
Actualy, it doesn't :)
trueandif-unchangedare not different in this behavior currently. If you use either of them, and the given target is unavailable on CI, bootstrap will just build LLVM locally. It would seem surprising to me if those two modes had a different behavior in this specific aspect.rust/src/bootstrap/src/core/config/config.rs
Line 2489 in 287084b
rust/src/bootstrap/src/core/config/config.rs
Line 2513 in 287084b
(By the way, I'm considering merging those two modes together, same as we do for gcc. So that you only say
true, and if there are local changes, you would build. But if the LLVM submodule is checked out, you wouldn't check git changes, ofc.)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.
Hm... I guess that sometimes I do want to download-ci-llvm to fail the build if CI LLVM cannot be used for whatever reason and never checkout the llvm submodule. (In that, for specific cases like testing in-tree tools I prefer to fail the build rather than trying to recover.)
But yeah if this matches existing behavior then we can consider revisiting this behavior later.