Skip to content

Commit f0073a5

Browse files
committed
Auto merge of #80435 - pietroalbini:compression-formats, r=Mark-Simulacrum
Only produce .xz tarballs on CI This PR adds a `./configure` option to choose which tarball compression formats to produce, and changes our CI configuration to only produce `.xz` tarballs. The release process will then recompress everything into `.gz` when producing a release. This will drastically reduce our storage costs for CI artifacts, as we'd stop storing the same data twice. **Stable, beta and nightly releases will not be affected by this at all.** Before landing this we'll need to increase the VM size of our release process, to recompress everything in a reasonable amount of time. r? `@Mark-Simulacrum`
2 parents 9775ffe + 5526d90 commit f0073a5

File tree

7 files changed

+34
-7
lines changed

7 files changed

+34
-7
lines changed

config.toml.example

+4
Original file line numberDiff line numberDiff line change
@@ -669,3 +669,7 @@ changelog-seen = 2
669669

670670
# Whether to allow failures when building tools
671671
#missing-tools = false
672+
673+
# List of compression formats to use when generating dist tarballs. The list of
674+
# formats is provided to rust-installer, which must support all of them.
675+
#compression-formats = ["gz", "xz"]

src/bootstrap/config.rs

+3
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ pub struct Config {
148148
pub dist_sign_folder: Option<PathBuf>,
149149
pub dist_upload_addr: Option<String>,
150150
pub dist_gpg_password_file: Option<PathBuf>,
151+
pub dist_compression_formats: Option<Vec<String>>,
151152

152153
// libstd features
153154
pub backtrace: bool, // support for RUST_BACKTRACE
@@ -438,6 +439,7 @@ struct Dist {
438439
upload_addr: Option<String>,
439440
src_tarball: Option<bool>,
440441
missing_tools: Option<bool>,
442+
compression_formats: Option<Vec<String>>,
441443
}
442444

443445
#[derive(Deserialize)]
@@ -936,6 +938,7 @@ impl Config {
936938
config.dist_sign_folder = t.sign_folder.map(PathBuf::from);
937939
config.dist_gpg_password_file = t.gpg_password_file.map(PathBuf::from);
938940
config.dist_upload_addr = t.upload_addr;
941+
config.dist_compression_formats = t.compression_formats;
939942
set(&mut config.rust_dist_src, t.src_tarball);
940943
set(&mut config.missing_tools, t.missing_tools);
941944
}

src/bootstrap/configure.py

+4
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ def v(*args):
147147
"experimental LLVM targets to build")
148148
v("release-channel", "rust.channel", "the name of the release channel to build")
149149
v("release-description", "rust.description", "optional descriptive string for version output")
150+
v("dist-compression-formats", None,
151+
"comma-separated list of compression formats to use")
150152

151153
# Used on systems where "cc" is unavailable
152154
v("default-linker", "rust.default-linker", "the default linker")
@@ -349,6 +351,8 @@ def set(key, value):
349351
elif option.name == 'option-checking':
350352
# this was handled above
351353
pass
354+
elif option.name == 'dist-compression-formats':
355+
set('dist.compression-formats', value.split(','))
352356
else:
353357
raise RuntimeError("unhandled option {}".format(option.name))
354358

src/bootstrap/tarball.rs

+15-1
Original file line numberDiff line numberDiff line change
@@ -294,11 +294,25 @@ impl<'a> Tarball<'a> {
294294

295295
build_cli(&self, &mut cmd);
296296
cmd.arg("--work-dir").arg(&self.temp_dir);
297+
if let Some(formats) = &self.builder.config.dist_compression_formats {
298+
assert!(!formats.is_empty(), "dist.compression-formats can't be empty");
299+
cmd.arg("--compression-formats").arg(formats.join(","));
300+
}
297301
self.builder.run(&mut cmd);
298302
if self.delete_temp_dir {
299303
t!(std::fs::remove_dir_all(&self.temp_dir));
300304
}
301305

302-
crate::dist::distdir(self.builder).join(format!("{}.tar.gz", package_name))
306+
// Use either the first compression format defined, or "gz" as the default.
307+
let ext = self
308+
.builder
309+
.config
310+
.dist_compression_formats
311+
.as_ref()
312+
.and_then(|formats| formats.get(0))
313+
.map(|s| s.as_str())
314+
.unwrap_or("gz");
315+
316+
crate::dist::distdir(self.builder).join(format!("{}.tar.{}", package_name, ext))
303317
}
304318
}

src/bootstrap/test.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -1962,7 +1962,7 @@ impl Step for Distcheck {
19621962
builder.ensure(dist::Src);
19631963

19641964
let mut cmd = Command::new("tar");
1965-
cmd.arg("-xzf")
1965+
cmd.arg("-xf")
19661966
.arg(builder.ensure(dist::PlainSourceTarball))
19671967
.arg("--strip-components=1")
19681968
.current_dir(&dir);
@@ -1986,10 +1986,7 @@ impl Step for Distcheck {
19861986
t!(fs::create_dir_all(&dir));
19871987

19881988
let mut cmd = Command::new("tar");
1989-
cmd.arg("-xzf")
1990-
.arg(builder.ensure(dist::Src))
1991-
.arg("--strip-components=1")
1992-
.current_dir(&dir);
1989+
cmd.arg("-xf").arg(builder.ensure(dist::Src)).arg("--strip-components=1").current_dir(&dir);
19931990
builder.run(&mut cmd);
19941991

19951992
let toml = dir.join("rust-src/lib/rustlib/src/rust/library/std/Cargo.toml");

src/ci/run.sh

+5
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-locked-deps"
5353
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-cargo-native-static"
5454
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.codegen-units-std=1"
5555

56+
# Only produce xz tarballs on CI. gz tarballs will be generated by the release
57+
# process by recompressing the existing xz ones. This decreases the storage
58+
# space required for CI artifacts.
59+
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --dist-compression-formats=xz"
60+
5661
if [ "$DIST_SRC" = "" ]; then
5762
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-dist-src"
5863
fi

0 commit comments

Comments
 (0)