[lld] r331690 - Do not call exit() directly from lld.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Mon May 7 15:11:35 PDT 2018
Author: ruiu
Date: Mon May 7 15:11:34 2018
New Revision: 331690
URL: http://llvm.org/viewvc/llvm-project?rev=331690&view=rev
Log:
Do not call exit() directly from lld.
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.
Differential Revision: https://reviews.llvm.org/D46442
Modified:
lld/trunk/ELF/Driver.cpp
lld/trunk/ELF/LTO.cpp
lld/trunk/test/ELF/lto/thinlto.ll
Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=331690&r1=331689&r2=331690&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Mon May 7 15:11:34 2018
@@ -1265,10 +1265,18 @@ template <class ELFT> void LinkerDriver:
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();
Modified: lld/trunk/ELF/LTO.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LTO.cpp?rev=331690&r1=331689&r2=331690&view=diff
==============================================================================
--- lld/trunk/ELF/LTO.cpp (original)
+++ lld/trunk/ELF/LTO.cpp Mon May 7 15:11:34 2018
@@ -282,7 +282,9 @@ std::vector<InputFile *> BitcodeCompiler
// 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)
Modified: lld/trunk/test/ELF/lto/thinlto.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/lto/thinlto.ll?rev=331690&r1=331689&r2=331690&view=diff
==============================================================================
--- lld/trunk/test/ELF/lto/thinlto.ll (original)
+++ lld/trunk/test/ELF/lto/thinlto.ll Mon May 7 15:11:34 2018
@@ -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
More information about the llvm-commits
mailing list