summaryrefslogtreecommitdiffstats
path: root/lld/COFF/Driver.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lld/COFF/Driver.cpp')
-rw-r--r--lld/COFF/Driver.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp
index 133cf40a83b..168d99093c5 100644
--- a/lld/COFF/Driver.cpp
+++ b/lld/COFF/Driver.cpp
@@ -54,18 +54,25 @@ BumpPtrAllocator BAlloc;
StringSaver Saver{BAlloc};
std::vector<SpecificAllocBase *> SpecificAllocBase::Instances;
-bool link(ArrayRef<const char *> Args, raw_ostream &Diag) {
+bool link(ArrayRef<const char *> Args, bool CanExitEarly, raw_ostream &Diag) {
ErrorCount = 0;
ErrorOS = &Diag;
Config = make<Configuration>();
Config->Argv = {Args.begin(), Args.end()};
Config->ColorDiagnostics = ErrorOS->has_colors();
+ Config->CanExitEarly = CanExitEarly;
Symtab = make<SymbolTable>();
Driver = make<LinkerDriver>();
Driver->link(Args);
+
+ // Call exit() if we can to avoid calling destructors.
+ if (CanExitEarly)
+ exitLld(ErrorCount ? 1 : 0);
+
+ freeArena();
return !ErrorCount;
}
@@ -1087,7 +1094,7 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
if (!Args.hasArg(OPT_INPUT)) {
fixupExports();
createImportLibrary(/*AsLib=*/true);
- exit(0);
+ return;
}
// Handle /delayload
@@ -1179,7 +1186,7 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
// This is useful because MSVC link.exe can generate complete PDBs.
if (Args.hasArg(OPT_msvclto)) {
invokeMSVC(Args);
- exit(0);
+ return;
}
// Do LTO by compiling bitcode input files to a set of native COFF files then
@@ -1273,12 +1280,6 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
// Write the result.
writeResult();
-
- if (ErrorCount)
- return;
-
- // Call exit to avoid calling destructors.
- exit(0);
}
} // namespace coff
OpenPOWER on IntegriCloud