[PATCH] D26696: Object: replace backslashes with slashes in embedded relative thin archive paths on Windows.

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 15 13:24:33 PST 2016


pcc created this revision.
pcc added reviewers: ruiu, rafael.
pcc added a subscriber: llvm-commits.

This makes these thin archives portable between *nix and Windows.


https://reviews.llvm.org/D26696

Files:
  llvm/lib/Object/ArchiveWriter.cpp
  llvm/test/Object/archive-thin-paths.test


Index: llvm/test/Object/archive-thin-paths.test
===================================================================
--- /dev/null
+++ llvm/test/Object/archive-thin-paths.test
@@ -0,0 +1,9 @@
+REQUIRES: system-windows
+
+RUN: cd %T
+RUN: mkdir -p archive-thin-paths.dir
+RUN: echo foo > archive-thin-paths.dir/foo.o
+
+RUN: rm -f archive-thin-paths.a
+RUN: llvm-ar rcsT archive-thin-paths.a archive-thin-paths.dir\foo.o
+RUN: grep archive-thin-paths.dir/foo.o archive-thin-paths.a
Index: llvm/lib/Object/ArchiveWriter.cpp
===================================================================
--- llvm/lib/Object/ArchiveWriter.cpp
+++ llvm/lib/Object/ArchiveWriter.cpp
@@ -205,6 +205,12 @@
   for (auto ToE = sys::path::end(To); ToI != ToE; ++ToI)
     sys::path::append(Relative, *ToI);
 
+#ifdef LLVM_ON_WIN32
+  // Replace backslashes with slashes so that the path is portable between *nix
+  // and Windows.
+  std::replace(Relative.begin(), Relative.end(), '\\', '/');
+#endif
+
   return Relative.str();
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26696.78063.patch
Type: text/x-patch
Size: 1011 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161115/ccfd1b77/attachment.bin>


More information about the llvm-commits mailing list