-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Add if-identical mode for download-ci-llvm
#113761
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
Changes from 1 commit
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 |
|---|---|---|
|
|
@@ -602,7 +602,7 @@ download-rustc = false | |
| } | ||
|
|
||
| pub(crate) fn maybe_download_ci_llvm(&self) { | ||
| if !self.llvm.from_ci { | ||
| if !self.llvm_from_ci { | ||
| return; | ||
| } | ||
| let llvm_root = self.ci_llvm_root(); | ||
|
|
@@ -674,4 +674,33 @@ download-rustc = false | |
| let llvm_root = self.ci_llvm_root(); | ||
| self.unpack(&tarball, &llvm_root, "rust-dev"); | ||
| } | ||
|
|
||
| pub(crate) fn download_ci_llvm_opts(&self, llvm_sha: &str) { | ||
| let cache_prefix = format!("llvm-opts-{llvm_sha}"); | ||
| let cache_dst = self.out.join("cache"); | ||
| let rustc_cache = cache_dst.join(cache_prefix); | ||
| t!(fs::create_dir_all(&rustc_cache)); | ||
| let base = if self.llvm.assertions { | ||
| &self.stage0_metadata.config.artifacts_with_llvm_assertions_server | ||
| } else { | ||
| &self.stage0_metadata.config.artifacts_server | ||
| }; | ||
| let version = self.artifact_version_part(llvm_sha); | ||
| let filename = format!("rust-dev-config-{}-{}.tar.xz", version, self.build.triple); | ||
| let tarball = rustc_cache.join(&filename); | ||
| if !tarball.exists() { | ||
| let help_on_error = "error: failed to download llvm config from ci | ||
|
|
||
| help: old builds get deleted after a certain time | ||
| help: if trying to compile an old commit of rustc, disable `download-ci-llvm` in config.toml: | ||
|
|
||
| [llvm] | ||
| download-ci-llvm = false | ||
| "; | ||
| self.download_file(&format!("{base}/{llvm_sha}/{filename}"), &tarball, help_on_error); | ||
| } | ||
|
|
||
| let llvm_root = self.ci_llvm_root_opts(); | ||
| self.unpack(&tarball, &llvm_root, "rust-dev-config"); | ||
|
Comment on lines
+678
to
+704
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. i have a vague "this is duplicating a lot of code" feeling but nothing concrete - if you find some easy way to reduce the boilerplate here that would be nice, but no worries if it's tricky
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. I still wonder if it wouldn't be simpler to just always download the LLVM archive (when using the |
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,7 +18,7 @@ use std::process::Command; | |
|
|
||
| use crate::builder::{Builder, RunConfig, ShouldRun, Step}; | ||
| use crate::channel; | ||
| use crate::config::{Config, TargetSelection}; | ||
| use crate::config::{Config, LLVMConfig, TargetSelection}; | ||
| use crate::util::get_clang_cl_resource_dir; | ||
| use crate::util::{self, exe, output, t, up_to_date}; | ||
| use crate::{CLang, GitRepo, Kind}; | ||
|
|
@@ -215,6 +215,23 @@ pub(crate) fn is_ci_llvm_available(config: &Config, asserts: bool) -> bool { | |
| true | ||
| } | ||
|
|
||
| pub(crate) fn get_llvm_opts_from_ci(config: &Config) -> Option<LLVMConfig> { | ||
| if config.dry_run() || is_ci_llvm_modified(config) { | ||
| return None; | ||
| } | ||
|
|
||
| let llvm_sha = detect_llvm_sha(config, config.rust_info.is_managed_git_subrepository()); | ||
| config.download_ci_llvm_opts(&llvm_sha); | ||
|
|
||
| let config_path = config.ci_llvm_root_opts().join("llvm-opts.json"); | ||
| let Ok(config) = serde_json::from_slice::<LLVMConfig>(&t!(std::fs::read(config_path))) else { | ||
| // The LLVM config has changed its format or is corrupted in some way | ||
| eprintln!("Cannot deserialize LLVM config from llvm-opts.json"); | ||
| return None; | ||
|
Comment on lines
+228
to
+230
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. hmm, when would this happen? continuing the build when we can't parse the format seems unfortunate, i worry it'll silence a real bug.
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. For example, if the struct is modified in a backwards incompatible way (e.g. new option added/removed), then it may fail to parse. This situation necessarily means that the config has changed somehow, and therefore we shouldn't reuse the LLVM from CI. In theory, we could lose all caching if there was some bug and it was never deserialized properly, but the alternative is basically failing the build if the format changes, which we probably shouldn't do?
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. Or we could devise some versioning scheme for the config (Protobuf? 😆 ), but that seems like overkill. |
||
| }; | ||
| Some(config) | ||
| } | ||
|
|
||
| /// Returns true if we're running in CI with modified LLVM (and thus can't download it) | ||
| pub(crate) fn is_ci_llvm_modified(config: &Config) -> bool { | ||
| CiEnv::is_ci() && config.rust_info.is_managed_git_subrepository() && { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.