[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 14:37:30 PDT 2018
ruiu updated this revision to Diff 145550.
ruiu added a comment.
Herald added a subscriber: eraman.
- flush IndexFile before returning so that the file is not truncated.
https://reviews.llvm.org/D46442
Files:
lld/ELF/Driver.cpp
lld/ELF/LTO.cpp
lld/test/ELF/lto/thinlto.ll
Index: lld/test/ELF/lto/thinlto.ll
===================================================================
--- lld/test/ELF/lto/thinlto.ll
+++ lld/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
Index: lld/ELF/LTO.cpp
===================================================================
--- lld/ELF/LTO.cpp
+++ lld/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/ELF/Driver.cpp
===================================================================
--- lld/ELF/Driver.cpp
+++ lld/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();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46442.145550.patch
Type: text/x-patch
Size: 1956 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180507/1b872b84/attachment.bin>
More information about the llvm-commits
mailing list