Skip to content

Support -Zno-link #9019

Open
Open
@bjorn3

Description

@bjorn3

Describe the problem you are trying to solve
Compilation pipelining can currently compile dependent crates as soon as the crate metadata is written in most cases. This improves cpu utilization for from-scratch builds. It is however not possible to apply pipelining on crates that need to be linked like executables and dylibs as all object files need to be available to link something.

Describe the solution you'd like
Using the -Zno-link option of rustc it is possible to separate the compilation and linking step. This makes it possible to pipeline the compilation and only wait for all crates to be fully compiled once we want to link the final executable. This option was introduced in rust-lang/rust#68487 and fixed in rust-lang/rust#80187 (now with a test to prevent regressions).

Notes
cc rust-lang/rust#64191

To implement this rustc will first need to be invoked with -Zno-link as argument. This will produce all object files and a .rlink file. Once all dependencies are compiled you need to invoke rustc a second time with -Zlink-only as argument and the .rlink file instead of the source file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-linkageArea: linker issues, dylib, cdylib, shared libraries, soC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`PerformanceGotta go fast!S-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions