diff --git a/llvm/lib/LTO/LTOCodeGenerator.cpp b/llvm/lib/LTO/LTOCodeGenerator.cpp index 98ce550c7ddd..ab4f96818804 100644 --- a/llvm/lib/LTO/LTOCodeGenerator.cpp +++ b/llvm/lib/LTO/LTOCodeGenerator.cpp @@ -257,6 +257,8 @@ bool LTOCodeGenerator::compileOptimizedToFile(const char **Name) { bool genResult = compileOptimized(&objFile.os()); objFile.os().close(); if (objFile.os().has_error()) { + Twine ErrMsg = "could not write object file: " + Filename.str(); + emitError(ErrMsg.str()); objFile.os().clear_error(); sys::fs::remove(Twine(Filename)); return false;