From ab9691d5b7a22ba6b37a9621a3c66c2626bd38a5 Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Wed, 26 Apr 2017 12:20:21 +0200 Subject: [PATCH] Add some documentation for -Zremap-path-prefix to the unstable book --- src/doc/unstable-book/src/SUMMARY.md | 1 + .../src/compiler-flags/remap-path-prefix.md | 37 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 src/doc/unstable-book/src/compiler-flags/remap-path-prefix.md diff --git a/src/doc/unstable-book/src/SUMMARY.md b/src/doc/unstable-book/src/SUMMARY.md index 2cb3763011218..0d0485dc872d7 100644 --- a/src/doc/unstable-book/src/SUMMARY.md +++ b/src/doc/unstable-book/src/SUMMARY.md @@ -2,6 +2,7 @@ - [Compiler flags](compiler-flags.md) - [linker_flavor](compiler-flags/linker-flavor.md) + - [remap_path_prefix](compiler-flags/remap-path-prefix.md) - [Language features](language-features.md) - [abi_msp430_interrupt](language-features/abi-msp430-interrupt.md) - [abi_ptx](language-features/abi-ptx.md) diff --git a/src/doc/unstable-book/src/compiler-flags/remap-path-prefix.md b/src/doc/unstable-book/src/compiler-flags/remap-path-prefix.md new file mode 100644 index 0000000000000..8ca04d2532592 --- /dev/null +++ b/src/doc/unstable-book/src/compiler-flags/remap-path-prefix.md @@ -0,0 +1,37 @@ +# `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.