Skip to content

Commit 5de0092

Browse files
committed
Auto merge of #42214 - RalfJung:rust-src, r=alexcrichton
rust-src: include everything needed to compile libstd with jemalloc I am not very happy about all this `Path::new`, but did not find a nice way to avoid it. Also, this shouldn't be very performance-critical. With this patch, rust-src-1.19.0-dev.tar.gz grows from 1.4 to 3.1 MiB (new uncompressed size: 15.5 MiB). Not great, but shipping incomplete sources is also not great, and this is still much smaller than pre-#41546. Excluding the entire `src/jemalloc/test` does not work, unfortunately; there is a file in there that is needed to build libstd. (And anyway there's just 190 KiB uncompressed left in that folder.) In principle, we could try excluding the Rust test suite directories (that would be `libcore/tests` and `libcollection/tests`). I don't know enough about how this component is used to judge whether that would cause any problems. Anyway this is just 600 KiB uncompressed. Fixes #41952
2 parents d78c2b4 + 6620c4b commit 5de0092

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

src/bootstrap/dist.rs

+21-6
Original file line numberDiff line numberDiff line change
@@ -489,8 +489,8 @@ pub fn analysis(build: &Build, compiler: &Compiler, target: &str) {
489489
t!(fs::remove_dir_all(&image));
490490
}
491491

492-
fn copy_src_dirs(build: &Build, src_dirs: &[&str], dst_dir: &Path) {
493-
let filter_fn = move |path: &Path| {
492+
fn copy_src_dirs(build: &Build, src_dirs: &[&str], exclude_dirs: &[&str], dst_dir: &Path) {
493+
fn filter_fn(exclude_dirs: &[&str], dir: &str, path: &Path) -> bool {
494494
let spath = match path.to_str() {
495495
Some(path) => path,
496496
None => return false,
@@ -506,6 +506,11 @@ fn copy_src_dirs(build: &Build, src_dirs: &[&str], dst_dir: &Path) {
506506
}
507507
}
508508

509+
let full_path = Path::new(dir).join(path);
510+
if exclude_dirs.iter().any(|excl| full_path == Path::new(excl)) {
511+
return false;
512+
}
513+
509514
let excludes = [
510515
"CVS", "RCS", "SCCS", ".git", ".gitignore", ".gitmodules",
511516
".gitattributes", ".cvsignore", ".svn", ".arch-ids", "{arch}",
@@ -515,13 +520,13 @@ fn copy_src_dirs(build: &Build, src_dirs: &[&str], dst_dir: &Path) {
515520
!path.iter()
516521
.map(|s| s.to_str().unwrap())
517522
.any(|s| excludes.contains(&s))
518-
};
523+
}
519524

520525
// Copy the directories using our filter
521526
for item in src_dirs {
522527
let dst = &dst_dir.join(item);
523528
t!(fs::create_dir_all(dst));
524-
cp_filtered(&build.src.join(item), dst, &filter_fn);
529+
cp_filtered(&build.src.join(item), dst, &|path| filter_fn(exclude_dirs, item, path));
525530
}
526531
}
527532

@@ -544,6 +549,7 @@ pub fn rust_src(build: &Build) {
544549
"src/liballoc",
545550
"src/liballoc_jemalloc",
546551
"src/liballoc_system",
552+
"src/libbacktrace",
547553
"src/libcollections",
548554
"src/libcompiler_builtins",
549555
"src/libcore",
@@ -559,9 +565,18 @@ pub fn rust_src(build: &Build) {
559565
"src/libstd_unicode",
560566
"src/libunwind",
561567
"src/rustc/libc_shim",
568+
"src/libtest",
569+
"src/libterm",
570+
"src/libgetopts",
571+
"src/compiler-rt",
572+
"src/jemalloc",
573+
];
574+
let std_src_dirs_exclude = [
575+
"src/compiler-rt/test",
576+
"src/jemalloc/test/unit",
562577
];
563578

564-
copy_src_dirs(build, &std_src_dirs[..], &dst_src);
579+
copy_src_dirs(build, &std_src_dirs[..], &std_src_dirs_exclude[..], &dst_src);
565580

566581
// Create source tarball in rust-installer format
567582
let mut cmd = rust_installer(build);
@@ -608,7 +623,7 @@ pub fn plain_source_tarball(build: &Build) {
608623
"src",
609624
];
610625

611-
copy_src_dirs(build, &src_dirs[..], &plain_dst_src);
626+
copy_src_dirs(build, &src_dirs[..], &[], &plain_dst_src);
612627

613628
// Copy the files normally
614629
for item in &src_files {

0 commit comments

Comments
 (0)