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

resolve rustdoc incompatibility with rust.download-rustc=true + rust.channel= beta/stable #126153

Merged
merged 2 commits into from
Jun 10, 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
26 changes: 19 additions & 7 deletions src/bootstrap/src/core/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1038,14 +1038,26 @@ impl<'a> Builder<'a> {
}

pub fn doc_rust_lang_org_channel(&self) -> String {
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",
// 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()
};
"https://doc.rust-lang.org/".to_owned() + channel

format!("https://doc.rust-lang.org/{channel}")
}

fn run_step_descriptions(&self, v: &[StepDescription], paths: &[PathBuf]) {
Expand Down
41 changes: 21 additions & 20 deletions src/bootstrap/src/core/config/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1608,19 +1608,8 @@ impl Config {
set(&mut config.channel, channel);

config.download_rustc_commit = config.download_ci_rustc_commit(download_rustc);
// This list is incomplete, please help by expanding it!
if config.download_rustc_commit.is_some() {
// We need the channel used by the downloaded compiler to match the one we set for rustdoc;
// otherwise rustdoc-ui tests break.
if config.channel != ci_channel
&& !(config.channel == "dev" && ci_channel == "nightly")
{
panic!(
"setting rust.channel={} is incompatible with download-rustc",
config.channel
);
}
}

// FIXME: handle download-rustc incompatible options.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have several incompatibility checks for download-rustc, but I believe we can further expand them. I'm unsure about which options we can check, so I'll leave this FIXME to revisit later.


debug = debug_toml;
debug_assertions = debug_assertions_toml;
Expand Down Expand Up @@ -2134,17 +2123,29 @@ impl Config {
args
}

/// Returns the content of the given file at a specific commit.
pub(crate) fn read_file_by_commit(&self, file: &Path, commit: &str) -> String {
assert!(
self.rust_info.is_managed_git_subrepository(),
"`Config::read_file_by_commit` is not supported in non-git sources."
);

let mut git = self.git();
git.arg("show").arg(format!("{commit}:{}", file.to_str().unwrap()));
output(&mut git)
}

/// Bootstrap embeds a version number into the name of shared libraries it uploads in CI.
/// Return the version it would have used for the given commit.
pub(crate) fn artifact_version_part(&self, commit: &str) -> String {
let (channel, version) = if self.rust_info.is_managed_git_subrepository() {
let mut channel = self.git();
channel.arg("show").arg(format!("{commit}:src/ci/channel"));
let channel = output(&mut channel);
let mut version = self.git();
version.arg("show").arg(format!("{commit}:src/version"));
let version = output(&mut version);
(channel.trim().to_owned(), version.trim().to_owned())
let channel = self
.read_file_by_commit(&PathBuf::from("src/ci/channel"), commit)
.trim()
.to_owned();
let version =
self.read_file_by_commit(&PathBuf::from("src/version"), commit).trim().to_owned();
(channel, version)
} else {
let channel = fs::read_to_string(self.src.join("src/ci/channel"));
let version = fs::read_to_string(self.src.join("src/version"));
Expand Down
Loading