-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Do not store LLVM bitcode in RLIBs by default #66961
Comments
Thanks for writing this up @michaelwoerister! This all sounds spot on to me, and my thoughts on the open questions would be:
I think we have a lot of liberties here to do whatever change we want. It's basically an implementation detail that compressed bitcode is in each rlib, so we basically need to ensure that use cases today continue to work tomorrow. Once we do that I think it's reasonably for us to both switch the defaults and to completely remove all support for compressed llvm bitcode. One unfortunate consequence of this, though, will likely be that we need to default to emitting "fat" object files. For example today you can do:
and that "just works". If we were to omit bitcode entirely it wouldn't work as expected (would either not actually do LTO or would generate an error). So I think that the backwards compatible way to implement this change would be:
Given all that I think we can preserve everyone's use case today, while also switching all users to faster compilations by default. If you're not performing LTO, you never generate bitcode files. If you're performing LTO, you never generate machine code in intermediate rlibs.
I would personally weakly say "no" to be more strict, but I don't feel stringly either way. I feel like though there's not much reason to support this and it's easier to implement an error rather than codegen'ing more object files on the fly.
I do think it's pretty critical to keep LTO working for wasm. This is actually somewhat unfortunate though. In the meantime I think we'll either have to (a) work with LLVM to implement this because wasm does have custom sections, or (b) we'll need to keep logic for including For LTO-ready rlibs on wasm though the |
@michaelwoerister is there a link missing here?
|
@nnethercote's original PR (linked above) has some quite compelling numbers: #66598 (comment) |
…ndling, r=alexcrichton Refactor object file handling Some preliminary clean-ups that grease the path to rust-lang#66961. r? @alexcrichton
…ndling, r=alexcrichton Refactor object file handling Some preliminary clean-ups that grease the path to rust-lang#66961. r? @alexcrichton
#70458 is for the rustc side of things. rust-lang/cargo#8066 is for the Cargo side of things. |
#71323 has landed. |
@nnethercote asked me to write up a more detailed plan for getting rid of LLVM bitcode in RLIBs, so here goes:
Current situation
rustc
canperform cross-crate LTO.
than necessary too (because then machine code is duplicated)
especially obvious because then we have two basically identical LLVM bitcode
files for each module (modulo compression).
bigger because we have to keep object files and bitcode files in the cache.
Proposed Solution
The proposed solution is to follow Clang's model: When compiling for cross-crate
LTO, no machine code is generated and the
.o
file is actually LLVM bitcode.There are special "fat" object files that contain regular machine code and
additionally, in a special section, uncompressed LLVM bitcode. These fat objects
would mainly be used for the standard library.
The consequences of this approach are:
libstd
) would only be eithermachine code or LLVM bitcode.
rustc
needs to know if it is intended to be used forLTO or not. Thus Cargo needs to invoke
rustc
differently.libstd
can partakein LTO steps performed by the LLVM linker plugin.
Open questions
Steps to get there
That actually depends on how we resolve the open questions above.
cc #66598
The text was updated successfully, but these errors were encountered: