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

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 7 15:15:23 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL331690: Do not call exit() directly from lld. (authored by ruiu, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D46442?vs=145550&id=145561#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46442

Files:
  lld/trunk/ELF/Driver.cpp
  lld/trunk/ELF/LTO.cpp
  lld/trunk/test/ELF/lto/thinlto.ll


Index: lld/trunk/ELF/Driver.cpp
===================================================================
--- lld/trunk/ELF/Driver.cpp
+++ lld/trunk/ELF/Driver.cpp
@@ -1265,10 +1265,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();
 
Index: lld/trunk/ELF/LTO.cpp
===================================================================
--- lld/trunk/ELF/LTO.cpp
+++ lld/trunk/ELF/LTO.cpp
@@ -282,7 +282,9 @@
     // ThinLTO with index only option is required to generate only the index
     // files. After that, we exit from linker and ThinLTO backend runs in a
     // distributed environment.
-    exit(0);
+    if (IndexFile)
+      IndexFile->close();
+    return {};
   }
 
   for (std::unique_ptr<MemoryBuffer> &File : Files)
Index: lld/trunk/test/ELF/lto/thinlto.ll
===================================================================
--- lld/trunk/test/ELF/lto/thinlto.ll
+++ lld/trunk/test/ELF/lto/thinlto.ll
@@ -37,7 +37,7 @@
 ; RUN: rm -f %t4.o.thinlto.bc
 ; RUN: touch %t4.o.thinlto.bc
 ; RUN: chmod 400 %t4.o.thinlto.bc
-; RUN: ld.lld -m elf_x86_64 --plugin-opt=thinlto-index-only -shared %t.o %t4.o -o %t5 2>&1 | FileCheck %s --check-prefix=ERR
+; RUN: not ld.lld -m elf_x86_64 --plugin-opt=thinlto-index-only -shared %t.o %t4.o -o %t5 2>&1 | FileCheck %s --check-prefix=ERR
 ; ERR: cannot open {{.*}}4.o.thinlto.bc: {{P|p}}ermission denied
 
 ; Ensure lld doesn't generates index files when thinlto-index-only is not enabled


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46442.145561.patch
Type: text/x-patch
Size: 2010 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180507/30757321/attachment.bin>


More information about the llvm-commits mailing list