diff --git a/src/bin/sccache-dist/build.rs b/src/bin/sccache-dist/build.rs index bfd7a980e5..2f3ad2c4b3 100644 --- a/src/bin/sccache-dist/build.rs +++ b/src/bin/sccache-dist/build.rs @@ -190,7 +190,12 @@ impl OverlayBuilder { entry.clone() } else { trace!("Creating toolchain directory for {}", tc.archive_id); - fs::create_dir(&toolchain_dir)?; + // The directory can persist on disk from a previous server + // process (or a toolchain evicted from the in-memory map + // without its directory). Treat it as already-prepared. + if !toolchain_dir.exists() { + fs::create_dir(&toolchain_dir)?; + } let mut tccache = tccache.lock().unwrap(); let toolchain_rdr = match tccache.get(tc) { diff --git a/src/compiler/rust.rs b/src/compiler/rust.rs index 779e9dd79e..fd93c2c32d 100644 --- a/src/compiler/rust.rs +++ b/src/compiler/rust.rs @@ -2285,10 +2285,18 @@ impl pkg::ToolchainPackager for RustToolchainPackager { let sysroot_executable = bins_path.join("rustc").with_extension(EXE_EXTENSION); package_builder.add_executable_and_deps(sysroot_executable)?; - package_builder.add_dir_contents(&bins_path)?; + // Package the Rust standard library subtree instead of the entire + // sysroot lib directory. Distros like Void Linux report `/usr` as the + // sysroot, so packaging `$sysroot/lib` would drag in the whole system + // library tree (several GiB) rather than just the Rust stdlib. if BINS_DIR != LIBS_DIR { let libs_path = sysroot.join(LIBS_DIR); - package_builder.add_dir_contents(&libs_path)?; + let rustlib_path = libs_path.join("rustlib"); + if rustlib_path.is_dir() { + package_builder.add_dir_contents(&rustlib_path)?; + } else { + package_builder.add_dir_contents(&libs_path)?; + } } package_builder.into_compressed_tar(f)