aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2019-08-23 12:56:03 +0000
committerHans Wennborg <hans@hanshq.net>2019-08-23 12:56:03 +0000
commita9eab33af4b01008cd496acb0876ebfb1af70ae9 (patch)
tree356fae1b81e331d5f0ce64bf5bd9f64a5d57547c
parent58617997a173cf6c5ffc624e09cdd219a1bf6fd5 (diff)
Merging r369445:
------------------------------------------------------------------------ r369445 | mstorsjo | 2019-08-20 23:08:14 +0200 (Tue, 20 Aug 2019) | 9 lines [COFF] Check errorCount before committing the output file 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. Differential Revision: https://reviews.llvm.org/D66491 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/lld/branches/release_90@369752 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--COFF/Writer.cpp3
-rw-r--r--test/COFF/multiple-resource-objs.test2
2 files changed, 5 insertions, 0 deletions
diff --git a/COFF/Writer.cpp b/COFF/Writer.cpp
index 9bc2f092c..573628195 100644
--- a/COFF/Writer.cpp
+++ b/COFF/Writer.cpp
@@ -626,6 +626,9 @@ void Writer::run() {
writeMapFile(outputSections);
+ if (errorCount())
+ return;
+
ScopedTimer t2(diskCommitTimer);
if (auto e = buffer->commit())
fatal("failed to write the output file: " + toString(std::move(e)));
diff --git a/test/COFF/multiple-resource-objs.test b/test/COFF/multiple-resource-objs.test
index 4263c64be..be5f9a280 100644
--- a/test/COFF/multiple-resource-objs.test
+++ b/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