@@ -22,7 +22,7 @@ lto = "thin"
22
22
23
23
> Note that LTO for ` rustc ` is currently supported and tested only for
24
24
> the ` x86_64-unknown-linux-gnu ` target. Other targets * may* work, but no guarantees are provided.
25
- > Notably, LTO optimized ` rustc ` currently produces [ miscompilations] on Windows.
25
+ > Notably, LTO- optimized ` rustc ` currently produces [ miscompilations] on Windows.
26
26
27
27
[ miscompilations ] : https://github.com/rust-lang/rust/issues/109114
28
28
@@ -63,7 +63,7 @@ compile `rustc` for a specific instruction set architecture, you can set the `ta
63
63
option in ` RUSTFLAGS ` :
64
64
65
65
``` bash
66
- $ RUSTFLAGS=" -C target_cpu=x86-64-v3" x.py build ...
66
+ RUSTFLAGS=" -C target_cpu=x86-64-v3" ./x build ...
67
67
```
68
68
69
69
If you also want to compile LLVM for a specific instruction set, you can set ` llvm ` flags
@@ -78,9 +78,9 @@ cflags = "-march=x86-64-v3"
78
78
## Profile-guided optimization
79
79
80
80
Applying profile-guided optimizations (or more generally, feedback-directed optimizations) can
81
- produce a large increase to ` rustc ` performance, by up to 25% . However, these techniques are not
82
- simply enabled by a configuration option, but rather they require a complex build workflow that
83
- compiles ` rustc ` multiple times and profiles it on selected benchmarks.
81
+ produce a large increase to ` rustc ` performance, by up to 15% ( [ 1 ] , [ 2 ] ) . However, these techniques
82
+ are not simply enabled by a configuration option, but rather they require a complex build workflow
83
+ that compiles ` rustc ` multiple times and profiles it on selected benchmarks.
84
84
85
85
There is a tool called ` opt-dist ` that is used to optimize ` rustc ` with [ PGO] (profile-guided
86
86
optimizations) and [ BOLT] (a post-link binary optimizer) for builds distributed to end users. You
@@ -89,6 +89,9 @@ workflow based on it, or try to use it directly. Note that the tool is currently
89
89
the way we use it in Rust's continuous integration workflows, and it might require some custom
90
90
changes to make it work in a different environment.
91
91
92
+ [ 1 ] : https://blog.rust-lang.org/inside-rust/2020/11/11/exploring-pgo-for-the-rust-compiler.html#final-numbers-and-a-benchmarking-plot-twist
93
+ [ 2 ] : https://github.com/rust-lang/rust/pull/96978
94
+
92
95
[ PGO ] : https://doc.rust-lang.org/rustc/profile-guided-optimization.html
93
96
94
97
[ BOLT ] : https://github.com/llvm/llvm-project/blob/main/bolt/README.md
@@ -112,11 +115,11 @@ you execute the following commands on a Linux system):
112
115
113
116
1 . Build the tool with the following command:
114
117
``` bash
115
- $ python3 x.py build tools/opt-dist
118
+ ./x build tools/opt-dist
116
119
```
117
120
2. Run the tool with the ` PGO_HOST` environment variable set to the 64-bit Linux target:
118
121
` ` ` bash
119
- $ PGO_HOST=x86_64-unknown-linux-gnu ./build/host/stage0-tools-bin/opt-dist
122
+ PGO_HOST=x86_64-unknown-linux-gnu ./build/host/stage0-tools-bin/opt-dist
120
123
` ` `
121
124
Note that the default Linux environment expects several hardcoded paths to exist:
122
125
- ` /checkout` should contain a checkout of the Rust compiler repository that will be compiled.
@@ -126,6 +129,6 @@ you execute the following commands on a Linux system):
126
129
127
130
You can modify ` LinuxEnvironment` (or implement your own) to override these paths.
128
131
129
- [` Environment` ]: https://github.com/rust-lang/rust/blob/65e468f9c259749c210b1ae8972bfe14781f72f1/src/tools/opt-dist/src/environment/mod.rs#L8-L7
132
+ [` Environment` ]: https://github.com/rust-lang/rust/blob/65e468f9c259749c210b1ae8972bfe14781f72f1/src/tools/opt-dist/src/environment/mod.rs#L8-L70
130
133
131
134
[Rust benchmark suite]: https://github.com/rust-lang/rustc-perf
0 commit comments