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

rustc_codegen_llvm: add support for writing summary bitcode #125345

Merged
merged 6 commits into from
May 24, 2024

Commits on May 22, 2024

  1. rustc_codegen_llvm: add support for writing summary bitcode

    Typical uses of ThinLTO don't have any use for this as a standalone
    file, but distributed ThinLTO uses this to make the linker phase more
    efficient. With clang you'd do something like `clang -flto=thin
    -fthin-link-bitcode=foo.indexing.o -c foo.c` and then get both foo.o
    (full of bitcode) and foo.indexing.o (just the summary or index part of
    the bitcode). That's then usable by a two-stage linking process that's
    more friendly to distributed build systems like bazel, which is why I'm
    working on this area.
    
    I talked some to @teresajohnson about naming in this area, as things
    seem to be a little confused between various blog posts and build
    systems. "bitcode index" and "bitcode summary" tend to be a little too
    ambiguous, and she tends to use "thin link bitcode" and "minimized
    bitcode" (which matches the descriptions in LLVM). Since the clang
    option is thin-link-bitcode, I went with that to try and not add a new
    spelling in the world.
    
    Per @dtolnay, you can work around the lack of this by using `lld
    --thinlto-index-only` to do the indexing on regular .o files of
    bitcode, but that is a bit wasteful on actions when we already have all
    the information in rustc and could just write out the matching minimized
    bitcode. I didn't test that at all in our infrastructure, because by the
    time I learned that I already had this patch largely written.
    durin42 committed May 22, 2024
    Configuration menu
    Copy the full SHA
    aa91871 View commit details
    Browse the repository at this point in the history
  2. cleanup: remove leftover extra block

    This was needed in an older version of this patch, but never got edited
    out when it became obsolete.
    durin42 committed May 22, 2024
    Configuration menu
    Copy the full SHA
    03d5556 View commit details
    Browse the repository at this point in the history

Commits on May 23, 2024

  1. thinlto: only build summary file if needed

    If we don't do this, some versions of LLVM (at least 17, experimentally)
    will double-emit some error messages, which is how I noticed this. Given
    that it seems to be costing some extra work, let's only request the
    summary bitcode production if we'll actually bother writing it down,
    otherwise skip it.
    durin42 committed May 23, 2024
    Configuration menu
    Copy the full SHA
    de8200c View commit details
    Browse the repository at this point in the history
  2. cleanup: standardize on summary over index in names

    I did this in the user-facing logic, but I noticed while fixing a minor
    defect that I had missed it in a few places in the internal details.
    durin42 committed May 23, 2024
    Configuration menu
    Copy the full SHA
    3ea4941 View commit details
    Browse the repository at this point in the history
  3. cleanup: run rustfmt

    durin42 committed May 23, 2024
    Configuration menu
    Copy the full SHA
    a0581b5 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    cfe3f77 View commit details
    Browse the repository at this point in the history