-
Notifications
You must be signed in to change notification settings - Fork 12.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #41508 - michaelwoerister:generic-path-remapping, r=ale…
…xcrichton Implement a file-path remapping feature in support of debuginfo and reproducible builds This PR adds the `-Zremap-path-prefix-from`/`-Zremap-path-prefix-to` commandline option pair and is a more general implementation of #41419. As opposed to the previous attempt, this implementation should enable reproducible builds regardless of the working directory of the compiler. This implementation of the feature is more general in the sense that the re-mapping will affect *all* paths the compiler emits, including the ones in error messages. r? @alexcrichton
- Loading branch information
Showing
37 changed files
with
547 additions
and
313 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/doc/unstable-book/src/compiler-flags/remap-path-prefix.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.