Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load only the crate header for locator::crate_matches #111329

Merged
merged 2 commits into from
May 29, 2023

Commits on May 26, 2023

  1. 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
    rust-lang#111329 (comment) for more details about how the
    original crash happened.
    jyn514 committed May 26, 2023
    Configuration menu
    Copy the full SHA
    62314be View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    60e95e7 View commit details
    Browse the repository at this point in the history