Index: lib/LTO/LTOModule.cpp =================================================================== --- lib/LTO/LTOModule.cpp +++ lib/LTO/LTOModule.cpp @@ -105,8 +105,10 @@ TargetOptions options) { ErrorOr> BufferOrErr = MemoryBuffer::getFile(path); - if (std::error_code EC = BufferOrErr.getError()) + if (std::error_code EC = BufferOrErr.getError()) { + Context.emitError(EC.message()); return EC; + } std::unique_ptr Buffer = std::move(BufferOrErr.get()); return makeLTOModule(Buffer->getMemBufferRef(), options, &Context); } @@ -123,8 +125,10 @@ off_t offset, TargetOptions options) { ErrorOr> BufferOrErr = MemoryBuffer::getOpenFileSlice(fd, path, map_size, offset); - if (std::error_code EC = BufferOrErr.getError()) + if (std::error_code EC = BufferOrErr.getError()) { + Context.emitError(EC.message()); return EC; + } std::unique_ptr Buffer = std::move(BufferOrErr.get()); return makeLTOModule(Buffer->getMemBufferRef(), options, &Context); } @@ -158,8 +162,10 @@ // Find the buffer. ErrorOr MBOrErr = IRObjectFile::findBitcodeInMemBuffer(Buffer); - if (std::error_code EC = MBOrErr.getError()) + if (std::error_code EC = MBOrErr.getError()) { + Context.emitError(EC.message()); return EC; + } if (!ShouldBeLazy) { // Parse the full file. Index: tools/lto/lto.cpp =================================================================== --- tools/lto/lto.cpp +++ tools/lto/lto.cpp @@ -81,7 +81,6 @@ DiagnosticPrinterRawOStream DP(Stream); DI.print(DP); } - sLastErrorString += '\n'; } // Initialize the configured targets if they have not been initialized. @@ -111,7 +110,6 @@ 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