Skip to content

Commit 60445fd

Browse files
committed
Auto merge of #108534 - Mark-Simulacrum:compression, r=pietroalbini
Import rust-installer & adjust compression settings This brings in rust-lang/rust-installer#123, which enables a larger compression window (8 -> 64MB) amongst other changes to the xz compression settings. The net effect should be smaller compressed tarballs which will decrease bandwidth usage for static.rust-lang.org, download times, and decompression time. This comes at the cost of higher baseline requirements for running rustup to use these files, which we believe should be largely acceptable (running rustc is likely to use at least this much memory) but if we get specific reports we may explore options to decrease impact (e.g., using the gzip tarballs automatically in rustup). To simplify iteration on compression settings this also imports the rust-lang/rust-installer submodule, it is now hosted fully inside rust-lang/rust. Once we land this I'll file a followup to add a note to that repo and we can subsequently archive it. -- CI times for dist-x86_64-linux builds: * threads=6, master - 2h 50m * threads=1, new - 3h 40m * threads=6, new - 2h 50m
2 parents 9b60e6c + dabafb4 commit 60445fd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+4437
-10
lines changed

.gitmodules

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
[submodule "src/rust-installer"]
2-
path = src/tools/rust-installer
3-
url = https://github.com/rust-lang/rust-installer.git
41
[submodule "src/doc/nomicon"]
52
path = src/doc/nomicon
63
url = https://github.com/rust-lang/nomicon.git

src/bootstrap/builder.rs

+1
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,7 @@ impl<'a> Builder<'a> {
711711
test::RustdocUi,
712712
test::RustdocJson,
713713
test::HtmlCheck,
714+
test::RustInstaller,
714715
// Run bootstrap close to the end as it's unlikely to fail
715716
test::Bootstrap,
716717
// Run run-make last, since these won't pass without make on Windows

src/bootstrap/lib.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -482,12 +482,7 @@ impl Build {
482482

483483
// Make sure we update these before gathering metadata so we don't get an error about missing
484484
// Cargo.toml files.
485-
let rust_submodules = [
486-
"src/tools/rust-installer",
487-
"src/tools/cargo",
488-
"library/backtrace",
489-
"library/stdarch",
490-
];
485+
let rust_submodules = ["src/tools/cargo", "library/backtrace", "library/stdarch"];
491486
for s in rust_submodules {
492487
build.update_submodule(Path::new(s));
493488
}

src/bootstrap/test.rs

+55
Original file line numberDiff line numberDiff line change
@@ -2695,3 +2695,58 @@ impl Step for LintDocs {
26952695
});
26962696
}
26972697
}
2698+
2699+
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
2700+
pub struct RustInstaller;
2701+
2702+
impl Step for RustInstaller {
2703+
type Output = ();
2704+
const ONLY_HOSTS: bool = true;
2705+
const DEFAULT: bool = true;
2706+
2707+
/// Ensure the version placeholder replacement tool builds
2708+
fn run(self, builder: &Builder<'_>) {
2709+
builder.info("test rust-installer");
2710+
2711+
let bootstrap_host = builder.config.build;
2712+
let compiler = builder.compiler(0, bootstrap_host);
2713+
let cargo = tool::prepare_tool_cargo(
2714+
builder,
2715+
compiler,
2716+
Mode::ToolBootstrap,
2717+
bootstrap_host,
2718+
"test",
2719+
"src/tools/rust-installer",
2720+
SourceType::InTree,
2721+
&[],
2722+
);
2723+
try_run(builder, &mut cargo.into());
2724+
2725+
// We currently don't support running the test.sh script outside linux(?) environments.
2726+
// Eventually this should likely migrate to #[test]s in rust-installer proper rather than a
2727+
// set of scripts, which will likely allow dropping this if.
2728+
if bootstrap_host != "x86_64-unknown-linux-gnu" {
2729+
return;
2730+
}
2731+
2732+
let mut cmd =
2733+
std::process::Command::new(builder.src.join("src/tools/rust-installer/test.sh"));
2734+
let tmpdir = testdir(builder, compiler.host).join("rust-installer");
2735+
let _ = std::fs::remove_dir_all(&tmpdir);
2736+
let _ = std::fs::create_dir_all(&tmpdir);
2737+
cmd.current_dir(&tmpdir);
2738+
cmd.env("CARGO_TARGET_DIR", tmpdir.join("cargo-target"));
2739+
cmd.env("CARGO", &builder.initial_cargo);
2740+
cmd.env("RUSTC", &builder.initial_rustc);
2741+
cmd.env("TMP_DIR", &tmpdir);
2742+
try_run(builder, &mut cmd);
2743+
}
2744+
2745+
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
2746+
run.path("src/tools/rust-installer")
2747+
}
2748+
2749+
fn make_run(run: RunConfig<'_>) {
2750+
run.builder.ensure(Self);
2751+
}
2752+
}

src/tools/rust-installer

-1
This file was deleted.

src/tools/rust-installer/.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*~
2+
tmp
3+
target/
4+
**/*.rs.bk
5+
Cargo.lock

src/tools/rust-installer/Cargo.toml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[package]
2+
authors = ["The Rust Project Developers"]
3+
name = "installer"
4+
version = "0.0.0"
5+
edition = "2018"
6+
7+
[[bin]]
8+
doc = false
9+
name = "rust-installer"
10+
path = "src/main.rs"
11+
12+
[dependencies]
13+
anyhow = "1.0.19"
14+
flate2 = "1.0.1"
15+
rayon = "1.0"
16+
tar = "0.4.13"
17+
walkdir = "2"
18+
xz2 = "0.1.4"
19+
num_cpus = "1"
20+
remove_dir_all = "0.5"
21+
22+
[dependencies.clap]
23+
features = ["derive"]
24+
version = "3.1"
25+
26+
[target."cfg(windows)".dependencies]
27+
lazy_static = "1"
28+
winapi = { version = "0.3", features = ["errhandlingapi", "handleapi", "ioapiset", "winerror", "winioctl", "winnt"] }

src/tools/rust-installer/README.md

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
[![Build Status](https://travis-ci.org/rust-lang/rust-installer.svg?branch=master)](https://travis-ci.org/rust-lang/rust-installer)
2+
3+
A generator for the install.sh script commonly used to install Rust in
4+
Unix environments. It is used By Rust, Cargo, and is intended to be
5+
used by a future combined installer of Rust + Cargo.
6+
7+
# Usage
8+
9+
```
10+
./gen-installer.sh --product-name=Rust \
11+
--rel-manifest-dir=rustlib \
12+
--success-message=Rust-is-ready-to-roll. \
13+
--image-dir=./install-image \
14+
--work-dir=./temp \
15+
--output-dir=./dist \
16+
--non-installed-overlay=./overlay \
17+
--package-name=rustc-nightly-i686-apple-darwin \
18+
--component-name=rustc \
19+
--legacy-manifest-dirs=rustlib \
20+
--bulk-dirs=share/doc
21+
```
22+
23+
Or, to just generate the script.
24+
25+
```
26+
./gen-install-script.sh --product-name=Rust \
27+
--rel-manifest-dir=rustlib \
28+
--success-message=Rust-is-ready-to-roll. \
29+
--output-script=install.sh \
30+
--legacy-manifest-dirs=rustlib
31+
```
32+
33+
*Note: the dashes in `success-message` are converted to spaces. The
34+
script's argument handling is broken with spaces.*
35+
36+
To combine installers.
37+
38+
```
39+
./combine-installers.sh --product-name=Rust \
40+
--rel-manifest-dir=rustlib \
41+
--success-message=Rust-is-ready-to-roll. \
42+
--work-dir=./temp \
43+
--output-dir=./dist \
44+
--non-installed-overlay=./overlay \
45+
--package-name=rustc-nightly-i686-apple-darwin \
46+
--legacy-manifest-dirs=rustlib \
47+
--input-tarballs=./rustc.tar.gz,cargo.tar.gz
48+
```
49+
50+
# Future work
51+
52+
* Make install.sh not have to be customized, pull it's data from a
53+
config file.
54+
* Be more resiliant to installation failures, particularly if the disk
55+
is full.
56+
* Pre-install and post-uninstall scripts.
57+
* Allow components to depend on or contradict other components.
58+
* Sanity check that expected destination dirs (bin, lib, share exist)?
59+
* Add --docdir flag. Is there a standard name for this?
60+
* Remove empty directories on uninstall.
61+
* Detect mismatches in --prefix, --mandir, etc. in follow-on
62+
installs/uninstalls.
63+
* Fix argument handling for spaces.
64+
* Add --bindir.
65+
66+
# License
67+
68+
This software is distributed under the terms of both the MIT license
69+
and/or the Apache License (Version 2.0), at your option.
70+
71+
See [LICENSE-APACHE](LICENSE-APACHE), [LICENSE-MIT](LICENSE-MIT) for details.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
# Copyright 2014 The Rust Project Developers. See the COPYRIGHT
3+
# file at the top-level directory of this distribution and at
4+
# http://rust-lang.org/COPYRIGHT.
5+
#
6+
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
7+
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
8+
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
9+
# option. This file may not be copied, modified, or distributed
10+
# except according to those terms.
11+
12+
set -ue
13+
14+
# Prints the absolute path of a directory to stdout
15+
abs_path() {
16+
local path="$1"
17+
# Unset CDPATH because it causes havok: it makes the destination unpredictable
18+
# and triggers 'cd' to print the path to stdout. Route `cd`'s output to /dev/null
19+
# for good measure.
20+
(unset CDPATH && cd "$path" > /dev/null && pwd)
21+
}
22+
23+
src_dir="$(abs_path $(dirname "$0"))"
24+
$CARGO run --manifest-path="$src_dir/Cargo.toml" -- combine "$@"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
# Copyright 2014 The Rust Project Developers. See the COPYRIGHT
3+
# file at the top-level directory of this distribution and at
4+
# http://rust-lang.org/COPYRIGHT.
5+
#
6+
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
7+
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
8+
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
9+
# option. This file may not be copied, modified, or distributed
10+
# except according to those terms.
11+
12+
set -ue
13+
14+
# Prints the absolute path of a directory to stdout
15+
abs_path() {
16+
local path="$1"
17+
# Unset CDPATH because it causes havok: it makes the destination unpredictable
18+
# and triggers 'cd' to print the path to stdout. Route `cd`'s output to /dev/null
19+
# for good measure.
20+
(unset CDPATH && cd "$path" > /dev/null && pwd)
21+
}
22+
23+
src_dir="$(abs_path $(dirname "$0"))"
24+
cargo run --manifest-path="$src_dir/Cargo.toml" -- script "$@"
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
# Copyright 2014 The Rust Project Developers. See the COPYRIGHT
3+
# file at the top-level directory of this distribution and at
4+
# http://rust-lang.org/COPYRIGHT.
5+
#
6+
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
7+
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
8+
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
9+
# option. This file may not be copied, modified, or distributed
10+
# except according to those terms.
11+
12+
set -ue
13+
14+
# Prints the absolute path of a directory to stdout
15+
abs_path() {
16+
local path="$1"
17+
# Unset CDPATH because it causes havok: it makes the destination unpredictable
18+
# and triggers 'cd' to print the path to stdout. Route `cd`'s output to /dev/null
19+
# for good measure.
20+
(unset CDPATH && cd "$path" > /dev/null && pwd)
21+
}
22+
23+
src_dir="$(abs_path $(dirname "$0"))"
24+
$CARGO run --manifest-path="$src_dir/Cargo.toml" -- generate "$@"

0 commit comments

Comments
 (0)