[llvm] r288280 - Only computeRelativePath() on new members
David Callahan via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 30 14:32:58 PST 2016
Author: david2050
Date: Wed Nov 30 16:32:58 2016
New Revision: 288280
URL: http://llvm.org/viewvc/llvm-project?rev=288280&view=rev
Log:
Only computeRelativePath() on new members
Summary:
When using thin archives, and processing the same archive multiple times, we were mangling existing entries. The root cause is that we were calling computeRelativePath() more than once. Here, we only call it when adding new members to an archive.
Note that D27218 changes the way thin archives are printed, and will break the new unit test included here. Depending on which one lands first, the other will need to be slightly modified.
Reviewers: rafael, davide
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D27217
Added:
llvm/trunk/test/Object/archive-thin-create.test
Modified:
llvm/trunk/include/llvm/Object/ArchiveWriter.h
llvm/trunk/lib/Object/ArchiveWriter.cpp
Modified: llvm/trunk/include/llvm/Object/ArchiveWriter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ArchiveWriter.h?rev=288280&r1=288279&r2=288280&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ArchiveWriter.h (original)
+++ llvm/trunk/include/llvm/Object/ArchiveWriter.h Wed Nov 30 16:32:58 2016
@@ -25,6 +25,7 @@ struct NewArchiveMember {
sys::TimePoint<std::chrono::seconds> ModTime;
unsigned UID = 0, GID = 0, Perms = 0644;
+ bool IsNew = false;
NewArchiveMember() = default;
NewArchiveMember(MemoryBufferRef BufRef);
Modified: llvm/trunk/lib/Object/ArchiveWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/ArchiveWriter.cpp?rev=288280&r1=288279&r2=288280&view=diff
==============================================================================
--- llvm/trunk/lib/Object/ArchiveWriter.cpp (original)
+++ llvm/trunk/lib/Object/ArchiveWriter.cpp Wed Nov 30 16:32:58 2016
@@ -45,6 +45,7 @@ NewArchiveMember::getOldMember(const obj
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 @@ Expected<NewArchiveMember> NewArchiveMem
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<std::chrono::seconds>(
@@ -231,9 +233,12 @@ static void writeStringTable(raw_fd_ostr
}
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";
Added: llvm/trunk/test/Object/archive-thin-create.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/archive-thin-create.test?rev=288280&view=auto
==============================================================================
--- llvm/trunk/test/Object/archive-thin-create.test (added)
+++ llvm/trunk/test/Object/archive-thin-create.test Wed Nov 30 16:32:58 2016
@@ -0,0 +1,14 @@
+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
+
More information about the llvm-commits
mailing list