@@ -21,7 +21,7 @@ Depending on what you're trying to measure, there are several different approach
21
21
eg. ` cargo -Ztimings build ` .
22
22
You can use this flag on the compiler itself with ` CARGOFLAGS="-Ztimings" ./x.py build `
23
23
24
- ## Optimizing rustc's self-compile- times with cargo-llvm-lines
24
+ ## Optimizing rustc's bootstrap times with ` cargo-llvm-lines `
25
25
26
26
Using [ cargo-llvm-lines] ( https://github.com/dtolnay/cargo-llvm-lines ) you can count the
27
27
number of lines of LLVM IR across all instantiations of a generic function.
@@ -38,8 +38,8 @@ cargo install cargo-llvm-lines
38
38
RUSTFLAGS="--emit=llvm-ir" ./x.py build --stage 0 compiler/rustc
39
39
40
40
# Single crate, eg. rustc_middle
41
- cargo llvm-lines --files ./build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/debug/deps/rustc_middle* > llvm-lines-middle.txt
42
- # Whole compiler at once
41
+ cargo llvm-lines --files ./build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/debug/deps/rustc_middle-a539a639bdab6513.ll > llvm-lines-middle.txt
42
+ # Specify all crates of the compiler. (Relies on the glob support of your shell.)
43
43
cargo llvm-lines --files ./build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/debug/deps/*.ll > llvm-lines.txt
44
44
```
45
45
@@ -72,7 +72,7 @@ you will be compiling rustc _a lot_.
72
72
I recommend changing a few settings in ` config.toml ` to make it bearable:
73
73
```
74
74
[rust]
75
- # A debug build takes _a fourth_ as long on my machine,
75
+ # A debug build takes _a third_ as long on my machine,
76
76
# but compiling more than stage0 rustc becomes unbearably slow.
77
77
optimize = false
78
78
@@ -81,15 +81,14 @@ incremental = false
81
81
# We won't be running it, so no point in compiling debug checks.
82
82
debug = false
83
83
84
- # Caution: This changes the output of llvm-lines.
85
- # Using a single codegen unit gives more accurate output, but is slower to compile.
86
- # Changing it to the number of cores on my machine increased the output
87
- # from 3.5GB to 4.1GB and decreased compile times from 5½ min to 4 min.
88
- codegen-units = 1
89
- #codegen-units = 0 # num_cpus
84
+ # Using a single codegen unit gives less output, but is slower to compile.
85
+ codegen-units = 0 # num_cpus
90
86
```
91
87
92
- What I'm still not sure about is if inlining in MIR optimizations affect llvm-lines.
93
- The output with ` -Zmir-opt-level=0 ` and ` -Zmir-opt-level=1 ` is the same,
94
- but it feels like that some functions that show up at the top should be to small
95
- to have such a high impact. Inlining should only happens in LLVM though.
88
+ The llvm-lines output is affected by several options.
89
+ ` optimize = false ` increases it from 2.1GB to 3.5GB and ` codegen-units = 0 ` to 4.1GB.
90
+
91
+ MIR optimizations have little impact. Compared to the default ` RUSTFLAGS="-Zmir-opt-level=1" ` ,
92
+ level 0 adds 0.3GB and level 2 removes 0.2GB.
93
+ Inlining currently only happens in LLVM, but this might change in the future.
94
+
0 commit comments