Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Hash the remapped sysroot instead of the original.
This will help reproducible builds, as the sysroot depends on the
working directory.
  • Loading branch information
Joel Galenson committed Aug 12, 2019
commit e9e45c59a7a5a1ea500fd667a56c0d0ab101365a
11 changes: 9 additions & 2 deletions src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,8 @@ 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],
maybe_sysroot_remapped: Option<PathBuf> [TRACKED],

target_triple: TargetTriple [TRACKED],

Expand Down Expand Up @@ -610,6 +611,7 @@ impl Default for Options {
output_types: OutputTypes(BTreeMap::new()),
search_paths: vec![],
maybe_sysroot: None,
maybe_sysroot_remapped: None,
target_triple: TargetTriple::from_triple(host_triple()),
test: false,
incremental: None,
Expand Down Expand Up @@ -2453,7 +2455,7 @@ pub fn build_session_options_and_crate_config(

let crate_name = matches.opt_str("crate-name");

let remap_path_prefix = matches
let remap_path_prefix: Vec<(PathBuf, PathBuf)> = matches
.opt_strs("remap-path-prefix")
.into_iter()
.map(|remap| {
Expand All @@ -2470,6 +2472,10 @@ pub fn build_session_options_and_crate_config(
})
.collect();

let sysroot_remapped_opt = sysroot_opt
.clone()
.map(|sysroot| FilePathMapping::new(remap_path_prefix.clone()).map_prefix(sysroot).0);

(
Options {
crate_types,
Expand All @@ -2481,6 +2487,7 @@ pub fn build_session_options_and_crate_config(
output_types: OutputTypes(output_types),
search_paths,
maybe_sysroot: sysroot_opt,
maybe_sysroot_remapped: sysroot_remapped_opt,
target_triple,
test,
incremental,
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