-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Support -Zno-link #9019
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
Comments
I am interested in this issue and plan to implement it. Just some questions need to make sure I didn't get it wrong. Below is my understanding of a possible flow. @bjorn3, could you help me check its correctness?
Edit: Wrong. Was too young at that time though. See #9019 (comment). @alexcrichton, since you are the person who implemented pipeline compilation and opened rust-lang/rust#64191, it would be very helpful if you can provide some advice and tips for prototyping. Thanks 😄 |
The first step is to compile all crates, with the crates that need to be linked getting an extra |
This is likely to be a somewhat nontrivial change in Cargo. My best guess for the way to implement this would be to introduce a Pipelining with rlib dependencies is different since we don't invoke rustc twice. Instead we invoke rustc once and only once we've received the message that the rmeta is available do we start executing other units. There's special-casing that handles this (see I suspect functions like |
Take another look of ii a few years after, I now have some doubts upon the benefit to compilation pipeline. For the real world crates, most of the dependencies are rlibs, not any other linkable artifacts. The most common linkable artifacts are bins from build scripts, which can't really be pipelined because their dependents still need to wait for build script executions. Given this, the benefit of splitting compile/link phase is more about configurability and cachability than pipelining. That said, for crates depending on dylibs it does help, but it is a bit rare. |
rustc_driver would benefit significantly from this. It is currently split into rustc_driver and rustc_driver_impl to effectively emulate |
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.The text was updated successfully, but these errors were encountered: