[PATCH] D135014: [lld][ELF] Fix lazy ThinLTO index writing in thin archives

Aiden Grossman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 3 11:11:28 PDT 2022


aidengrossman updated this revision to Diff 464748.
aidengrossman added a comment.

Remove extraneous x86 requirement on regression test.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135014/new/

https://reviews.llvm.org/D135014

Files:
  lld/ELF/LTO.cpp
  lld/test/ELF/lto/thinlto-index-files-thin-archive.ll


Index: lld/test/ELF/lto/thinlto-index-files-thin-archive.ll
===================================================================
--- /dev/null
+++ lld/test/ELF/lto/thinlto-index-files-thin-archive.ll
@@ -0,0 +1,24 @@
+;; Make sure that when we are linking against a thin archive in a different
+;; folder from the object files it references, bitcode files that have
+;; their ThinLTO index files written lazily (because they're not linked
+;; against) have their file paths resolved correctly. Regression test for
+;; #57963 on the issue tracker.
+; RUN: rm -rf %t.dir && mkdir %t.dir && cd %t.dir
+; RUN: mkdir test-folder-1
+; RUN: llvm-as %s -o ./test-folder-1/a.o
+; RUN: llvm-as %p/Inputs/thinlto.ll -o ./test-folder-1/b.o
+; RUN: mkdir test-folder-2
+; RUN: llvm-ar -crT ./test-folder-2/lib.a test-folder-1/a.o test-folder-1/b.o
+; RUN: ld.lld --thinlto-emit-index-files -shared ./test-folder-2/lib.a -o c
+; RUN: ls ./test-folder-2 | FileCheck %s
+
+; CHECK: lib.a(a.o
+; CHECK-NEXT: lib.a(b.o
+
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define void @f() {
+entry:
+  ret void
+}
Index: lld/ELF/LTO.cpp
===================================================================
--- lld/ELF/LTO.cpp
+++ lld/ELF/LTO.cpp
@@ -301,7 +301,8 @@
       continue;
     if (linkedBitCodeFiles.contains(f->getName()))
       continue;
-    std::string path = replaceThinLTOSuffix(getThinLTOOutputFile(f->getName()));
+    std::string path =
+        replaceThinLTOSuffix(getThinLTOOutputFile(f->obj->getName()));
     std::unique_ptr<raw_fd_ostream> os = openFile(path + ".thinlto.bc");
     if (!os)
       continue;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135014.464748.patch
Type: text/x-patch
Size: 1705 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221003/0fd2d51f/attachment.bin>


More information about the llvm-commits mailing list