[PATCH] D66491: [COFF] Check errorCount before committing the output file

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 20 12:18:29 PDT 2019


mstorsjo created this revision.
mstorsjo added reviewers: ruiu, rnk, thakis.
Herald added a project: LLVM.

This avoids producing an output file if errors appeared late in the linking process (e.g. while fixing relocations, or as in the test, while checking for multiple resources). If an output file is produced, build tools might not retry building it on rebuilds, even if a previous build failed due to the error return code.


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D66491

Files:
  COFF/Writer.cpp
  test/COFF/multiple-resource-objs.test


Index: test/COFF/multiple-resource-objs.test
===================================================================
--- test/COFF/multiple-resource-objs.test
+++ test/COFF/multiple-resource-objs.test
@@ -1,7 +1,9 @@
 # RUN: llvm-cvtres /out:%t_resource.obj %S/Inputs/resource.res
 # RUN: llvm-cvtres /out:%t_id.obj %S/Inputs/id.res
+# RUN: rm -f %t.exe
 # RUN: not lld-link /out:%t.exe /dll /noentry %t_id.obj %t_resource.obj 2>&1 | \
 # RUN:     FileCheck --check-prefix=TWOOBJ %s
+# RUN: not test -f %t.exe
 
 TWOOBJ: error: {{.*}}_resource.obj: more than one resource obj file not allowed, already got {{.*}}_id.obj
 
Index: COFF/Writer.cpp
===================================================================
--- COFF/Writer.cpp
+++ COFF/Writer.cpp
@@ -628,6 +628,9 @@
 
   writeMapFile(outputSections);
 
+  if (errorCount())
+    return;
+
   ScopedTimer t2(diskCommitTimer);
   if (auto e = buffer->commit())
     fatal("failed to write the output file: " + toString(std::move(e)));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66491.216210.patch
Type: text/x-patch
Size: 986 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190820/ab4cbff6/attachment.bin>


More information about the llvm-commits mailing list