Skip to content

Commit

Permalink
Auto merge of #115554 - Kobzol:single-cgu, r=Mark-Simulacrum
Browse files Browse the repository at this point in the history
Build `rustc` with a single CGU on x64 Linux

This PR adds the `rust.codegen-units=1` setting when compiling the 64-bit Linux `rustc` artifact (the one used for try builds and Linux rustup distribution). This had mixed results in the past, however after the bump to LLVM 17, the results now seem pretty [incredible](#115554 (comment)). Instruction counts, cycles, wall time, max RSS and even artifact sizes see large improvements.

The last [try build](https://github.com/rust-lang-ci/rust/actions/runs/6077686494/job/16487768049) with this setting took 1h 8m, which is basically the same duration for try builds that we have seen recently. So there shouldn't be any large hit to CI/build time.

I hope that this could potentially also reduce codegen noise of `rustc` a little bit, since small changes within a single `rustc` crate should no longer perturn optimizations because of CGU movement. We still do cross-crate LTO, so it won't eliminate it though.

r? `@Mark-Simulacrum`
  • Loading branch information
bors committed Sep 10, 2023
2 parents 7418413 + 1bffa88 commit d4cecd0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ ENV RUST_CONFIGURE_ARGS \
--set llvm.ninja=false \
--set rust.jemalloc \
--set rust.use-lld=true \
--set rust.lto=thin
--set rust.lto=thin \
--set rust.codegen-units=1

ENV SCRIPT python3 ../x.py build --set rust.debug=true opt-dist && \
./build/$HOSTS/stage0-tools-bin/opt-dist python3 ../x.py dist \
Expand Down

0 comments on commit d4cecd0

Please sign in to comment.