Skip to content

Enable ThinLTO and incremental compilation #48996

Closed
@alexcrichton

Description

@alexcrichton

Currently ThinLTO is not compatible with incremental compilation, unfortunately. This is due to the fact that the codegen of an object file is actually dependent on all object files rather than just the one object file, which means we can rarely reuse anything!

ThinLTO, however, is explicitly designed with incrementality in mind. We're just not currently taking advantage of any of it! Last I remember checking in on this there's a good bit of nontrivial work that the incremental ThinLTO requires. Currently the ThinLTO support in rustc is largely a duplicate of that file (so far a duplicate of what we need) which helps us conform to our own requirements and integration better. This would likely best be implemented by tweaking the upstream interfaces to be more what we in rustc desire so we can directly use LLVM's support in this regard.

In any case, I realized we didn't have a tracking issue for this so I wanted to open one! At a high level I'd expect this to be tackled by:

  • Create a separate query/codepath in codegen which only emits bytecode, not object files (aka the optimization passes for one module)
  • When ThinLTO is enabled with incremental compilation we use this query instead of the previous "give me all the object files" query.
  • After all bytecode is loaded/optimized, we then transition to the ThinLTO-owned incremental phase. This'd probably reserve a special directory in the normal incremental directory for exclusive ownership by ThinLTO itself.
  • Once the ThinLTO passes have finished we've now got a bunch of object files so we can proceed as usual

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-incr-compArea: Incremental compilationC-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions