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

Add manifest docs fallback. #92800

Merged
merged 4 commits into from
Jan 20, 2022
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ jobs:
- name: dist-aarch64-apple
env:
SCRIPT: "./x.py dist --stage 2"
RUST_CONFIGURE_ARGS: "--build=x86_64-apple-darwin --host=aarch64-apple-darwin --target=aarch64-apple-darwin --enable-full-tools --enable-sanitizers --enable-profiler --set rust.jemalloc --set llvm.ninja=false"
RUST_CONFIGURE_ARGS: "--build=x86_64-apple-darwin --host=aarch64-apple-darwin --target=aarch64-apple-darwin --enable-full-tools --enable-sanitizers --enable-profiler --disable-docs --set rust.jemalloc --set llvm.ninja=false"
RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
USE_XCODE_CLANG: 1
MACOSX_DEPLOYMENT_TARGET: 11.0
Expand Down
3 changes: 1 addition & 2 deletions src/bootstrap/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1483,11 +1483,10 @@ impl Step for Extended {
};
prepare("rustc");
prepare("cargo");
prepare("rust-docs");
prepare("rust-std");
prepare("rust-analysis");
prepare("clippy");
for tool in &["rust-demangler", "rls", "rust-analyzer", "miri"] {
for tool in &["rust-docs", "rust-demangler", "rls", "rust-analyzer", "miri"] {
if built_tools.contains(tool) {
prepare(tool);
}
Expand Down
1 change: 1 addition & 0 deletions src/ci/github-actions/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,7 @@ jobs:
--enable-full-tools
--enable-sanitizers
--enable-profiler
--disable-docs
--set rust.jemalloc
--set llvm.ninja=false
RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
Expand Down
3 changes: 1 addition & 2 deletions src/tools/build-manifest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ Then, you can generate the manifest and all the packages from `path/to/dist` to
`path/to/output` with:

```
$ cargo +nightly run path/to/dist path/to/output 1970-01-01 http://example.com \
CHANNEL VERSION
$ cargo +nightly run path/to/dist path/to/output 1970-01-01 http://example.com CHANNEL
```

Remember to replace `CHANNEL` with the channel you produced dist artifacts of
Expand Down
98 changes: 63 additions & 35 deletions src/tools/build-manifest/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,17 +155,19 @@ static TARGETS: &[&str] = &[
"x86_64-unknown-hermit",
];

static DOCS_TARGETS: &[&str] = &[
"aarch64-unknown-linux-gnu",
"i686-apple-darwin",
"i686-pc-windows-gnu",
"i686-pc-windows-msvc",
"i686-unknown-linux-gnu",
"x86_64-apple-darwin",
"x86_64-pc-windows-gnu",
"x86_64-pc-windows-msvc",
"x86_64-unknown-linux-gnu",
"x86_64-unknown-linux-musl",
/// This allows the manifest to contain rust-docs for hosts that don't build
/// docs.
///
/// Tuples of `(host_partial, host_instead)`. If the host does not have the
/// rust-docs component available, then if the host name contains
/// `host_partial`, it will use the docs from `host_instead` instead.
///
/// The order here matters, more specific entries should be first.
static DOCS_FALLBACK: &[(&str, &str)] = &[
Copy link
Member

Choose a reason for hiding this comment

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

Just to double check my understanding: this does not make us lose checking that e.g. x86_64-pc-windows-gnu shipped a rust-docs tarball, right? (If I'm reading the old code right, we never had checking of that kind).

It would generally be nice to assert somewhere that the builders we want to fallback are -- e.g., that aarch64-apple-darwin isn't producing a rust-docs tarball. I guess we can chalk that up to my (future) hope for a more general scheme that lets us check which tests/steps ran on which builders (or didn't run).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, there weren't any checks before (except for the oddity that apple-darwin was hard-coded to require it). I added an assert to check that the fallback exists.

("-apple-", "x86_64-apple-darwin"),
("aarch64", "aarch64-unknown-linux-gnu"),
("arm-", "aarch64-unknown-linux-gnu"),
("", "x86_64-unknown-linux-gnu"),
];

static MSI_INSTALLERS: &[&str] = &[
Expand Down Expand Up @@ -301,23 +303,27 @@ impl Builder {
}

fn add_packages_to(&mut self, manifest: &mut Manifest) {
let mut package = |name, targets| self.package(name, &mut manifest.pkg, targets);
package("rustc", HOSTS);
package("rustc-dev", HOSTS);
package("reproducible-artifacts", HOSTS);
package("rustc-docs", HOSTS);
package("cargo", HOSTS);
package("rust-mingw", MINGW);
package("rust-std", TARGETS);
package("rust-docs", DOCS_TARGETS);
package("rust-src", &["*"]);
package("rls-preview", HOSTS);
package("rust-analyzer-preview", HOSTS);
package("clippy-preview", HOSTS);
package("miri-preview", HOSTS);
package("rustfmt-preview", HOSTS);
package("rust-analysis", TARGETS);
package("llvm-tools-preview", TARGETS);
macro_rules! package {
($name:expr, $targets:expr) => {
self.package($name, &mut manifest.pkg, $targets, &[])
};
}
package!("rustc", HOSTS);
package!("rustc-dev", HOSTS);
package!("reproducible-artifacts", HOSTS);
package!("rustc-docs", HOSTS);
package!("cargo", HOSTS);
package!("rust-mingw", MINGW);
package!("rust-std", TARGETS);
self.package("rust-docs", &mut manifest.pkg, HOSTS, DOCS_FALLBACK);
package!("rust-src", &["*"]);
package!("rls-preview", HOSTS);
package!("rust-analyzer-preview", HOSTS);
package!("clippy-preview", HOSTS);
package!("miri-preview", HOSTS);
package!("rustfmt-preview", HOSTS);
package!("rust-analysis", TARGETS);
package!("llvm-tools-preview", TARGETS);
}

fn add_artifacts_to(&mut self, manifest: &mut Manifest) {
Expand Down Expand Up @@ -500,7 +506,13 @@ impl Builder {
.extend(pkgs.iter().map(|s| (*s).to_owned()));
}

fn package(&mut self, pkgname: &str, dst: &mut BTreeMap<String, Package>, targets: &[&str]) {
fn package(
&mut self,
pkgname: &str,
dst: &mut BTreeMap<String, Package>,
targets: &[&str],
fallback: &[(&str, &str)],
) {
let version_info = self
.versions
.version(&PkgType::from_component(pkgname))
Expand All @@ -512,16 +524,32 @@ impl Builder {
is_present = false; // Pretend the component is entirely missing.
}

macro_rules! tarball_name {
($target_name:expr) => {
self.versions.tarball_name(&PkgType::from_component(pkgname), $target_name).unwrap()
};
}
let mut target_from_compressed_tar = |target_name| {
let target = Target::from_compressed_tar(self, &tarball_name!(target_name));
if target.available {
return target;
}
for (substr, fallback_target) in fallback {
if target_name.contains(substr) {
let t = Target::from_compressed_tar(self, &tarball_name!(fallback_target));
// Fallbacks must always be available.
assert!(t.available);
return t;
}
}
Target::unavailable()
};

let targets = targets
.iter()
.map(|name| {
let target = if is_present {
let filename = self
.versions
.tarball_name(&PkgType::from_component(pkgname), name)
.unwrap();

Target::from_compressed_tar(self, &filename)
target_from_compressed_tar(name)
} else {
// If the component is not present for this build add it anyway but mark it as
// unavailable -- this way rustup won't allow upgrades without --force
Expand Down
8 changes: 2 additions & 6 deletions src/tools/build-manifest/src/versions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ impl Versions {
}

pub(crate) fn archive_name(
&mut self,
&self,
package: &PkgType,
target: &str,
extension: &str,
Expand All @@ -189,11 +189,7 @@ impl Versions {
}
}

pub(crate) fn tarball_name(
&mut self,
package: &PkgType,
target: &str,
) -> Result<String, Error> {
pub(crate) fn tarball_name(&self, package: &PkgType, target: &str) -> Result<String, Error> {
self.archive_name(package, target, "tar.gz")
}

Expand Down