about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
diff options
context:
space:
mode:
authorjyn <github@jyn.dev>2023-05-21 09:40:00 -0500
committerjyn <github@jyn.dev>2023-05-26 07:44:37 -0500
commit62314be705aee343870f3bc36cb5eb7e89ef6269 (patch)
treee32c283f55fd8a868577f724e3c4d89f329d5c0d /compiler/rustc_codegen_llvm/src
parent0004b3b984b19646c1f78b09ba497b7bd6e882c1 (diff)
downloadrust-62314be705aee343870f3bc36cb5eb7e89ef6269.tar.gz
rust-62314be705aee343870f3bc36cb5eb7e89ef6269.zip
Load only the header for crate_matches
Previously, we used the following info to determine whether to load the crate:
1. The METADATA_HEADER, which includes a METADATA_VERSION constant
2. The embedded rustc version
3. Various metadata in the `CrateRoot`, including the SVH

This worked ok most of the time. Unfortunately, when building locally the rustc version is always
the same because `omit-git-hash` is on by default. That meant that we depended only on 1 and 3, and
we are not very good about bumping METADATA_VERSION (it's currently at 7) so in practice we were
only depending on 3. `CrateRoot` is a very large struct and changes somewhat regularly, so this led
to a steady stream of crashes from trying to load it.

Change the logic to add an intermediate step between 2 and 3: introduce a new `CrateHeader` struct
that contains only the minimum info needed to decide whether the crate should be loaded or not. That
avoids having to load all of `CrateRoot`, which in practice means we should crash much less often.

Note that this works because the SVH should be different between any two dependencies, even if the
compiler has changed, because we use `-Zbinary-dep-depinfo` in bootstrap. See
https://github.com/rust-lang/rust/pull/111329#issuecomment-1538303474 for more details about how the
original crash happened.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
0 files changed, 0 insertions, 0 deletions