Skip to content

Commit bcb093e

Browse files
authored
Rollup merge of #92800 - ehuss:docs-fallback, r=Mark-Simulacrum
Add manifest docs fallback. This adds a fallback so that the rustup manifest will contain the rust-docs component for all hosts. There is a mapping so that the docs that get downloaded are roughly close to the actual host. There inevitably will be things that don't match. Ideally the standard library docs would be the same for every platform (`cfg(doc)` goes a long way towards this), but there are still lots of minor differences. Closes #69525
2 parents dfbb6b2 + c8e6889 commit bcb093e

File tree

6 files changed

+69
-46
lines changed

6 files changed

+69
-46
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ jobs:
320320
- name: dist-aarch64-apple
321321
env:
322322
SCRIPT: "./x.py dist --stage 2"
323-
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"
323+
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"
324324
RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
325325
USE_XCODE_CLANG: 1
326326
MACOSX_DEPLOYMENT_TARGET: 11.0

src/bootstrap/dist.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1483,11 +1483,10 @@ impl Step for Extended {
14831483
};
14841484
prepare("rustc");
14851485
prepare("cargo");
1486-
prepare("rust-docs");
14871486
prepare("rust-std");
14881487
prepare("rust-analysis");
14891488
prepare("clippy");
1490-
for tool in &["rust-demangler", "rls", "rust-analyzer", "miri"] {
1489+
for tool in &["rust-docs", "rust-demangler", "rls", "rust-analyzer", "miri"] {
14911490
if built_tools.contains(tool) {
14921491
prepare(tool);
14931492
}

src/ci/github-actions/ci.yml

+1
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,7 @@ jobs:
496496
--enable-full-tools
497497
--enable-sanitizers
498498
--enable-profiler
499+
--disable-docs
499500
--set rust.jemalloc
500501
--set llvm.ninja=false
501502
RUSTC_RETRY_LINKER_ON_SEGFAULT: 1

src/tools/build-manifest/README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ Then, you can generate the manifest and all the packages from `path/to/dist` to
2020
`path/to/output` with:
2121

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

2726
Remember to replace `CHANNEL` with the channel you produced dist artifacts of

src/tools/build-manifest/src/main.rs

+63-35
Original file line numberDiff line numberDiff line change
@@ -155,17 +155,19 @@ static TARGETS: &[&str] = &[
155155
"x86_64-unknown-hermit",
156156
];
157157

158-
static DOCS_TARGETS: &[&str] = &[
159-
"aarch64-unknown-linux-gnu",
160-
"i686-apple-darwin",
161-
"i686-pc-windows-gnu",
162-
"i686-pc-windows-msvc",
163-
"i686-unknown-linux-gnu",
164-
"x86_64-apple-darwin",
165-
"x86_64-pc-windows-gnu",
166-
"x86_64-pc-windows-msvc",
167-
"x86_64-unknown-linux-gnu",
168-
"x86_64-unknown-linux-musl",
158+
/// This allows the manifest to contain rust-docs for hosts that don't build
159+
/// docs.
160+
///
161+
/// Tuples of `(host_partial, host_instead)`. If the host does not have the
162+
/// rust-docs component available, then if the host name contains
163+
/// `host_partial`, it will use the docs from `host_instead` instead.
164+
///
165+
/// The order here matters, more specific entries should be first.
166+
static DOCS_FALLBACK: &[(&str, &str)] = &[
167+
("-apple-", "x86_64-apple-darwin"),
168+
("aarch64", "aarch64-unknown-linux-gnu"),
169+
("arm-", "aarch64-unknown-linux-gnu"),
170+
("", "x86_64-unknown-linux-gnu"),
169171
];
170172

171173
static MSI_INSTALLERS: &[&str] = &[
@@ -301,23 +303,27 @@ impl Builder {
301303
}
302304

303305
fn add_packages_to(&mut self, manifest: &mut Manifest) {
304-
let mut package = |name, targets| self.package(name, &mut manifest.pkg, targets);
305-
package("rustc", HOSTS);
306-
package("rustc-dev", HOSTS);
307-
package("reproducible-artifacts", HOSTS);
308-
package("rustc-docs", HOSTS);
309-
package("cargo", HOSTS);
310-
package("rust-mingw", MINGW);
311-
package("rust-std", TARGETS);
312-
package("rust-docs", DOCS_TARGETS);
313-
package("rust-src", &["*"]);
314-
package("rls-preview", HOSTS);
315-
package("rust-analyzer-preview", HOSTS);
316-
package("clippy-preview", HOSTS);
317-
package("miri-preview", HOSTS);
318-
package("rustfmt-preview", HOSTS);
319-
package("rust-analysis", TARGETS);
320-
package("llvm-tools-preview", TARGETS);
306+
macro_rules! package {
307+
($name:expr, $targets:expr) => {
308+
self.package($name, &mut manifest.pkg, $targets, &[])
309+
};
310+
}
311+
package!("rustc", HOSTS);
312+
package!("rustc-dev", HOSTS);
313+
package!("reproducible-artifacts", HOSTS);
314+
package!("rustc-docs", HOSTS);
315+
package!("cargo", HOSTS);
316+
package!("rust-mingw", MINGW);
317+
package!("rust-std", TARGETS);
318+
self.package("rust-docs", &mut manifest.pkg, HOSTS, DOCS_FALLBACK);
319+
package!("rust-src", &["*"]);
320+
package!("rls-preview", HOSTS);
321+
package!("rust-analyzer-preview", HOSTS);
322+
package!("clippy-preview", HOSTS);
323+
package!("miri-preview", HOSTS);
324+
package!("rustfmt-preview", HOSTS);
325+
package!("rust-analysis", TARGETS);
326+
package!("llvm-tools-preview", TARGETS);
321327
}
322328

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

503-
fn package(&mut self, pkgname: &str, dst: &mut BTreeMap<String, Package>, targets: &[&str]) {
509+
fn package(
510+
&mut self,
511+
pkgname: &str,
512+
dst: &mut BTreeMap<String, Package>,
513+
targets: &[&str],
514+
fallback: &[(&str, &str)],
515+
) {
504516
let version_info = self
505517
.versions
506518
.version(&PkgType::from_component(pkgname))
@@ -512,16 +524,32 @@ impl Builder {
512524
is_present = false; // Pretend the component is entirely missing.
513525
}
514526

527+
macro_rules! tarball_name {
528+
($target_name:expr) => {
529+
self.versions.tarball_name(&PkgType::from_component(pkgname), $target_name).unwrap()
530+
};
531+
}
532+
let mut target_from_compressed_tar = |target_name| {
533+
let target = Target::from_compressed_tar(self, &tarball_name!(target_name));
534+
if target.available {
535+
return target;
536+
}
537+
for (substr, fallback_target) in fallback {
538+
if target_name.contains(substr) {
539+
let t = Target::from_compressed_tar(self, &tarball_name!(fallback_target));
540+
// Fallbacks must always be available.
541+
assert!(t.available);
542+
return t;
543+
}
544+
}
545+
Target::unavailable()
546+
};
547+
515548
let targets = targets
516549
.iter()
517550
.map(|name| {
518551
let target = if is_present {
519-
let filename = self
520-
.versions
521-
.tarball_name(&PkgType::from_component(pkgname), name)
522-
.unwrap();
523-
524-
Target::from_compressed_tar(self, &filename)
552+
target_from_compressed_tar(name)
525553
} else {
526554
// If the component is not present for this build add it anyway but mark it as
527555
// unavailable -- this way rustup won't allow upgrades without --force

src/tools/build-manifest/src/versions.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ impl Versions {
169169
}
170170

171171
pub(crate) fn archive_name(
172-
&mut self,
172+
&self,
173173
package: &PkgType,
174174
target: &str,
175175
extension: &str,
@@ -189,11 +189,7 @@ impl Versions {
189189
}
190190
}
191191

192-
pub(crate) fn tarball_name(
193-
&mut self,
194-
package: &PkgType,
195-
target: &str,
196-
) -> Result<String, Error> {
192+
pub(crate) fn tarball_name(&self, package: &PkgType, target: &str) -> Result<String, Error> {
197193
self.archive_name(package, target, "tar.gz")
198194
}
199195

0 commit comments

Comments
 (0)