[lld] 1ca6bd2 - [lld] Clean up in lld::{coff,elf}::link after D70378
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 24 18:03:00 PDT 2020
Author: Fangrui Song
Date: 2020-09-24T18:02:45-07:00
New Revision: 1ca6bd261e0aebdd73e3af98fb97c444c2a339cd
URL: https://github.com/llvm/llvm-project/commit/1ca6bd261e0aebdd73e3af98fb97c444c2a339cd
DIFF: https://github.com/llvm/llvm-project/commit/1ca6bd261e0aebdd73e3af98fb97c444c2a339cd.diff
LOG: [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.
Added:
Modified:
lld/COFF/Driver.cpp
lld/ELF/Driver.cpp
Removed:
################################################################################
diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp
index 354ca10582d5..fb496a1c106f 100644
--- a/lld/COFF/Driver.cpp
+++ b/lld/COFF/Driver.cpp
@@ -96,7 +96,10 @@ bool link(ArrayRef<const char *> args, bool canExitEarly, raw_ostream &stdoutOS,
if (canExitEarly)
exitLld(errorCount() ? 1 : 0);
- return !errorCount();
+ bool ret = errorCount() == 0;
+ if (!canExitEarly)
+ errorHandler().reset();
+ return ret;
}
// Parse options of the form "old;new".
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index 9205a1660a6a..8fee30c789ba 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -125,7 +125,10 @@ bool elf::link(ArrayRef<const char *> args, bool canExitEarly,
if (canExitEarly)
exitLld(errorCount() ? 1 : 0);
- return !errorCount();
+ bool ret = errorCount() == 0;
+ if (!canExitEarly)
+ errorHandler().reset();
+ return ret;
}
// Parses a linker -m option.
More information about the llvm-commits
mailing list