@@ -274,13 +274,13 @@ void LinkerDriver::addBuffer(std::unique_ptr<MemoryBuffer> mb,
274
274
make<std::unique_ptr<Archive>>(std::move (file)); // take ownership
275
275
276
276
int memberIndex = 0 ;
277
- for (MemoryBufferRef m : getArchiveMembers (ctx, archive))
277
+ for (MemoryBufferRef m : getArchiveMembers (ctx, archive)) {
278
278
if (!archive->isThin ())
279
279
addArchiveBuffer (m, " <whole-archive>" , filename, memberIndex++);
280
280
else
281
- // Pass empty string as archive name so that the original filename is
282
- // used as the buffer identifier.
283
- addArchiveBuffer (m, " <whole-archive> " , " " , /* OffsetInArchive= */ 0 );
281
+ addThinArchiveBuffer (m, " <whole- archive> " );
282
+ }
283
+
284
284
return ;
285
285
}
286
286
addFile (make<ArchiveFile>(ctx, mbref));
@@ -391,6 +391,16 @@ void LinkerDriver::addArchiveBuffer(MemoryBufferRef mb, StringRef symName,
391
391
Log (ctx) << " Loaded " << obj << " for " << symName;
392
392
}
393
393
394
+ void LinkerDriver::addThinArchiveBuffer (MemoryBufferRef mb, StringRef symName) {
395
+ // Pass an empty string as the archive name and an offset of 0 so that
396
+ // the original filename is used as the buffer identifier. This
397
+ // ensures the naming of thin archive members is consistent with the
398
+ // non-`whole-archive` path, and is useful for DTLTO, where having the
399
+ // member identifier be the actual path on disk enables distribution
400
+ // of bitcode files during ThinLTO.
401
+ addArchiveBuffer (mb, symName, /* parentName=*/ " " , /* OffsetInArchive=*/ 0 );
402
+ }
403
+
394
404
void LinkerDriver::enqueueArchiveMember (const Archive::Child &c,
395
405
const Archive::Symbol &sym,
396
406
StringRef parentName) {
@@ -427,11 +437,8 @@ void LinkerDriver::enqueueArchiveMember(const Archive::Child &c,
427
437
reportBufferError (errorCodeToError (mbOrErr.second ), childName);
428
438
llvm::TimeTraceScope timeScope (" Archive: " ,
429
439
mbOrErr.first ->getBufferIdentifier ());
430
- // Pass empty string as archive name so that the original filename is
431
- // used as the buffer identifier.
432
- ctx.driver .addArchiveBuffer (takeBuffer (std::move (mbOrErr.first )),
433
- toCOFFString (ctx, sym), " " ,
434
- /* OffsetInArchive=*/ 0 );
440
+ ctx.driver .addThinArchiveBuffer (takeBuffer (std::move (mbOrErr.first )),
441
+ toCOFFString (ctx, sym));
435
442
});
436
443
}
437
444
0 commit comments