-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
xLTO: Code from standard library does not partake in linker-based LTO (unless compiling with -Clto) #64124
Copy link
Copy link
Open
Labels
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-codegenArea: Code generationArea: Code generationC-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.I-compiletimeIssue: Problems and improvements with respect to compile times.Issue: Problems and improvements with respect to compile times.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-codegenArea: Code generationArea: Code generationC-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.I-compiletimeIssue: Problems and improvements with respect to compile times.Issue: Problems and improvements with respect to compile times.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
xLTO works by emitting LLVM bitcode instead of machine code and then letting the linker run LLVM optimizations (at a point where also code from C/C++ is available for IPO). In the current setup, this means that code from the standard library does not partake in the final LTO step because it is pre-compiled to machine code.
This limitation can be lifted by compiling to a staticlib with
-Cltobecause the fat LTO step thatrustcdoes pulls in the compressed bitcode version of the standard library and then emits the unified bitcode file for further processing by the linker. However, this adds an additional fat LTO step into the compilation pipeline, which is very costly.In theory it should be possible to make
rustcemitlibstdLLVM bitcode into the staticlib instead of the object files (if-Clinker-plugin-ltois specified). The bitcode is available andrustcknows how to decompress it. Then the linker could do its LTO step with the standard library included but without the additional cost.