Skip to content

Move LTO from the codegen coordinator thread to link_binary #908

@bjorn3

Description

@bjorn3

Proposal

I've been working on fixing support for -Zno-link/-Zlink-only, which is supposed to also allow for build pipelining for linked crates (rust-lang/rust#141706). It is currently broken because the dependency_formats are calculated too early during the -Zno-link invocation, which forces all dependencies to be already available as fully compiled artifacts during the -Zno-link invocation rather than only during the -Zlink-only invocation. One of the reasons this is done is because LTO, which needs fully compiled artifacts, currently runs during the -Zno-link invocation. As such fixing -Zno-link/-Zlink-only requires moving LTO to the -Zlink-only invocation. In the process I also discovered that -Zdylib-lto is currently broken when combined with -Cprefer-dynamic and --crate-type staticlib,dylib as in that case both crate types disagree about whether or not LTO has to statically link (and include in LTO) or dynamically link (and exclude from LTO) the standard library. Fixing that requires doing LTO once for each crate type (if the dependency_formats are different between crate types at least), which is easier to do when running LTO inside link_binary.

Implementation steps

Questions

Mentors or Reviewers

If you have a reviewer or mentor in mind for this work, mention them here. You can put your own name here if you are planning to mentor the work.

Process

The main points of the Major Change Process are as follows:

  • File an issue describing the proposal.
  • A compiler team member who is knowledgeable in the area can second by writing @rustbot second or kickoff a team FCP with @rfcbot fcp $RESOLUTION.
  • Once an MCP is seconded, the Final Comment Period begins.
    • Final Comment Period lasts for 10 days after all outstanding concerns are solved.
    • Outstanding concerns will block the Final Comment Period from finishing. Once all concerns are resolved, the 10 day countdown is restarted.
    • If no concerns are raised after 10 days since the resolution of the last outstanding concern, the MCP is considered approved.

You can read more about Major Change Proposals on forge.

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-compilerAdd this label so rfcbot knows to poll the compiler teammajor-changeA proposal to make a major change to rustcmajor-change-acceptedA major change proposal that was accepted

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions