[clang] [lld] [llvm] Integrated Distributed ThinLTO (DTLTO): Initial support (PR #126654)

Paul Kirth via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 11 14:00:24 PST 2025


================
@@ -1702,6 +1703,38 @@ static uint8_t getOsAbi(const Triple &t) {
   }
 }
 
+namespace dtlto {
+// Check if an archive file is a thin archive.
+bool isThinArchive(Ctx &ctx, StringRef archiveFilePath) {
+  const size_t thinArchiveMagicLen = sizeof(ThinArchiveMagic) - 1;
+
+  ErrorOr<std::unique_ptr<MemoryBuffer>> memBufferOrError =
+      MemoryBuffer::getFileSlice(archiveFilePath, thinArchiveMagicLen, 0);
+  if (std::error_code ec = memBufferOrError.getError()) {
+    ErrAlways(ctx) << "cannot open " << archiveFilePath << ": " << ec.message();
+    return false;
+  }
+
+  MemoryBufferRef memBufRef = *memBufferOrError.get();
+  return memBufRef.getBuffer().starts_with(ThinArchiveMagic);
+}
+
+// Compute a thin archive member full file path.
+std::string computeFullThinArchiveMemberPath(const StringRef modulePath,
----------------
ilovepi wrote:

Given that we have "Full LTO" and "Thin LTO", I think you may want to rename this to something like `computeThinArchiveMemberFullPath`, to avoid confusion. My first reading of this had me assuming it would handle both Full and Thin LTO somehow before reading the comment.

https://github.com/llvm/llvm-project/pull/126654


More information about the llvm-commits mailing list