non-exiting diagnostic handler for LTO code generator

Gao, Yunzhong via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 8 20:01:26 PDT 2015


Hi Rafael, Duncan, Peter,
With r220732, when calling the Linker::Linker(Module *M) constructor, the default
diagnostic handler is set to use LLVMContext::diagnose(). Linker::Linker(Module *M)
is the constructor called by LTOCodeGenerator::LTOCodeGenerator() constructor. This
change is somewhat problematic for our LTO client, because we use a wrapper
executable to relay communications with the LTO library. LLVMContext::diagnose()
calls exit(1) on errors, which causes the wrapper executable to exit before the
linker gets a chance to do any clean-up. I was wondering whether the
LTOCodeGenerator is now expected to provide a non-exiting diagnostic handler (like
below), and whether/how the other LTO clients are affected (or not). Any advice?
Thanks,
- Gao

diff --git a/llvm/lib/LTO/LTOCodeGenerator.cpp b/llvm/lib/LTO/LTOCodeGenerator.c
index c7a50bc..20ab4a2 100644
--- a/llvm/lib/LTO/LTOCodeGenerator.cpp
+++ b/llvm/lib/LTO/LTOCodeGenerator.cpp
@@ -75,7 +75,12 @@ const char* LTOCodeGenerator::getVersionString() {
}

LTOCodeGenerator::LTOCodeGenerator()
-    : Context(getGlobalContext()), IRLinker(new Module("ld-temp.o", Context)) {
+    : Context(getGlobalContext()), IRLinker(new Module("ld-temp.o", Context),
+       [&](const DiagnosticInfo &DI) {
+         DiagnosticPrinterRawOStream DP(errs());
+         DI.print(DP);
+         errs() << "\n";
+       }) {
   initializeLTOPasses();
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150909/a36427d7/attachment.html>


More information about the llvm-commits mailing list