<div dir="ltr">Hi David,<div><br></div><div>Sorry for the late response, I realise I did not reply or comment regarding this fix on the original review for the commit.</div><div>The commit above was made on June 3rd (362407) and reverted shortly after due to the mismatch issue you highlighted. On the 4th I committed a fix (362484) that uses a different call to mismatch that I believe is in c++11:</div><div><br></div><div>template< class InputIt1, class InputIt2 ><br>std::pair<InputIt1,InputIt2><br>    mismatch( InputIt1 first1, InputIt1 last1,<br>              InputIt2 first2 );<br></div><div><br></div><div>I'd appreciate your thoughts on this however and will revert if similar issues still occur.</div><div><br></div><div>Thanks,</div><div><br></div><div>Owen</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jul 8, 2019 at 10:46 PM David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Ping</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jun 3, 2019 at 9:06 AM David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jun 3, 2019 at 8:22 AM Owen Reynolds via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Author: gbreynoo<br>
Date: Mon Jun  3 08:26:07 2019<br>
New Revision: 362407<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=362407&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=362407&view=rev</a><br>
Log:<br>
[llvm-ar] Fix relative thin archive path handling<br>
<br>
This fixes some thin archive relative path issues, paths are shortened where possible and paths are output correctly when using the display table command.<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D59491" rel="noreferrer" target="_blank">https://reviews.llvm.org/D59491</a><br>
<br>
Added:<br>
    llvm/trunk/test/tools/llvm-ar/reduce-thin-path.test<br>
    llvm/trunk/test/tools/llvm-ar/thin-archive.test<br>
Modified:<br>
    llvm/trunk/include/llvm/Object/ArchiveWriter.h<br>
    llvm/trunk/lib/Object/ArchiveWriter.cpp<br>
    llvm/trunk/lib/ToolDrivers/llvm-lib/LibDriver.cpp<br>
    llvm/trunk/test/tools/llvm-objcopy/ELF/archive-unknown-members.test<br>
    llvm/trunk/test/tools/llvm-readobj/thin-archive-paths.test<br>
    llvm/trunk/tools/llvm-ar/llvm-ar.cpp<br>
<br>
Modified: llvm/trunk/include/llvm/Object/ArchiveWriter.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ArchiveWriter.h?rev=362407&r1=362406&r2=362407&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ArchiveWriter.h?rev=362407&r1=362406&r2=362407&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/Object/ArchiveWriter.h (original)<br>
+++ llvm/trunk/include/llvm/Object/ArchiveWriter.h Mon Jun  3 08:26:07 2019<br>
@@ -36,7 +36,7 @@ struct NewArchiveMember {<br>
                                             bool Deterministic);<br>
 };<br>
<br>
-std::string computeArchiveRelativePath(StringRef From, StringRef To);<br>
+Expected<std::string> computeArchiveRelativePath(StringRef From, StringRef To);<br>
<br>
 Error writeArchive(StringRef ArcName, ArrayRef<NewArchiveMember> NewMembers,<br>
                    bool WriteSymtab, object::Archive::Kind Kind,<br>
<br>
Modified: llvm/trunk/lib/Object/ArchiveWriter.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/ArchiveWriter.cpp?rev=362407&r1=362406&r2=362407&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/ArchiveWriter.cpp?rev=362407&r1=362406&r2=362407&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Object/ArchiveWriter.cpp (original)<br>
+++ llvm/trunk/lib/Object/ArchiveWriter.cpp Mon Jun  3 08:26:07 2019<br>
@@ -494,29 +494,46 @@ computeMemberData(raw_ostream &StringTab<br>
 }<br>
<br>
 namespace llvm {<br>
+<br>
+static ErrorOr<SmallString<128>> canonicalizePath(StringRef P) {<br>
+  SmallString<128> Ret = P;<br>
+  std::error_code Err = sys::fs::make_absolute(Ret);<br>
+  if (Err)<br>
+    return Err;<br>
+  sys::path::remove_dots(Ret, /*removedotdot*/ true);<br>
+  return Ret;<br>
+}<br>
+<br>
 // Compute the relative path from From to To.<br>
-std::string computeArchiveRelativePath(StringRef From, StringRef To) {<br>
-  if (sys::path::is_absolute(From) || sys::path::is_absolute(To))<br>
-    return To;<br>
-<br>
-  StringRef DirFrom = sys::path::parent_path(From);<br>
-  auto FromI = sys::path::begin(DirFrom);<br>
-  auto ToI = sys::path::begin(To);<br>
-  while (*FromI == *ToI) {<br>
-    ++FromI;<br>
-    ++ToI;<br>
-  }<br>
+Expected<std::string> computeArchiveRelativePath(StringRef From, StringRef To) {<br>
+  ErrorOr<SmallString<128>> PathToOrErr = canonicalizePath(To);<br>
+  ErrorOr<SmallString<128>> DirFromOrErr = canonicalizePath(From);<br>
+  if (!PathToOrErr || !DirFromOrErr)<br>
+    return errorCodeToError(std::error_code(errno, std::generic_category()));<br>
+<br>
+  const SmallString<128> &PathTo = *PathToOrErr;<br>
+  const SmallString<128> &DirFrom = sys::path::parent_path(*DirFromOrErr);<br>
+<br>
+  // Can't construct a relative path between different roots<br>
+  if (sys::path::root_name(PathTo) != sys::path::root_name(DirFrom))<br>
+    return sys::path::convert_to_slash(PathTo);<br>
+<br>
+  // Skip common prefixes<br>
+  auto FromTo =<br>
+      std::mismatch(sys::path::begin(DirFrom), sys::path::end(DirFrom),<br>
+                    sys::path::begin(PathTo), sys::path::end(PathTo));<br></blockquote><div><br>Looks like std::mismatch isn't in C++11, so cannot/should not be used in LLVM at the moment? Could you revert this patch, or if there's a quick fix (O(minutes)), fix forward?<br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+  auto FromI = FromTo.first;<br>
+  auto ToI = FromTo.second;<br>
<br>
+  // Construct relative path<br>
   SmallString<128> Relative;<br>
   for (auto FromE = sys::path::end(DirFrom); FromI != FromE; ++FromI)<br>
-    sys::path::append(Relative, "..");<br>
+    sys::path::append(Relative, sys::path::Style::posix, "..");<br>
<br>
-  for (auto ToE = sys::path::end(To); ToI != ToE; ++ToI)<br>
-    sys::path::append(Relative, *ToI);<br>
+  for (auto ToE = sys::path::end(PathTo); ToI != ToE; ++ToI)<br>
+    sys::path::append(Relative, sys::path::Style::posix, *ToI);<br>
<br>
-  // Replace backslashes with slashes so that the path is portable between *nix<br>
-  // and Windows.<br>
-  return sys::path::convert_to_slash(Relative);<br>
+  return Relative.str();<br>
 }<br>
<br>
 Error writeArchive(StringRef ArcName, ArrayRef<NewArchiveMember> NewMembers,<br>
<br>
Modified: llvm/trunk/lib/ToolDrivers/llvm-lib/LibDriver.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ToolDrivers/llvm-lib/LibDriver.cpp?rev=362407&r1=362406&r2=362407&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ToolDrivers/llvm-lib/LibDriver.cpp?rev=362407&r1=362406&r2=362407&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/ToolDrivers/llvm-lib/LibDriver.cpp (original)<br>
+++ llvm/trunk/lib/ToolDrivers/llvm-lib/LibDriver.cpp Mon Jun  3 08:26:07 2019<br>
@@ -211,9 +211,14 @@ int llvm::libDriverMain(ArrayRef<const c<br>
   // llvm-lib uses relative paths for both regular and thin archives, unlike<br>
   // standard GNU ar, which only uses relative paths for thin archives and<br>
   // basenames for regular archives.<br>
-  for (NewArchiveMember &Member : Members)<br>
-    Member.MemberName =<br>
-        Saver.save(computeArchiveRelativePath(OutputPath, Member.MemberName));<br>
+  for (NewArchiveMember &Member : Members) {<br>
+    if (sys::path::is_relative(Member.MemberName)) {<br>
+      Expected<std::string> PathOrErr =<br>
+          computeArchiveRelativePath(OutputPath, Member.MemberName);<br>
+      if (PathOrErr)<br>
+        Member.MemberName = Saver.save(*PathOrErr);<br>
+    }<br>
+  }<br>
<br>
   if (Error E =<br>
           writeArchive(OutputPath, Members,<br>
<br>
Added: llvm/trunk/test/tools/llvm-ar/reduce-thin-path.test<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-ar/reduce-thin-path.test?rev=362407&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-ar/reduce-thin-path.test?rev=362407&view=auto</a><br>
==============================================================================<br>
--- llvm/trunk/test/tools/llvm-ar/reduce-thin-path.test (added)<br>
+++ llvm/trunk/test/tools/llvm-ar/reduce-thin-path.test Mon Jun  3 08:26:07 2019<br>
@@ -0,0 +1,10 @@<br>
+RUN: rm -rf %t && mkdir -p %t/foo/bar/<br>
+RUN: mkdir -p %t/baz/<br>
+RUN: yaml2obj %S/Inputs/elf.yaml -o %t/elf.o<br>
+<br>
+RUN: cd %t && llvm-ar rTc %t/baz/<a href="http://internal.ar" rel="noreferrer" target="_blank">internal.ar</a> elf.o<br>
+RUN: cd %t/foo && llvm-ar rTc %t/foo/bar/<a href="http://external.ar" rel="noreferrer" target="_blank">external.ar</a> ../baz/<a href="http://internal.ar" rel="noreferrer" target="_blank">internal.ar</a><br>
+<br>
+RUN: FileCheck -input-file=%t/foo/bar/<a href="http://external.ar" rel="noreferrer" target="_blank">external.ar</a> %s<br>
+<br>
+CHECK: {{^}}../../elf.o/<br>
<br>
Added: llvm/trunk/test/tools/llvm-ar/thin-archive.test<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-ar/thin-archive.test?rev=362407&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-ar/thin-archive.test?rev=362407&view=auto</a><br>
==============================================================================<br>
--- llvm/trunk/test/tools/llvm-ar/thin-archive.test (added)<br>
+++ llvm/trunk/test/tools/llvm-ar/thin-archive.test Mon Jun  3 08:26:07 2019<br>
@@ -0,0 +1,45 @@<br>
+RUN: rm -rf %t && mkdir -p %t/foo/bar/<br>
+<br>
+RUN: yaml2obj %S/Inputs/elf.yaml -o %t/foo/elf.o<br>
+RUN: cp %t/foo/elf.o %t/foo/bar/elf.o<br>
+RUN: cp %t/foo/bar/elf.o %t/delete.o<br>
+<br>
+Test that modules can be added with absolute paths when the archive is created using an absolute path<br>
+<br>
+RUN: llvm-ar rTc %t/<a href="http://absolute-1.ar" rel="noreferrer" target="_blank">absolute-1.ar</a> %t/foo/elf.o %t/delete.o %t/foo/bar/elf.o<br>
+RUN: llvm-ar dT %t/<a href="http://absolute-1.ar" rel="noreferrer" target="_blank">absolute-1.ar</a> delete.o<br>
+<br>
+RUN: FileCheck -input-file=%t/<a href="http://absolute-1.ar" rel="noreferrer" target="_blank">absolute-1.ar</a> --check-prefixes=THIN,CHECK %s -DPATH=%/t/<br>
+RUN: llvm-ar t %t/<a href="http://absolute-1.ar" rel="noreferrer" target="_blank">absolute-1.ar</a> | FileCheck %s -DPATH=%/t/<br>
+<br>
+Test that modules can be added with absolute paths when the archive is created using a relative path<br>
+<br>
+RUN: llvm-ar rTc Output/%basename_t.tmp/<a href="http://absolute-2.ar" rel="noreferrer" target="_blank">absolute-2.ar</a> %t/foo/elf.o %t/delete.o %t/foo/bar/elf.o<br>
+RUN: llvm-ar dT Output/%basename_t.tmp/<a href="http://absolute-2.ar" rel="noreferrer" target="_blank">absolute-2.ar</a> %t/delete.o<br>
+<br>
+RUN: FileCheck -input-file=%t/<a href="http://absolute-2.ar" rel="noreferrer" target="_blank">absolute-2.ar</a> --check-prefixes=THIN,CHECK %s -DPATH=%/t/<br>
+RUN: llvm-ar t %t/<a href="http://absolute-2.ar" rel="noreferrer" target="_blank">absolute-2.ar</a> | FileCheck %s -DPATH=%/t/<br>
+<br>
+These tests must be run in %t/foo. cd %t is included on each line to make debugging this test case easier.<br>
+<br>
+Test that modules can be added with relative paths when the archive is created using a relative path<br>
+<br>
+RUN: cd %t/foo && llvm-ar rTc ../<a href="http://relative-1.ar" rel="noreferrer" target="_blank">relative-1.ar</a> elf.o ../delete.o bar/elf.o<br>
+RUN: cd %t/foo && llvm-ar dT ../<a href="http://relative-1.ar" rel="noreferrer" target="_blank">relative-1.ar</a> delete.o<br>
+<br>
+RUN: FileCheck -input-file=%t/<a href="http://relative-1.ar" rel="noreferrer" target="_blank">relative-1.ar</a> --check-prefixes=THIN,CHECK %s -DPATH=<br>
+RUN: llvm-ar t %t/<a href="http://relative-1.ar" rel="noreferrer" target="_blank">relative-1.ar</a> | FileCheck %s -DPATH=%/t/<br>
+<br>
+Test that modules can be added with relative paths when the archive is created using a absolute path<br>
+<br>
+RUN: cd %t/foo && llvm-ar rTc %t/<a href="http://relative-2.ar" rel="noreferrer" target="_blank">relative-2.ar</a> elf.o ../delete.o bar/elf.o<br>
+RUN: cd %t/foo && llvm-ar dT %t/<a href="http://relative-2.ar" rel="noreferrer" target="_blank">relative-2.ar</a> delete.o<br>
+<br>
+RUN: FileCheck -input-file=%t/<a href="http://relative-2.ar" rel="noreferrer" target="_blank">relative-2.ar</a> --check-prefixes=THIN,CHECK %s -DPATH=<br>
+RUN: llvm-ar t %t/<a href="http://relative-2.ar" rel="noreferrer" target="_blank">relative-2.ar</a> | FileCheck %s -DPATH=%/t/<br>
+<br>
+THIN: !<thin><br>
+<br>
+CHECK-NOT: delete.o<br>
+CHECK: {{^}}[[PATH]]foo/elf.o<br>
+CHECK: {{^}}[[PATH]]foo/bar/elf.o<br>
<br>
Modified: llvm/trunk/test/tools/llvm-objcopy/ELF/archive-unknown-members.test<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objcopy/ELF/archive-unknown-members.test?rev=362407&r1=362406&r2=362407&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objcopy/ELF/archive-unknown-members.test?rev=362407&r1=362406&r2=362407&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/tools/llvm-objcopy/ELF/archive-unknown-members.test (original)<br>
+++ llvm/trunk/test/tools/llvm-objcopy/ELF/archive-unknown-members.test Mon Jun  3 08:26:07 2019<br>
@@ -23,10 +23,10 @@<br>
 # RUN: llvm-ar rcT %t.thin1.a %t1.o %s<br>
 # RUN: llvm-ar rcT %t.thin2.a %t2.o %s<br>
<br>
-# RUN: not llvm-objcopy --strip-debug %t.thin1.a 2>&1 \<br>
-# RUN:   | FileCheck %s --check-prefix=THIN -DARCHIVE=%t.thin1.a -DMEMBER=%s<br>
-# RUN: not llvm-strip --strip-debug %t.thin2.a 2>&1 \<br>
-# RUN:   | FileCheck %s --check-prefix=THIN -DARCHIVE=%t.thin2.a -DMEMBER=%s<br>
+# RUN: not llvm-objcopy --strip-debug %/t.thin1.a 2>&1 \<br>
+# RUN:   | FileCheck %s --check-prefix=THIN -DARCHIVE=%/t.thin1.a -DMEMBER=%/s<br>
+# RUN: not llvm-strip --strip-debug %/t.thin2.a 2>&1 \<br>
+# RUN:   | FileCheck %s --check-prefix=THIN -DARCHIVE=%/t.thin2.a -DMEMBER=%/s<br>
 ## Verify that the first member was not modified, if a later member could not<br>
 ## be recognized.<br>
 # RUN: cmp %t.o %t1.o<br>
<br>
Modified: llvm/trunk/test/tools/llvm-readobj/thin-archive-paths.test<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-readobj/thin-archive-paths.test?rev=362407&r1=362406&r2=362407&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-readobj/thin-archive-paths.test?rev=362407&r1=362406&r2=362407&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/tools/llvm-readobj/thin-archive-paths.test (original)<br>
+++ llvm/trunk/test/tools/llvm-readobj/thin-archive-paths.test Mon Jun  3 08:26:07 2019<br>
@@ -23,11 +23,11 @@<br>
 # RUN: llvm-ar rcT c/absolute.a %t/a/b/1.o<br>
<br>
 # Show that absolute paths in the file header printing are correct.<br>
-# RUN: llvm-readobj --file-headers c/absolute.a | FileCheck %s --check-prefix=ABS -DDIR=%t<br>
+# RUN: llvm-readobj --file-headers c/absolute.a | FileCheck %s --check-prefix=ABS -DDIR=%/t<br>
 # ABS: File: [[DIR]]/a/b/1.o<br>
<br>
 # Show that absolute paths in an error message for both archive and member are correct.<br>
 # RUN: rm a/b/1.o<br>
-# RUN: not llvm-readobj --file-headers %t/c/absolute.a 2>&1 | FileCheck %s --check-prefix=ERR2 -DDIR=%t<br>
-# RUN: not llvm-readelf --file-headers %t/c/absolute.a 2>&1 | FileCheck %s --check-prefix=ERR2 -DDIR=%t<br>
+# RUN: not llvm-readobj --file-headers %/t/c/absolute.a 2>&1 | FileCheck %s --check-prefix=ERR2 -DDIR=%/t<br>
+# RUN: not llvm-readelf --file-headers %/t/c/absolute.a 2>&1 | FileCheck %s --check-prefix=ERR2 -DDIR=%/t<br>
 # ERR2: error: '[[DIR]]/c/absolute.a': '[[DIR]]/a/b/1.o': {{[Nn]}}o such file or directory<br>
<br>
Modified: llvm/trunk/tools/llvm-ar/llvm-ar.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-ar/llvm-ar.cpp?rev=362407&r1=362406&r2=362407&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-ar/llvm-ar.cpp?rev=362407&r1=362406&r2=362407&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/tools/llvm-ar/llvm-ar.cpp (original)<br>
+++ llvm/trunk/tools/llvm-ar/llvm-ar.cpp Mon Jun  3 08:26:07 2019<br>
@@ -464,9 +464,11 @@ static void doDisplayTable(StringRef Nam<br>
   }<br>
<br>
   if (C.getParent()->isThin()) {<br>
-    StringRef ParentDir = sys::path::parent_path(ArchiveName);<br>
-    if (!ParentDir.empty())<br>
-      outs() << ParentDir << '/';<br>
+    if (!sys::path::is_absolute(Name)) {<br>
+      StringRef ParentDir = sys::path::parent_path(ArchiveName);<br>
+      if (!ParentDir.empty())<br>
+        outs() << sys::path::convert_to_slash(ParentDir) << '/';<br>
+    }<br>
   }<br>
   outs() << Name << "\n";<br>
 }<br>
@@ -593,10 +595,18 @@ static void addChildMember(std::vector<N<br>
   // the archive it's in, so the file resolves correctly.<br>
   if (Thin && FlattenArchive) {<br>
     StringSaver Saver(Alloc);<br>
-    Expected<std::string> FileNameOrErr = M.getFullName();<br>
+    Expected<std::string> FileNameOrErr = M.getName();<br>
     failIfError(FileNameOrErr.takeError());<br>
-    NMOrErr->MemberName =<br>
-        Saver.save(computeArchiveRelativePath(ArchiveName, *FileNameOrErr));<br>
+    if (sys::path::is_absolute(*FileNameOrErr)) {<br>
+      NMOrErr->MemberName = Saver.save(sys::path::convert_to_slash(*FileNameOrErr));<br>
+    } else {<br>
+      FileNameOrErr = M.getFullName();<br>
+      failIfError(FileNameOrErr.takeError());<br>
+      Expected<std::string> PathOrErr =<br>
+          computeArchiveRelativePath(ArchiveName, *FileNameOrErr);<br>
+      NMOrErr->MemberName = Saver.save(<br>
+          PathOrErr ? *PathOrErr : sys::path::convert_to_slash(*FileNameOrErr));<br>
+    }<br>
   }<br>
   if (FlattenArchive &&<br>
       identify_magic(NMOrErr->Buf->getBuffer()) == file_magic::archive) {<br>
@@ -625,9 +635,19 @@ static void addMember(std::vector<NewArc<br>
   // For regular archives, use the basename of the object path for the member<br>
   // name. For thin archives, use the full relative paths so the file resolves<br>
   // correctly.<br>
-  NMOrErr->MemberName =<br>
-      Thin ? Saver.save(computeArchiveRelativePath(ArchiveName, FileName))<br>
-           : sys::path::filename(NMOrErr->MemberName);<br>
+  if (!Thin) {<br>
+    NMOrErr->MemberName = sys::path::filename(NMOrErr->MemberName);<br>
+  } else {<br>
+    if (sys::path::is_absolute(FileName))<br>
+      NMOrErr->MemberName = Saver.save(sys::path::convert_to_slash(FileName));<br>
+    else {<br>
+      Expected<std::string> PathOrErr =<br>
+          computeArchiveRelativePath(ArchiveName, FileName);<br>
+      NMOrErr->MemberName = Saver.save(<br>
+          PathOrErr ? *PathOrErr : sys::path::convert_to_slash(FileName));<br>
+    }<br>
+  }<br>
+<br>
   if (FlattenArchive &&<br>
       identify_magic(NMOrErr->Buf->getBuffer()) == file_magic::archive) {<br>
     object::Archive &Lib = readLibrary(FileName);<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div></div>
</blockquote></div>
</blockquote></div>