From 1b5f85615a3391b9c7abb749e4c4599815a47b55 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Thu, 13 Jan 2022 11:40:44 -0500 Subject: [PATCH] Disable lto on modules with dll exports (lld-link bug) --- IDEHelper/Compiler/BfIRCodeGen.cpp | 5 +++++ IDEHelper/Compiler/BfIRCodeGen.h | 1 + 2 files changed, 6 insertions(+) diff --git a/IDEHelper/Compiler/BfIRCodeGen.cpp b/IDEHelper/Compiler/BfIRCodeGen.cpp index 393d992a..d92a6c8c 100644 --- a/IDEHelper/Compiler/BfIRCodeGen.cpp +++ b/IDEHelper/Compiler/BfIRCodeGen.cpp @@ -352,6 +352,7 @@ BfIRCodeGen::BfIRCodeGen() mLLVMContext = new llvm::LLVMContext(); mLLVMModule = NULL; mIsCodeView = false; + mHadDLLExport = false; mConstValIdx = 0; mCmdCount = 0; @@ -3794,6 +3795,7 @@ void BfIRCodeGen::HandleNextCmd() else if (attribute == BFIRAttribute_DllExport) { func->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass); + mHadDLLExport = true; } else if (attribute == BFIRAttribute_NoFramePointerElim) { @@ -5314,6 +5316,9 @@ bool BfIRCodeGen::WriteObjectFile(const StringImpl& outFileName) { enableLTO = false; } + + if (mHadDLLExport) // LTO bug in LLVM-link? + enableLTO = false; } std::error_code EC; diff --git a/IDEHelper/Compiler/BfIRCodeGen.h b/IDEHelper/Compiler/BfIRCodeGen.h index 7cd3868f..ad474f4d 100644 --- a/IDEHelper/Compiler/BfIRCodeGen.h +++ b/IDEHelper/Compiler/BfIRCodeGen.h @@ -106,6 +106,7 @@ public: BfCodeGenOptions mCodeGenOptions; bool mHasDebugLoc; bool mIsCodeView; + bool mHadDLLExport; int mConstValIdx; int mCmdCount;