Skip to content
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

override user defined channel when using precompiled rustc #126572

Merged
merged 2 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 6 additions & 17 deletions src/bootstrap/src/core/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1036,23 +1036,12 @@ impl<'a> Builder<'a> {
}

pub fn doc_rust_lang_org_channel(&self) -> String {
// When using precompiled compiler from CI, we need to use CI rustc's channel and
// ignore `rust.channel` from the configuration. Otherwise most of the rustdoc tests
// will fail due to incompatible `DOC_RUST_LANG_ORG_CHANNEL`.
let channel = if let Some(commit) = self.config.download_rustc_commit() {
self.config
.read_file_by_commit(&PathBuf::from("src/ci/channel"), commit)
.trim()
.to_owned()
} else {
match &*self.config.channel {
"stable" => &self.version,
"beta" => "beta",
"nightly" | "dev" => "nightly",
// custom build of rustdoc maybe? link to the latest stable docs just in case
_ => "stable",
}
.to_owned()
let channel = match &*self.config.channel {
"stable" => &self.version,
"beta" => "beta",
"nightly" | "dev" => "nightly",
// custom build of rustdoc maybe? link to the latest stable docs just in case
_ => "stable",
};

format!("https://doc.rust-lang.org/{channel}")
Expand Down
18 changes: 17 additions & 1 deletion src/bootstrap/src/core/config/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1718,7 +1718,23 @@ impl Config {
config.omit_git_hash = omit_git_hash.unwrap_or(default);
config.rust_info = GitInfo::new(config.omit_git_hash, &config.src);

if config.rust_info.is_from_tarball() && !is_user_configured_rust_channel {
// We need to override `rust.channel` if it's manually specified when using the CI rustc.
// This is because if the compiler uses a different channel than the one specified in config.toml,
// tests may fail due to using a different channel than the one used by the compiler during tests.
if let Some(commit) = &config.download_rustc_commit {
if is_user_configured_rust_channel {
println!(
"WARNING: `rust.download-rustc` is enabled. The `rust.channel` option will be overridden by the CI rustc's channel."
);

let channel = config
.read_file_by_commit(&PathBuf::from("src/ci/channel"), commit)
.trim()
.to_owned();

config.channel = channel;
}
} else if config.rust_info.is_from_tarball() && !is_user_configured_rust_channel {
ci_channel.clone_into(&mut config.channel);
}

Expand Down
Loading