]> git.lizzy.rs Git - rust.git/commit
Change how compiler-builtins gets many CGUs
authorAlex Crichton <alex@alexcrichton.com>
Mon, 8 Jun 2020 16:02:57 +0000 (09:02 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Mon, 15 Jun 2020 14:38:00 +0000 (07:38 -0700)
commitd6156e8fe5619143c687983d3ffa5b7ccc37c77e
tree9b886b0382603b67f4a966c22b5d5a91b48af10f
parent73558160933b2764ed9a84b1b2b647e128eac3f8
Change how compiler-builtins gets many CGUs

This commit intends to fix an accidental regression from #70846. The
goal of #70846 was to build compiler-builtins with a maximal number of
CGUs to ensure that each module in the source corresponds to an object
file. This high degree of control for compiler-builtins is desirable to
ensure that there's at most one exported symbol per CGU, ideally
enabling compiler-builtins to not conflict with the system libgcc as
often.

In #70846, however, only part of the compiler understands that
compiler-builtins is built with many CGUs. The rest of the compiler
thinks it's building with `sess.codegen_units()`. Notably the
calculation of `sess.lto()` consults `sess.codegen_units()`, which when
there's only one CGU it disables ThinLTO. This means that
compiler-builtins is built without ThinLTO, which is quite harmful to
performance! This is the root of the cause from #73135 where intrinsics
were found to not be inlining trivial functions.

The fix applied in this commit is to remove the special-casing of
compiler-builtins in the compiler. Instead the build system is now
responsible for special-casing compiler-builtins. It doesn't know
exactly how many CGUs will be needed but it passes a large number that
is assumed to be much greater than the number of source-level modules
needed. After reading the various locations in the compiler source, this
seemed like the best solution rather than adding more and more special
casing in the compiler for compiler-builtins.

Closes #73135
Cargo.toml
src/librustc_mir/monomorphize/partitioning.rs
src/test/codegen-units/partitioning/compiler-builtins.rs [deleted file]