mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-12 13:55:57 +03:00
Don't output files on LLVM errors. (#4425)
Fix issue where an LLVM error or warning during IR passes (e.g. --fwarn-stack-size) does not abort outputting files. The object file would be added to the cache, and subsequent repeated LDC execution would fetch the object file from the cache, effectively swallowing the error.
This commit is contained in:
parent
29bf2d302c
commit
3e2156fa68
3 changed files with 62 additions and 12 deletions
|
@ -377,15 +377,24 @@ void CodeGenerator::writeMLIRModule(mlir::OwningModuleRef *module,
|
|||
const auto llpath = replaceExtensionWith(mlir_ext, filename);
|
||||
Logger::println("Writting MLIR to %s\n", llpath.c_str());
|
||||
std::error_code errinfo;
|
||||
llvm::raw_fd_ostream aos(llpath, errinfo, llvm::sys::fs::OF_None);
|
||||
llvm::ToolOutputFile aos(llpath, errinfo, llvm::sys::fs::OF_None);
|
||||
|
||||
if (aos.has_error()) {
|
||||
if (aos.os().has_error()) {
|
||||
error(Loc(), "Cannot write MLIR file '%s': %s", llpath.c_str(),
|
||||
errinfo.message().c_str());
|
||||
fatal();
|
||||
}
|
||||
|
||||
// module->print(aos);
|
||||
|
||||
// Terminate upon errors during the LLVM passes.
|
||||
if (global.errors || global.warnings) {
|
||||
Logger::println(
|
||||
"Aborting because of errors/warnings during bitcode LLVM passes");
|
||||
fatal();
|
||||
}
|
||||
|
||||
aos.keep();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue