-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Allow configuring where artifacts are downloaded from #97828
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c1a0f49
keep the same config values in stage0 between invocations
pietroalbini 97f3ecd
load configuration for downloading artifacts from stage0.json
pietroalbini 77097c5
change stage0.json to reduce the chance of merge conflicts
pietroalbini 2f44813
future-proof adding more protocols
pietroalbini 754af72
fix typo
pietroalbini c20541f
fix tests
pietroalbini d3b1532
move stage0 config closer to Config
pietroalbini File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,6 @@ use crate::channel::GitInfo; | |
pub use crate::flags::Subcommand; | ||
use crate::flags::{Color, Flags}; | ||
use crate::util::{exe, output, program_out_of_date, t}; | ||
use crate::RustfmtMetadata; | ||
use once_cell::sync::OnceCell; | ||
use serde::{Deserialize, Deserializer}; | ||
|
||
|
@@ -73,6 +72,7 @@ pub struct Config { | |
pub test_compare_mode: bool, | ||
pub color: Color, | ||
pub patch_binaries_for_nix: bool, | ||
pub stage0_metadata: Stage0Metadata, | ||
|
||
pub on_fail: Option<String>, | ||
pub stage: u32, | ||
|
@@ -720,6 +720,28 @@ define_config! { | |
} | ||
} | ||
|
||
#[derive(Default, Deserialize)] | ||
#[cfg_attr(test, derive(Clone))] | ||
pub struct Stage0Metadata { | ||
pub config: Stage0Config, | ||
pub checksums_sha256: HashMap<String, String>, | ||
pub rustfmt: Option<RustfmtMetadata>, | ||
} | ||
#[derive(Default, Deserialize)] | ||
#[cfg_attr(test, derive(Clone))] | ||
pub struct Stage0Config { | ||
pub dist_server: String, | ||
pub artifacts_server: String, | ||
pub artifacts_with_llvm_assertions_server: String, | ||
pub git_merge_commit_email: String, | ||
} | ||
#[derive(Default, Deserialize)] | ||
#[cfg_attr(test, derive(Clone))] | ||
pub struct RustfmtMetadata { | ||
pub date: String, | ||
pub version: String, | ||
} | ||
|
||
impl Config { | ||
pub fn default_opts() -> Config { | ||
let mut config = Config::default(); | ||
|
@@ -776,6 +798,9 @@ impl Config { | |
config.llvm_profile_use = flags.llvm_profile_use; | ||
config.llvm_profile_generate = flags.llvm_profile_generate; | ||
|
||
let stage0_json = t!(std::fs::read(&config.src.join("src").join("stage0.json"))); | ||
config.stage0_metadata = t!(serde_json::from_slice::<Stage0Metadata>(&stage0_json)); | ||
|
||
#[cfg(test)] | ||
let get_toml = |_| TomlConfig::default(); | ||
#[cfg(not(test))] | ||
|
@@ -1103,8 +1128,11 @@ impl Config { | |
config.rust_codegen_units_std = rust.codegen_units_std.map(threads_from_config); | ||
config.rust_profile_use = flags.rust_profile_use.or(rust.profile_use); | ||
config.rust_profile_generate = flags.rust_profile_generate.or(rust.profile_generate); | ||
config.download_rustc_commit = | ||
download_ci_rustc_commit(rust.download_rustc, config.verbose > 0); | ||
config.download_rustc_commit = download_ci_rustc_commit( | ||
&config.stage0_metadata, | ||
rust.download_rustc, | ||
config.verbose > 0, | ||
); | ||
} else { | ||
config.rust_profile_use = flags.rust_profile_use; | ||
config.rust_profile_generate = flags.rust_profile_generate; | ||
|
@@ -1424,7 +1452,11 @@ fn threads_from_config(v: u32) -> u32 { | |
} | ||
|
||
/// Returns the commit to download, or `None` if we shouldn't download CI artifacts. | ||
fn download_ci_rustc_commit(download_rustc: Option<StringOrBool>, verbose: bool) -> Option<String> { | ||
fn download_ci_rustc_commit( | ||
stage0_metadata: &Stage0Metadata, | ||
download_rustc: Option<StringOrBool>, | ||
verbose: bool, | ||
) -> Option<String> { | ||
// If `download-rustc` is not set, default to rebuilding. | ||
let if_unchanged = match download_rustc { | ||
None | Some(StringOrBool::Bool(false)) => return None, | ||
|
@@ -1443,13 +1475,12 @@ fn download_ci_rustc_commit(download_rustc: Option<StringOrBool>, verbose: bool) | |
|
||
// Look for a version to compare to based on the current commit. | ||
// Only commits merged by bors will have CI artifacts. | ||
let merge_base = output(Command::new("git").args(&[ | ||
"rev-list", | ||
"[email protected]", | ||
"-n1", | ||
"--first-parent", | ||
"HEAD", | ||
])); | ||
let merge_base = output( | ||
Command::new("git") | ||
.arg("rev-list") | ||
.arg(format!("--author={}", stage0_metadata.config.git_merge_commit_email)) | ||
.args(&["-n1", "--first-parent", "HEAD"]), | ||
); | ||
let commit = merge_base.trim_end(); | ||
if commit.is_empty() { | ||
println!("error: could not find commit hash for downloading rustc"); | ||
|
@@ -1484,7 +1515,7 @@ fn download_ci_rustc_commit(download_rustc: Option<StringOrBool>, verbose: bool) | |
} | ||
|
||
fn maybe_download_rustfmt(builder: &Builder<'_>) -> Option<PathBuf> { | ||
let RustfmtMetadata { date, version } = builder.stage0_metadata.rustfmt.as_ref()?; | ||
let RustfmtMetadata { date, version } = builder.config.stage0_metadata.rustfmt.as_ref()?; | ||
let channel = format!("{version}-{date}"); | ||
|
||
let host = builder.config.build; | ||
|
@@ -1568,13 +1599,13 @@ fn download_component( | |
let tarball = cache_dir.join(&filename); | ||
let (base_url, url, should_verify) = match mode { | ||
DownloadSource::CI => ( | ||
"https://ci-artifacts.rust-lang.org/rustc-builds".to_string(), | ||
builder.config.stage0_metadata.config.artifacts_server.clone(), | ||
format!("{key}/{filename}"), | ||
false, | ||
), | ||
DownloadSource::Dist => { | ||
let dist_server = env::var("RUSTUP_DIST_SERVER") | ||
.unwrap_or(builder.stage0_metadata.dist_server.to_string()); | ||
.unwrap_or(builder.config.stage0_metadata.config.dist_server.to_string()); | ||
// NOTE: make `dist` part of the URL because that's how it's stored in src/stage0.json | ||
(dist_server, format!("dist/{key}/{filename}"), true) | ||
} | ||
|
@@ -1590,7 +1621,7 @@ fn download_component( | |
target at this time, see https://doc.rust-lang.org/nightly\ | ||
/rustc/platform-support.html for more information." | ||
); | ||
let sha256 = builder.stage0_metadata.checksums_sha256.get(&url).expect(&error); | ||
let sha256 = builder.config.stage0_metadata.checksums_sha256.get(&url).expect(&error); | ||
if tarball.exists() { | ||
if builder.verify(&tarball, sha256) { | ||
builder.unpack(&tarball, &bin_root, prefix); | ||
|
@@ -1610,7 +1641,7 @@ fn download_component( | |
None | ||
}; | ||
|
||
builder.download_component(&base_url, &url, &tarball, ""); | ||
builder.download_component(&format!("{base_url}/{url}"), &tarball, ""); | ||
if let Some(sha256) = checksum { | ||
if !builder.verify(&tarball, sha256) { | ||
panic!("failed to verify {}", tarball.display()); | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -121,7 +121,7 @@ pub(crate) fn maybe_download_ci_llvm(builder: &Builder<'_>) { | |
let mut rev_list = Command::new("git"); | ||
rev_list.args(&[ | ||
PathBuf::from("rev-list"), | ||
"--author=[email protected]".into(), | ||
format!("--author={}", builder.config.stage0_metadata.config.git_merge_commit_email).into(), | ||
"-n1".into(), | ||
"--first-parent".into(), | ||
"HEAD".into(), | ||
|
@@ -170,11 +170,10 @@ fn download_ci_llvm(builder: &Builder<'_>, llvm_sha: &str) { | |
if !rustc_cache.exists() { | ||
t!(fs::create_dir_all(&rustc_cache)); | ||
} | ||
let base = "https://ci-artifacts.rust-lang.org"; | ||
let url = if llvm_assertions { | ||
format!("rustc-builds-alt/{}", llvm_sha) | ||
let base = if llvm_assertions { | ||
&builder.config.stage0_metadata.config.artifacts_with_llvm_assertions_server | ||
} else { | ||
format!("rustc-builds/{}", llvm_sha) | ||
&builder.config.stage0_metadata.config.artifacts_server | ||
}; | ||
let filename = format!("rust-dev-nightly-{}.tar.xz", builder.build.build.triple); | ||
let tarball = rustc_cache.join(&filename); | ||
|
@@ -187,7 +186,11 @@ fn download_ci_llvm(builder: &Builder<'_>, llvm_sha: &str) { | |
\ndownload-ci-llvm = false | ||
\n | ||
"; | ||
builder.download_component(base, &format!("{}/{}", url, filename), &tarball, help_on_error); | ||
builder.download_component( | ||
&format!("{base}/{llvm_sha}/{filename}"), | ||
&tarball, | ||
help_on_error, | ||
); | ||
} | ||
let llvm_root = builder.config.ci_llvm_root(); | ||
builder.unpack(&tarball, &llvm_root, "rust-dev"); | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,20 @@ | ||
{ | ||
"__comment": "Generated by `./x.py run src/tools/bump-stage0`. Run that command again to update the bootstrap compiler.", | ||
"dist_server": "https://static.rust-lang.org", | ||
"config": { | ||
jyn514 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"dist_server": "https://static.rust-lang.org", | ||
"artifacts_server": "https://ci-artifacts.rust-lang.org/rustc-builds", | ||
"artifacts_with_llvm_assertions_server": "https://ci-artifacts.rust-lang.org/rustc-builds-alt", | ||
"git_merge_commit_email": "[email protected]" | ||
}, | ||
"__comments": [ | ||
"The configuration above this comment is editable, and can be changed", | ||
"by forks of the repository if they have alternate values.", | ||
"", | ||
"The section below is generated by `./x.py run src/tools/bump-stage0`,", | ||
"run that command again to update the bootstrap compiler.", | ||
"", | ||
"All changes below this comment will be overridden the next time the", | ||
"tool is executed." | ||
], | ||
"compiler": { | ||
"date": "2022-05-20", | ||
"version": "beta" | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.