[lld] b114e13 - [ELF] Fix --thinlto-index-only regression after D79300
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 9 23:10:38 PDT 2020
Author: Fangrui Song
Date: 2020-06-09T23:10:30-07:00
New Revision: b114e134bdc89fc43aef2ab2d7ff19aca89e5b36
URL: https://github.com/llvm/llvm-project/commit/b114e134bdc89fc43aef2ab2d7ff19aca89e5b36
DIFF: https://github.com/llvm/llvm-project/commit/b114e134bdc89fc43aef2ab2d7ff19aca89e5b36.diff
LOG: [ELF] Fix --thinlto-index-only regression after D79300
After D79300, we don't rewrite InputFile::mb to an empty buffer.
In thinLTOCreateEmptyIndexFiles(), we should check LazyObjFile::fetched
as well as checking whether mb is a bitcode, otherwise we would overwrite (path + .thinlto.bc) with an empty index.
Added:
Modified:
lld/ELF/LTO.cpp
lld/test/ELF/lto/thinlto-index-only.ll
Removed:
################################################################################
diff --git a/lld/ELF/LTO.cpp b/lld/ELF/LTO.cpp
index 56bf5b48f81a..1f1c21764bc0 100644
--- a/lld/ELF/LTO.cpp
+++ b/lld/ELF/LTO.cpp
@@ -255,7 +255,7 @@ void BitcodeCompiler::add(BitcodeFile &f) {
// distributed build system that depends on that behavior.
static void thinLTOCreateEmptyIndexFiles() {
for (LazyObjFile *f : lazyObjFiles) {
- if (!isBitcode(f->mb))
+ if (f->fetched || !isBitcode(f->mb))
continue;
std::string path = replaceThinLTOSuffix(getThinLTOOutputFile(f->getName()));
std::unique_ptr<raw_fd_ostream> os = openFile(path + ".thinlto.bc");
diff --git a/lld/test/ELF/lto/thinlto-index-only.ll b/lld/test/ELF/lto/thinlto-index-only.ll
index cccab1d16eb9..4c3c7e1b1917 100644
--- a/lld/test/ELF/lto/thinlto-index-only.ll
+++ b/lld/test/ELF/lto/thinlto-index-only.ll
@@ -26,7 +26,7 @@
; Ensure lld generates an index even if the file is wrapped in --start-lib/--end-lib
; RUN: rm -f %t2.o.thinlto.bc %t4
; RUN: ld.lld --plugin-opt=thinlto-index-only -shared %t1.o %t3.o --start-lib %t2.o --end-lib -o %t4
-; RUN: ls %t2.o.thinlto.bc
+; RUN: llvm-dis < %t2.o.thinlto.bc | grep -q '\^0 = module:'
; RUN: not test -e %t4
; Test that LLD generates an empty index even for lazy object file that is not added to link.
More information about the llvm-commits
mailing list