[lld] Clean up in lld::{coff,elf}::link after D70378

Library users should not need to call errorHandler().reset() explicitly.

google/iree calls lld:🧝:link and without the patch some global
variables are not cleaned up in the next invocation.
This commit is contained in:
Fangrui Song 2020-09-24 18:01:26 -07:00
parent 92106641ae
commit 1ca6bd261e
2 changed files with 8 additions and 2 deletions

View File

@ -96,7 +96,10 @@ bool link(ArrayRef<const char *> args, bool canExitEarly, raw_ostream &stdoutOS,
if (canExitEarly) if (canExitEarly)
exitLld(errorCount() ? 1 : 0); exitLld(errorCount() ? 1 : 0);
return !errorCount(); bool ret = errorCount() == 0;
if (!canExitEarly)
errorHandler().reset();
return ret;
} }
// Parse options of the form "old;new". // Parse options of the form "old;new".

View File

@ -125,7 +125,10 @@ bool elf::link(ArrayRef<const char *> args, bool canExitEarly,
if (canExitEarly) if (canExitEarly)
exitLld(errorCount() ? 1 : 0); exitLld(errorCount() ? 1 : 0);
return !errorCount(); bool ret = errorCount() == 0;
if (!canExitEarly)
errorHandler().reset();
return ret;
} }
// Parses a linker -m option. // Parses a linker -m option.