[llvm] r287038 - 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:36:35 PST 2016


Author: pcc
Date: Tue Nov 15 15:36:35 2016
New Revision: 287038

URL: http://llvm.org/viewvc/llvm-project?rev=287038&view=rev
Log:
Object: replace backslashes with slashes in embedded relative thin archive paths on Windows.

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

Differential Revision: https://reviews.llvm.org/D26696

Added:
    llvm/trunk/test/Object/archive-thin-paths.test
Modified:
    llvm/trunk/lib/Object/ArchiveWriter.cpp

Modified: llvm/trunk/lib/Object/ArchiveWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/ArchiveWriter.cpp?rev=287038&r1=287037&r2=287038&view=diff
==============================================================================
--- llvm/trunk/lib/Object/ArchiveWriter.cpp (original)
+++ llvm/trunk/lib/Object/ArchiveWriter.cpp Tue Nov 15 15:36:35 2016
@@ -205,6 +205,12 @@ static std::string computeRelativePath(S
   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();
 }
 

Added: llvm/trunk/test/Object/archive-thin-paths.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/archive-thin-paths.test?rev=287038&view=auto
==============================================================================
--- llvm/trunk/test/Object/archive-thin-paths.test (added)
+++ llvm/trunk/test/Object/archive-thin-paths.test Tue Nov 15 15:36:35 2016
@@ -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




More information about the llvm-commits mailing list