remap-cwd-prefix
This commit is contained in:
parent
69c4aa2901
commit
ce35f8ec56
5 changed files with 70 additions and 3 deletions
|
@ -753,6 +753,7 @@ fn test_debugging_options_tracking_hash() {
|
||||||
tracked!(profiler_runtime, "abc".to_string());
|
tracked!(profiler_runtime, "abc".to_string());
|
||||||
tracked!(relax_elf_relocations, Some(true));
|
tracked!(relax_elf_relocations, Some(true));
|
||||||
tracked!(relro_level, Some(RelroLevel::Full));
|
tracked!(relro_level, Some(RelroLevel::Full));
|
||||||
|
tracked!(remap_cwd_prefix, Some(PathBuf::from("abc")));
|
||||||
tracked!(simulate_remapped_rust_src_base, Some(PathBuf::from("/rustc/abc")));
|
tracked!(simulate_remapped_rust_src_base, Some(PathBuf::from("/rustc/abc")));
|
||||||
tracked!(report_delayed_bugs, true);
|
tracked!(report_delayed_bugs, true);
|
||||||
tracked!(sanitizer, SanitizerSet::ADDRESS);
|
tracked!(sanitizer, SanitizerSet::ADDRESS);
|
||||||
|
|
|
@ -1920,9 +1920,10 @@ fn parse_extern_dep_specs(
|
||||||
|
|
||||||
fn parse_remap_path_prefix(
|
fn parse_remap_path_prefix(
|
||||||
matches: &getopts::Matches,
|
matches: &getopts::Matches,
|
||||||
|
debugging_opts: &DebuggingOptions,
|
||||||
error_format: ErrorOutputType,
|
error_format: ErrorOutputType,
|
||||||
) -> Vec<(PathBuf, PathBuf)> {
|
) -> Vec<(PathBuf, PathBuf)> {
|
||||||
matches
|
let mut mapping: Vec<(PathBuf, PathBuf)> = matches
|
||||||
.opt_strs("remap-path-prefix")
|
.opt_strs("remap-path-prefix")
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|remap| match remap.rsplit_once('=') {
|
.map(|remap| match remap.rsplit_once('=') {
|
||||||
|
@ -1932,7 +1933,15 @@ fn parse_remap_path_prefix(
|
||||||
),
|
),
|
||||||
Some((from, to)) => (PathBuf::from(from), PathBuf::from(to)),
|
Some((from, to)) => (PathBuf::from(from), PathBuf::from(to)),
|
||||||
})
|
})
|
||||||
.collect()
|
.collect();
|
||||||
|
match &debugging_opts.remap_cwd_prefix {
|
||||||
|
Some(to) => match std::env::current_dir() {
|
||||||
|
Ok(cwd) => mapping.push((cwd, to.clone())),
|
||||||
|
Err(_) => (),
|
||||||
|
},
|
||||||
|
None => (),
|
||||||
|
};
|
||||||
|
mapping
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn build_session_options(matches: &getopts::Matches) -> Options {
|
pub fn build_session_options(matches: &getopts::Matches) -> Options {
|
||||||
|
@ -2077,7 +2086,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
|
||||||
|
|
||||||
let crate_name = matches.opt_str("crate-name");
|
let crate_name = matches.opt_str("crate-name");
|
||||||
|
|
||||||
let remap_path_prefix = parse_remap_path_prefix(matches, error_format);
|
let remap_path_prefix = parse_remap_path_prefix(matches, &debugging_opts, error_format);
|
||||||
|
|
||||||
let pretty = parse_pretty(&debugging_opts, error_format);
|
let pretty = parse_pretty(&debugging_opts, error_format);
|
||||||
|
|
||||||
|
|
|
@ -1236,6 +1236,8 @@ options! {
|
||||||
"whether ELF relocations can be relaxed"),
|
"whether ELF relocations can be relaxed"),
|
||||||
relro_level: Option<RelroLevel> = (None, parse_relro_level, [TRACKED],
|
relro_level: Option<RelroLevel> = (None, parse_relro_level, [TRACKED],
|
||||||
"choose which RELRO level to use"),
|
"choose which RELRO level to use"),
|
||||||
|
remap_cwd_prefix: Option<PathBuf> = (None, parse_opt_pathbuf, [TRACKED],
|
||||||
|
"remap paths under the current working directory to this path prefix"),
|
||||||
simulate_remapped_rust_src_base: Option<PathBuf> = (None, parse_opt_pathbuf, [TRACKED],
|
simulate_remapped_rust_src_base: Option<PathBuf> = (None, parse_opt_pathbuf, [TRACKED],
|
||||||
"simulate the effect of remap-debuginfo = true at bootstrapping by remapping path \
|
"simulate the effect of remap-debuginfo = true at bootstrapping by remapping path \
|
||||||
to rust's source base directory. only meant for testing purposes"),
|
to rust's source base directory. only meant for testing purposes"),
|
||||||
|
|
|
@ -345,6 +345,19 @@ replacement is purely textual, with no consideration of the current system's
|
||||||
pathname syntax. For example `--remap-path-prefix foo=bar` will match
|
pathname syntax. For example `--remap-path-prefix foo=bar` will match
|
||||||
`foo/lib.rs` but not `./foo/lib.rs`.
|
`foo/lib.rs` but not `./foo/lib.rs`.
|
||||||
|
|
||||||
|
<a id="option-remap-cwd-prefix"></a>
|
||||||
|
## `--remap-cwd-prefix`: remap paths under the cwd in output
|
||||||
|
|
||||||
|
Remap all absolute paths that are rooted under the current working directory to
|
||||||
|
be under the given value instead. The given value may be absolute or relative,
|
||||||
|
or empty. This switch takes precidence over `--remap-path-prefix` in case they
|
||||||
|
would both match a given path.
|
||||||
|
|
||||||
|
This flag allows the command line to be universally reproducible, such that the
|
||||||
|
same execution will work on all machines, regardless of build environment.
|
||||||
|
|
||||||
|
This is an unstable option. Use `-Z remap-cwd-prefix=val` to specify a value.
|
||||||
|
|
||||||
<a id="option-json"></a>
|
<a id="option-json"></a>
|
||||||
## `--json`: configure json messages printed by the compiler
|
## `--json`: configure json messages printed by the compiler
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,9 @@ all: \
|
||||||
link_paths \
|
link_paths \
|
||||||
remap_paths \
|
remap_paths \
|
||||||
different_source_dirs \
|
different_source_dirs \
|
||||||
|
remap_cwd_bin \
|
||||||
|
remap_cwd_rlib \
|
||||||
|
remap_cwd_to_empty \
|
||||||
extern_flags
|
extern_flags
|
||||||
|
|
||||||
smoke:
|
smoke:
|
||||||
|
@ -64,6 +67,45 @@ different_source_dirs:
|
||||||
--crate-type rlib)
|
--crate-type rlib)
|
||||||
cmp "$(TMPDIR)/libreproducible_build.rlib" "$(TMPDIR)/libfoo.rlib" || exit 1
|
cmp "$(TMPDIR)/libreproducible_build.rlib" "$(TMPDIR)/libfoo.rlib" || exit 1
|
||||||
|
|
||||||
|
remap_cwd_bin:
|
||||||
|
rm -rf $(TMPDIR) && mkdir $(TMPDIR)
|
||||||
|
$(RUSTC) reproducible-build-aux.rs
|
||||||
|
mkdir $(TMPDIR)/test
|
||||||
|
cp reproducible-build.rs $(TMPDIR)/test
|
||||||
|
$(RUSTC) reproducible-build.rs --crate-type bin -C debuginfo=2 \
|
||||||
|
-Z remap-cwd-prefix=.
|
||||||
|
cp $(TMPDIR)/reproducible-build $(TMPDIR)/first
|
||||||
|
(cd $(TMPDIR)/test && \
|
||||||
|
$(RUSTC) reproducible-build.rs --crate-type bin -C debuginfo=2 \
|
||||||
|
-Z remap-cwd-prefix=.)
|
||||||
|
cmp "$(TMPDIR)/first" "$(TMPDIR)/reproducible-build" || exit 1
|
||||||
|
|
||||||
|
remap_cwd_rlib:
|
||||||
|
rm -rf $(TMPDIR) && mkdir $(TMPDIR)
|
||||||
|
$(RUSTC) reproducible-build-aux.rs
|
||||||
|
mkdir $(TMPDIR)/test
|
||||||
|
cp reproducible-build.rs $(TMPDIR)/test
|
||||||
|
$(RUSTC) reproducible-build.rs --crate-type rlib -C debuginfo=2 \
|
||||||
|
-Z remap-cwd-prefix=.
|
||||||
|
cp $(TMPDIR)/libreproducible_build.rlib $(TMPDIR)/libfirst.rlib
|
||||||
|
(cd $(TMPDIR)/test && \
|
||||||
|
$(RUSTC) reproducible-build.rs --crate-type rlib -C debuginfo=2 \
|
||||||
|
-Z remap-cwd-prefix=.)
|
||||||
|
cmp "$(TMPDIR)/libfirst.rlib" "$(TMPDIR)/libreproducible_build.rlib" || exit 1
|
||||||
|
|
||||||
|
remap_cwd_to_empty:
|
||||||
|
rm -rf $(TMPDIR) && mkdir $(TMPDIR)
|
||||||
|
$(RUSTC) reproducible-build-aux.rs
|
||||||
|
mkdir $(TMPDIR)/test
|
||||||
|
cp reproducible-build.rs $(TMPDIR)/test
|
||||||
|
$(RUSTC) reproducible-build.rs --crate-type rlib -C debuginfo=2 \
|
||||||
|
-Z remap-cwd-prefix=
|
||||||
|
cp $(TMPDIR)/libreproducible_build.rlib $(TMPDIR)/libfirst.rlib
|
||||||
|
(cd $(TMPDIR)/test && \
|
||||||
|
$(RUSTC) reproducible-build.rs --crate-type rlib -C debuginfo=2 \
|
||||||
|
-Z remap-cwd-prefix=)
|
||||||
|
cmp "$(TMPDIR)/libfirst.rlib" "$(TMPDIR)/libreproducible_build.rlib" || exit 1
|
||||||
|
|
||||||
extern_flags:
|
extern_flags:
|
||||||
rm -rf $(TMPDIR) && mkdir $(TMPDIR)
|
rm -rf $(TMPDIR) && mkdir $(TMPDIR)
|
||||||
$(RUSTC) reproducible-build-aux.rs
|
$(RUSTC) reproducible-build-aux.rs
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue