[llvm] r299264 - [llvm-ar] Extract objects to their basename in the CWD
Reid Kleckner via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 31 14:10:53 PDT 2017
Author: rnk
Date: Fri Mar 31 16:10:53 2017
New Revision: 299264
URL: http://llvm.org/viewvc/llvm-project?rev=299264&view=rev
Log:
[llvm-ar] Extract objects to their basename in the CWD
This is helpful when extracting objects from archives produced by MSVC's
lib.exe, which users absolute paths to describe the archive members.
Added:
llvm/trunk/test/tools/llvm-ar/Inputs/absolute-paths.lib
llvm/trunk/test/tools/llvm-ar/absolute-paths.test
Modified:
llvm/trunk/tools/llvm-ar/llvm-ar.cpp (contents, props changed)
Added: llvm/trunk/test/tools/llvm-ar/Inputs/absolute-paths.lib
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-ar/Inputs/absolute-paths.lib?rev=299264&view=auto
==============================================================================
(empty)
Added: llvm/trunk/test/tools/llvm-ar/absolute-paths.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-ar/absolute-paths.test?rev=299264&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-ar/absolute-paths.test (added)
+++ llvm/trunk/test/tools/llvm-ar/absolute-paths.test Fri Mar 31 16:10:53 2017
@@ -0,0 +1,20 @@
+MSVC's lib.exe produces archives with absolute paths to the members. It's useful
+for llvm-ar to extract them to their basename in the CWD, since usually the
+directories in the path in the archive won't exist during archive extraction.
+
+Get a temp clean cwd to extract into.
+RUN: rm -rf %t && mkdir %t && cd %t
+
+RUN: llvm-ar t %S/Inputs/absolute-paths.lib | FileCheck %s --check-prefix=CHECK-LIST
+CHECK-LIST: C:/src/llvm-project/build/dne/b.o
+CHECK-LIST: C:/src/llvm-project/build/dne/a.o
+
+Check that a.o comes out and defines foo.
+RUN: llvm-ar x %S/Inputs/absolute-paths.lib 'C:/src/llvm-project/build/dne/a.o'
+RUN: llvm-nm a.o | FileCheck %s --check-prefix=CHECK-A
+CHECK-A: T foo
+
+Check that b.o comes out and defines bar.
+RUN: llvm-ar x %S/Inputs/absolute-paths.lib C:/src/llvm-project/build/dne/b.o
+RUN: llvm-nm b.o | FileCheck %s --check-prefix=CHECK-B
+CHECK-B: T bar
Modified: llvm/trunk/tools/llvm-ar/llvm-ar.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-ar/llvm-ar.cpp?rev=299264&r1=299263&r2=299264&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-ar/llvm-ar.cpp (original)
+++ llvm/trunk/tools/llvm-ar/llvm-ar.cpp Fri Mar 31 16:10:53 2017
@@ -377,7 +377,9 @@ static void doExtract(StringRef Name, co
sys::fs::perms Mode = ModeOrErr.get();
int FD;
- failIfError(sys::fs::openFileForWrite(Name, FD, sys::fs::F_None, Mode), Name);
+ failIfError(sys::fs::openFileForWrite(sys::path::filename(Name), FD,
+ sys::fs::F_None, Mode),
+ Name);
{
raw_fd_ostream file(FD, false);
Propchange: llvm/trunk/tools/llvm-ar/llvm-ar.cpp
------------------------------------------------------------------------------
--- svn:eol-style (original)
+++ svn:eol-style (removed)
@@ -1 +0,0 @@
-native
More information about the llvm-commits
mailing list