Skip to content

Commit

Permalink
Rollup merge of rust-lang#63505 - jgalenson:sysroot-hash, r=alexcrichton
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Centril authored Aug 17, 2019
2 parents 477db05 + 692c0bf commit 5e59787
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ top_level_options!(
output_types: OutputTypes [TRACKED],
search_paths: Vec<SearchPath> [UNTRACKED],
libs: Vec<(String, Option<String>, Option<cstore::NativeLibraryKind>)> [TRACKED],
maybe_sysroot: Option<PathBuf> [TRACKED],
maybe_sysroot: Option<PathBuf> [UNTRACKED],

target_triple: TargetTriple [TRACKED],

Expand Down
12 changes: 11 additions & 1 deletion src/test/run-make-fulldeps/reproducible-build-2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
# Objects are reproducible but their path is not.

all: \
fat_lto
fat_lto \
sysroot

fat_lto:
rm -rf $(TMPDIR) && mkdir $(TMPDIR)
Expand All @@ -14,3 +15,12 @@ fat_lto:
cp $(TMPDIR)/reproducible-build $(TMPDIR)/reproducible-build-a
$(RUSTC) reproducible-build.rs -C lto=fat
cmp "$(TMPDIR)/reproducible-build-a" "$(TMPDIR)/reproducible-build" || exit 1

sysroot:
rm -rf $(TMPDIR) && mkdir $(TMPDIR)
$(RUSTC) reproducible-build-aux.rs
$(RUSTC) reproducible-build.rs --crate-type rlib --sysroot $(shell $(RUSTC) --print sysroot) --remap-path-prefix=$(shell $(RUSTC) --print sysroot)=/sysroot
cp -r $(shell $(RUSTC) --print sysroot) $(TMPDIR)/sysroot
cp $(TMPDIR)/libreproducible_build.rlib $(TMPDIR)/libfoo.rlib
$(RUSTC) reproducible-build.rs --crate-type rlib --sysroot $(TMPDIR)/sysroot --remap-path-prefix=$(TMPDIR)/sysroot=/sysroot
cmp "$(TMPDIR)/libreproducible_build.rlib" "$(TMPDIR)/libfoo.rlib" || exit 1

0 comments on commit 5e59787

Please sign in to comment.