Implement --remap-path-prefix

Remove experimental -Zremap-path-prefix-from/to, and replace it with
the stabilized --remap-path-prefix=from=to variant.

This is an implementation for issue of #41555.
This commit is contained in:
Jeremy Fitzhardinge 2018-02-18 15:05:24 -08:00 committed by Jeremy Fitzhardinge
parent b1f8e6fb06
commit 56a6828533
10 changed files with 38 additions and 70 deletions

View file

@ -125,6 +125,16 @@ Print version info and exit.
\fB\-v\fR, \fB\-\-verbose\fR
Use verbose output.
.TP
\fB\-\-remap\-path\-prefix\fR \fIfrom\fR=\fIto\fR
Remap source path prefixes in all output, including compiler diagnostics, debug information,
macro expansions, etc. The \fIfrom\fR=\fIto\fR parameter is scanned from right to left, so \fIfrom\fR
may contain '=', but \fIto\fR may not.
This is useful for normalizing build products, for example by removing the current directory out of
pathnames emitted into the object files. The replacement is purely textual, with no consideration of
the current system's pathname syntax. For example \fI\-\-remap\-path\-prefix foo=bar\fR will
match \fBfoo/lib.rs\fR but not \fB./foo/lib.rs\fR.
.TP
\fB\-\-extern\fR \fINAME\fR=\fIPATH\fR
Specify where an external rust library is located. These should match
\fIextern\fR declarations in the crate's source code.

View file

@ -1,37 +0,0 @@
# `remap-path-prefix`
The tracking issue for this feature is: [#41555](https://github.com/rust-lang/rust/issues/41555)
------------------------
The `-Z remap-path-prefix-from`, `-Z remap-path-prefix-to` commandline option
pair allows to replace prefixes of any file paths the compiler emits in various
places. This is useful for bringing debuginfo paths into a well-known form and
for achieving reproducible builds independent of the directory the compiler was
executed in. All paths emitted by the compiler are affected, including those in
error messages.
In order to map all paths starting with `/home/foo/my-project/src` to
`/sources/my-project`, one would invoke the compiler as follows:
```text
rustc -Zremap-path-prefix-from="/home/foo/my-project/src" -Zremap-path-prefix-to="/sources/my-project"
```
Debuginfo for code from the file `/home/foo/my-project/src/foo/mod.rs`,
for example, would then point debuggers to `/sources/my-project/foo/mod.rs`
instead of the original file.
The options can be specified multiple times when multiple prefixes should be
mapped:
```text
rustc -Zremap-path-prefix-from="/home/foo/my-project/src" \
-Zremap-path-prefix-to="/sources/my-project" \
-Zremap-path-prefix-from="/home/foo/my-project/build-dir" \
-Zremap-path-prefix-to="/stable-build-dir"
```
When the options are given multiple times, the nth `-from` will be matched up
with the nth `-to` and they can appear anywhere on the commandline. Mappings
specified later on the line will take precedence over earlier ones.