Skip to content

Commit 08a5a0a

Browse files
committedAug 20, 2019
[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 llvm-svn: 369445
1 parent a99086d commit 08a5a0a

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed
 

‎lld/COFF/Writer.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,9 @@ void Writer::run() {
628628

629629
writeMapFile(outputSections);
630630

631+
if (errorCount())
632+
return;
633+
631634
ScopedTimer t2(diskCommitTimer);
632635
if (auto e = buffer->commit())
633636
fatal("failed to write the output file: " + toString(std::move(e)));

‎lld/test/COFF/multiple-resource-objs.test

+2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# RUN: llvm-cvtres /out:%t_resource.obj %S/Inputs/resource.res
22
# RUN: llvm-cvtres /out:%t_id.obj %S/Inputs/id.res
3+
# RUN: rm -f %t.exe
34
# RUN: not lld-link /out:%t.exe /dll /noentry %t_id.obj %t_resource.obj 2>&1 | \
45
# RUN: FileCheck --check-prefix=TWOOBJ %s
6+
# RUN: not test -f %t.exe
57

68
TWOOBJ: error: {{.*}}_resource.obj: more than one resource obj file not allowed, already got {{.*}}_id.obj
79

0 commit comments

Comments
 (0)
Please sign in to comment.