Skip to content
Merged
11 changes: 7 additions & 4 deletions src/bootstrap/src/core/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,12 @@ impl Config {

let mut tar = tar::Archive::new(decompressor);

let is_ci_rustc = dst.ends_with("ci-rustc");

// `compile::Sysroot` needs to know the contents of the `rustc-dev` tarball to avoid adding
// it to the sysroot unless it was explicitly requested. But parsing the 100 MB tarball is slow.
// Cache the entries when we extract it so we only have to read it once.
let mut recorded_entries =
if dst.ends_with("ci-rustc") { recorded_entries(dst, pattern) } else { None };
let mut recorded_entries = if is_ci_rustc { recorded_entries(dst, pattern) } else { None };

for member in t!(tar.entries()) {
let mut member = t!(member);
Expand All @@ -287,10 +288,12 @@ impl Config {
continue;
}
let mut short_path = t!(original_path.strip_prefix(directory_prefix));
if !short_path.starts_with(pattern) {
let is_builder_config = short_path.to_str() == Some("builder-config");

if !short_path.starts_with(pattern) && (is_ci_rustc && !is_builder_config) {
continue;
}
short_path = t!(short_path.strip_prefix(pattern));
short_path = short_path.strip_prefix(pattern).unwrap_or(short_path);
let dst_path = dst.join(short_path);
self.verbose(|| {
println!("extracting {} to {}", original_path.display(), dst.display())
Expand Down