[PATCH] D46442: Do not call exit() directly from lld.

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 4 11:15:31 PDT 2018


ruiu created this revision.
ruiu added reviewers: rdhindsa, pcc.
Herald added subscribers: arichardson, emaste.
Herald added a reviewer: espindola.

Our promise is that as long as there's no fatal error (i.e. broken
file is given to the linker), our main function returns to the caller.
So we can't use exit() in the regular code path.


https://reviews.llvm.org/D46442

Files:
  lld/ELF/Driver.cpp
  lld/ELF/LTO.cpp


Index: lld/ELF/LTO.cpp
===================================================================
--- lld/ELF/LTO.cpp
+++ lld/ELF/LTO.cpp
@@ -301,7 +301,7 @@
   // files. After that, we exit from linker and ThinLTO backend runs in a
   // distributed environment.
   if (Config->ThinLTOIndexOnly)
-    exit(0);
+    return {};
 
   for (std::unique_ptr<MemoryBuffer> &File : Files)
     if (File)
Index: lld/ELF/Driver.cpp
===================================================================
--- lld/ELF/Driver.cpp
+++ lld/ELF/Driver.cpp
@@ -1264,10 +1264,18 @@
   for (auto *Arg : Args.filtered(OPT_wrap))
     Symtab->addSymbolWrap<ELFT>(Arg->getValue());
 
+  // Do link-time optimization if given files are LLVM bitcode
+  // files. This compiles bitcode files into real object files.
   Symtab->addCombinedLTOObject<ELFT>();
   if (errorCount())
     return;
 
+  // If -thinlto-index-only is given, we should create only "index
+  // files" and not object files. Index file creation is already done
+  // in addCombinedLTOObject, so we are done if that's the case.
+  if (Config->ThinLTOIndexOnly)
+    return;
+
   // Apply symbol renames for -wrap.
   Symtab->applySymbolWrap();
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46442.145227.patch
Type: text/x-patch
Size: 1181 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180504/307f1c28/attachment.bin>


More information about the llvm-commits mailing list