diff options
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/lib/LTO/LTOCodeGenerator.cpp | 10 | ||||
-rw-r--r-- | llvm/test/LTO/X86/diagnostic-handler-noexit.ll | 4 | ||||
-rw-r--r-- | llvm/tools/lto/lto.cpp | 12 |
3 files changed, 14 insertions, 12 deletions
diff --git a/llvm/lib/LTO/LTOCodeGenerator.cpp b/llvm/lib/LTO/LTOCodeGenerator.cpp index 8dcc53c8033..56240502c02 100644 --- a/llvm/lib/LTO/LTOCodeGenerator.cpp +++ b/llvm/lib/LTO/LTOCodeGenerator.cpp @@ -64,23 +64,17 @@ const char* LTOCodeGenerator::getVersionString() { #endif } -static void handleLTODiagnostic(const DiagnosticInfo &DI) { - DiagnosticPrinterRawOStream DP(errs()); - DI.print(DP); - errs() << "\n"; -} - LTOCodeGenerator::LTOCodeGenerator() : Context(getGlobalContext()), MergedModule(new Module("ld-temp.o", Context)), - IRLinker(MergedModule.get(), handleLTODiagnostic) { + IRLinker(MergedModule.get()) { initializeLTOPasses(); } LTOCodeGenerator::LTOCodeGenerator(std::unique_ptr<LLVMContext> Context) : OwnedContext(std::move(Context)), Context(*OwnedContext), MergedModule(new Module("ld-temp.o", *OwnedContext)), - IRLinker(MergedModule.get(), handleLTODiagnostic) { + IRLinker(MergedModule.get()) { initializeLTOPasses(); } diff --git a/llvm/test/LTO/X86/diagnostic-handler-noexit.ll b/llvm/test/LTO/X86/diagnostic-handler-noexit.ll index be768c900f1..597419ff64f 100644 --- a/llvm/test/LTO/X86/diagnostic-handler-noexit.ll +++ b/llvm/test/LTO/X86/diagnostic-handler-noexit.ll @@ -4,10 +4,10 @@ ; RUN: llvm-as <%s >%t1 ; RUN: llvm-as <%s >%t2 -; RUN: not llvm-lto -o /dev/null %t1 %t2 2>&1 | FileCheck %s +; RUN: not llvm-lto -use-diagnostic-handler -o /dev/null %t1 %t2 2>&1 | FileCheck %s target triple = "x86_64-unknown-linux-gnu" -; CHECK: Linking globals named 'goodboy': symbol multiply defined! +; CHECK: llvm-lto: error: Linking globals named 'goodboy': symbol multiply defined! ; CHECK: llvm-lto{{.*}}: error adding file @goodboy = global i32 3203383023, align 4 ; 0xbeefbeef diff --git a/llvm/tools/lto/lto.cpp b/llvm/tools/lto/lto.cpp index 62675081464..0839a566cc5 100644 --- a/llvm/tools/lto/lto.cpp +++ b/llvm/tools/lto/lto.cpp @@ -85,13 +85,21 @@ static void lto_initialize() { namespace { +static void handleLibLTODiagnostic(lto_codegen_diagnostic_severity_t Severity, + const char *Msg, void *) { + sLastErrorString = Msg; + sLastErrorString += "\n"; +} + // This derived class owns the native object file. This helps implement the // libLTO API semantics, which require that the code generator owns the object // file. struct LibLTOCodeGenerator : LTOCodeGenerator { - LibLTOCodeGenerator() {} + LibLTOCodeGenerator() { + setDiagnosticHandler(handleLibLTODiagnostic, nullptr); } LibLTOCodeGenerator(std::unique_ptr<LLVMContext> Context) - : LTOCodeGenerator(std::move(Context)) {} + : LTOCodeGenerator(std::move(Context)) { + setDiagnosticHandler(handleLibLTODiagnostic, nullptr); } std::unique_ptr<MemoryBuffer> NativeObjectFile; }; |