Skip to content

Commit 074bbc6

Browse files
committed
Use correct pipeline for LTO at O0
Unlike the pre-link piplines, the LTO pipelines do support O0, and using them is required to avoid leaving behind undefined references for the linker.
1 parent be01f42 commit 074bbc6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,10 @@ LLVMRustOptimizeWithNewPassManager(
10041004
#endif
10051005
bool NeedThinLTOBufferPasses = UseThinLTOBuffers;
10061006
if (!NoPrepopulatePasses) {
1007-
if (OptLevel == OptimizationLevel::O0) {
1007+
// The pre-link pipelines don't support O0 and require using budilO0DefaultPipeline() instead.
1008+
// At the same time, the LTO pipelines do support O0 and using them is required.
1009+
bool IsLTO = OptStage == LLVMRustOptStage::ThinLTO || OptStage == LLVMRustOptStage::FatLTO;
1010+
if (OptLevel == OptimizationLevel::O0 && !IsLTO) {
10081011
#if LLVM_VERSION_GE(12, 0)
10091012
for (const auto &C : PipelineStartEPCallbacks)
10101013
PB.registerPipelineStartEPCallback(C);

0 commit comments

Comments
 (0)