Index: include/llvm/Object/ArchiveWriter.h =================================================================== --- include/llvm/Object/ArchiveWriter.h +++ include/llvm/Object/ArchiveWriter.h @@ -25,6 +25,7 @@ sys::TimePoint ModTime; unsigned UID = 0, GID = 0, Perms = 0644; + bool IsNew = false; NewArchiveMember() = default; NewArchiveMember(MemoryBufferRef BufRef); Index: lib/Object/ArchiveWriter.cpp =================================================================== --- lib/Object/ArchiveWriter.cpp +++ lib/Object/ArchiveWriter.cpp @@ -45,6 +45,7 @@ return BufOrErr.takeError(); NewArchiveMember M; + assert(M.IsNew == false); M.Buf = MemoryBuffer::getMemBuffer(*BufOrErr, false); if (!Deterministic) { auto ModTimeOrErr = OldMember.getLastModified(); @@ -93,6 +94,7 @@ return errorCodeToError(std::error_code(errno, std::generic_category())); NewArchiveMember M; + M.IsNew = true; M.Buf = std::move(*MemberBufferOrErr); if (!Deterministic) { M.ModTime = std::chrono::time_point_cast( @@ -231,9 +233,12 @@ } StringMapIndexes.push_back(Out.tell() - StartOffset); - if (Thin) - Out << computeRelativePath(ArcName, Path); - else + if (Thin) { + if (M.IsNew) + Out << computeRelativePath(ArcName, Path); + else + Out << M.Buf->getBufferIdentifier(); + } else Out << Name; Out << "/\n"; Index: test/Object/archive-thin-create.test =================================================================== --- /dev/null +++ test/Object/archive-thin-create.test @@ -0,0 +1,13 @@ +RUN: mkdir -p %t +RUN: cd %t +RUN: mkdir -p foo +RUN: touch foo/test1.o +RUN: touch foo/test2.o +RUN: llvm-ar qcT foo/libtest.a foo/test1.o +RUN: llvm-ar qcT foo/libtest.a foo/test1.o +RUN: llvm-ar qcT foo/libtest.a foo/test2.o +RUN: llvm-ar t foo/libtest.a | FileCheck %s + +CHECK: test1.o +CHECK: test1.o +CHECK: test2.o \ No newline at end of file