Skip to content

Commit 1ca6bd2

Browse files
committed
[lld] Clean up in lld::{coff,elf}::link after D70378
Library users should not need to call errorHandler().reset() explicitly. google/iree calls lld::elf::link and without the patch some global variables are not cleaned up in the next invocation.
1 parent 9210664 commit 1ca6bd2

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

lld/COFF/Driver.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,10 @@ bool link(ArrayRef<const char *> args, bool canExitEarly, raw_ostream &stdoutOS,
9696
if (canExitEarly)
9797
exitLld(errorCount() ? 1 : 0);
9898

99-
return !errorCount();
99+
bool ret = errorCount() == 0;
100+
if (!canExitEarly)
101+
errorHandler().reset();
102+
return ret;
100103
}
101104

102105
// Parse options of the form "old;new".

lld/ELF/Driver.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,10 @@ bool elf::link(ArrayRef<const char *> args, bool canExitEarly,
125125
if (canExitEarly)
126126
exitLld(errorCount() ? 1 : 0);
127127

128-
return !errorCount();
128+
bool ret = errorCount() == 0;
129+
if (!canExitEarly)
130+
errorHandler().reset();
131+
return ret;
129132
}
130133

131134
// Parses a linker -m option.

0 commit comments

Comments
 (0)