From 227d85956b205a60a9fa7b269854f0da0653da29 Mon Sep 17 00:00:00 2001 From: Amy Huang Date: Thu, 12 Sep 2019 22:04:56 +0000 Subject: [PATCH] [COFF] Fix to not add archive name to buffer identifiers when they come from thin archives. Currently lld adds the archive name to MemoryBufferRef identifiers in order to ensure they are unique. For thin archives, since the file name is already unique and we want to keep the original path to the file, don't add the archive name. Differential Revision: https://reviews.llvm.org/D67295 llvm-svn: 371778 --- lld/COFF/Driver.cpp | 5 +++-- lld/test/COFF/thinlto-index-only.ll | 11 +++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp index 882313a1..b445733 100644 --- a/lld/COFF/Driver.cpp +++ b/lld/COFF/Driver.cpp @@ -310,9 +310,10 @@ void LinkerDriver::enqueueArchiveMember(const Archive::Child &c, auto mbOrErr = future->get(); if (mbOrErr.second) reportBufferError(errorCodeToError(mbOrErr.second), childName); + // Pass empty string as archive name so that the original filename is + // used as the buffer identifier. driver->addArchiveBuffer(takeBuffer(std::move(mbOrErr.first)), - toCOFFString(sym), parentName, - /*OffsetInArchive=*/0); + toCOFFString(sym), "", /*OffsetInArchive=*/0); }); } diff --git a/lld/test/COFF/thinlto-index-only.ll b/lld/test/COFF/thinlto-index-only.ll index db41309..996c888 100644 --- a/lld/test/COFF/thinlto-index-only.ll +++ b/lld/test/COFF/thinlto-index-only.ll @@ -41,6 +41,17 @@ ; BACKEND2-NEXT: