xref: /llvm-project/llvm/test/tools/llvm-ar/absolute-paths.test (revision bf223e43fe68da22f185a12c1a2fe36a726f4fe9)
1MSVC's lib.exe produces archives with absolute paths to the members. It's useful
2for llvm-ar to extract them to their basename in the CWD, since usually the
3directories in the path in the archive won't exist during archive extraction.
4
5Get a temp clean cwd to extract into.
6RUN: rm -rf %t && mkdir %t && cd %t
7
8RUN: llvm-ar t %S/Inputs/absolute-paths.lib | FileCheck %s --check-prefix=CHECK-LIST
9CHECK-LIST: C:/src/llvm-project/build/dne/b.o
10CHECK-LIST: C:/src/llvm-project/build/dne/a.o
11
12Check that a.o comes out and defines foo.
13RUN: llvm-ar xP %S/Inputs/absolute-paths.lib 'C:/src/llvm-project/build/dne/a.o'
14RUN: llvm-nm a.o | FileCheck %s --check-prefix=CHECK-A
15CHECK-A: T foo
16
17Check that b.o comes out and defines bar.
18RUN: llvm-ar xP %S/Inputs/absolute-paths.lib C:/src/llvm-project/build/dne/b.o
19RUN: llvm-nm b.o | FileCheck %s --check-prefix=CHECK-B
20CHECK-B: T bar
21
22xP above is only required because we were explicitly extracting items from an
23archive with absolute paths. Extracting all objects doesn't need P because we
24aren't explicitly requesting any individual object.
25RUN: rm -f a.o b.o
26RUN: llvm-ar x %S/Inputs/absolute-paths.lib
27RUN: llvm-nm a.o | FileCheck %s --check-prefix=CHECK-A
28RUN: llvm-nm b.o | FileCheck %s --check-prefix=CHECK-B
29
30RUN: mkdir dir
31RUN: llvm-ar x %S/Inputs/absolute-paths.lib --output=dir/
32RUN: cmp a.o dir/a.o
33