Skip to content

Commit 13bba87

Browse files
authored
Rollup merge of rust-lang#63505 - jgalenson:sysroot-hash, r=alexcrichton
Hash the remapped sysroot instead of the original. One of the reasons that rustc builds are not reproducible is because the --sysroot path is dependent on the current directory. We can fix this by hashing the remapped sysroot instead of the original when applicable. Note that with this patch, the hash will stay the same if both the sysroot and the remapped path change. However, given that if the contents of the sysroot change the hash will also stay the same, this might be acceptable. I would appreciate feedback on the best way to do this. This helps rust-lang#34902, although it does not fix it by itself.
2 parents 4368867 + 692c0bf commit 13bba87

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/librustc/session/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ top_level_options!(
395395
output_types: OutputTypes [TRACKED],
396396
search_paths: Vec<SearchPath> [UNTRACKED],
397397
libs: Vec<(String, Option<String>, Option<cstore::NativeLibraryKind>)> [TRACKED],
398-
maybe_sysroot: Option<PathBuf> [TRACKED],
398+
maybe_sysroot: Option<PathBuf> [UNTRACKED],
399399

400400
target_triple: TargetTriple [TRACKED],
401401

src/test/run-make-fulldeps/reproducible-build-2/Makefile

+11-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
# Objects are reproducible but their path is not.
66

77
all: \
8-
fat_lto
8+
fat_lto \
9+
sysroot
910

1011
fat_lto:
1112
rm -rf $(TMPDIR) && mkdir $(TMPDIR)
@@ -14,3 +15,12 @@ fat_lto:
1415
cp $(TMPDIR)/reproducible-build $(TMPDIR)/reproducible-build-a
1516
$(RUSTC) reproducible-build.rs -C lto=fat
1617
cmp "$(TMPDIR)/reproducible-build-a" "$(TMPDIR)/reproducible-build" || exit 1
18+
19+
sysroot:
20+
rm -rf $(TMPDIR) && mkdir $(TMPDIR)
21+
$(RUSTC) reproducible-build-aux.rs
22+
$(RUSTC) reproducible-build.rs --crate-type rlib --sysroot $(shell $(RUSTC) --print sysroot) --remap-path-prefix=$(shell $(RUSTC) --print sysroot)=/sysroot
23+
cp -r $(shell $(RUSTC) --print sysroot) $(TMPDIR)/sysroot
24+
cp $(TMPDIR)/libreproducible_build.rlib $(TMPDIR)/libfoo.rlib
25+
$(RUSTC) reproducible-build.rs --crate-type rlib --sysroot $(TMPDIR)/sysroot --remap-path-prefix=$(TMPDIR)/sysroot=/sysroot
26+
cmp "$(TMPDIR)/libreproducible_build.rlib" "$(TMPDIR)/libfoo.rlib" || exit 1

0 commit comments

Comments
 (0)