llvm.org GIT mirror llvm / 4f840f1
[llvm-ar] Use POSIX-specified timestamps for 'tv'. Summary: The POSIX spec says: ``` If the −t option is used with the −v option, the standard output format shall be: "%s %u/%u %u %s %d %d:%d %d %s\n", <member mode>, <user ID>, <group ID>, <number of bytes in member>, <abbreviated month>, <day-of-month>, <hour>, <minute>, <year>, <file> where: ... <abbreviated month> Equivalent to the format of the %b conversion specification format in date. <day-of-month> Equivalent to the format of the %e conversion specification format in date. <hour> Equivalent to the format of the %H conversion specification format in date. <minute> Equivalent to the format of the %M conversion specification format in date. <year> Equivalent to the format of the %Y conversion specification format in date. ``` This actually used to be the format printed by llvm-ar. It was apparently accidentally changed (see r207385 followed by comments in r207387). This makes it conform to GNU ar for easier replacement. Reviewers: MaskRay Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D52940 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343901 91177308-0d34-0410-b5e6-96231b3b80d8 Jordan Rupprecht 10 months ago
4 changed file(s) with 28 addition(s) and 23 deletion(s). Raw diff Collapse all Expand all
3939 ; RUN: llvm-ar -format gnu rcU %t.a very_long_bytecode_file_name.bc
4040 ; RUN: env TZ=GMT llvm-ar tv %t.a | FileCheck %s -check-prefix CHECK-GNU
4141
42 CHECK-GNU: 1465 2004-11-19 03:01:31.000000000 very_long_bytecode_file_name.bc
42 CHECK-GNU: 1465 Nov 19 03:01 2004 very_long_bytecode_file_name.bc
4343
4444 ; RUN: rm -f %t.a
4545 ; RUN: llvm-ar -format darwin rcU %t.a very_long_bytecode_file_name.bc
4646 ; RUN: env TZ=GMT llvm-ar tv %t.a | FileCheck %s -check-prefix CHECK-DARWIN
4747
48 CHECK-DARWIN: 1472 2004-11-19 03:01:31.000000000 very_long_bytecode_file_name.bc
48 CHECK-DARWIN: 1472 Nov 19 03:01 2004 very_long_bytecode_file_name.bc
4949
5050 RUN: not llvm-ar x %p/Inputs/GNU.a foo.o 2>&1 | FileCheck --check-prefix=NOTFOUND %s
5151 NOTFOUND: foo.o was not found
22 Test reading an archive created by gnu ar
33 RUN: env TZ=GMT llvm-ar tv Inputs/GNU.a | FileCheck %s --check-prefix=GNU -strict-whitespace
44
5 GNU: rw-r--r-- 500/500 8 2004-11-19 02:57:37.000000000 evenlen
6 GNU-NEXT: rw-r--r-- 500/500 7 2004-11-19 02:57:21.000000000 oddlen
7 GNU-NEXT: rwxr-xr-x 500/500 1465 2004-11-19 03:01:31.000000000 very_long_bytecode_file_name.bc
8 GNU-NEXT: rw-r--r-- 500/500 2280 2004-11-19 03:04:30.000000000 IsNAN.o
5 GNU: rw-r--r-- 500/500 8 Nov 19 02:57 2004 evenlen
6 GNU-NEXT: rw-r--r-- 500/500 7 Nov 19 02:57 2004 oddlen
7 GNU-NEXT: rwxr-xr-x 500/500 1465 Nov 19 03:01 2004 very_long_bytecode_file_name.bc
8 GNU-NEXT: rw-r--r-- 500/500 2280 Nov 19 03:04 2004 IsNAN.o
99
1010
1111 Test reading an archive createdy by Mac OS X ar
1212 RUN: env TZ=GMT llvm-ar tv Inputs/MacOSX.a | FileCheck %s --check-prefix=OSX -strict-whitespace
1313
1414 OSX-NOT: __.SYMDEF
15 OSX: rw-r--r-- 501/501 8 2004-11-19 02:57:37.000000000 evenlen
16 OSX-NEXT: rw-r--r-- 501/501 8 2004-11-19 02:57:21.000000000 oddlen
17 OSX-NEXT: rw-r--r-- 502/502 1465 2010-02-04 06:59:14.000000000 very_long_bytecode_file_name.bc
18 OSX-NEXT: rw-r--r-- 501/501 2280 2004-11-19 04:32:06.000000000 IsNAN.o
15 OSX: rw-r--r-- 501/501 8 Nov 19 02:57 2004 evenlen
16 OSX-NEXT: rw-r--r-- 501/501 8 Nov 19 02:57 2004 oddlen
17 OSX-NEXT: rw-r--r-- 502/502 1465 Feb 4 06:59 2010 very_long_bytecode_file_name.bc
18 OSX-NEXT: rw-r--r-- 501/501 2280 Nov 19 04:32 2004 IsNAN.o
1919
2020 Test reading an archive created on Solaris by /usr/ccs/bin/ar
2121 RUN: env TZ=GMT llvm-ar tv Inputs/SVR4.a | FileCheck %s -strict-whitespace
2323 Test reading an archive created on Solaris by /usr/xpg4/bin/ar
2424 RUN: env TZ=GMT llvm-ar tv Inputs/xpg4.a | FileCheck %s -strict-whitespace
2525
26 CHECK: rw-r--r-- 1002/102 8 2004-11-19 03:24:02.000000000 evenlen
27 CHECK-NEXT: rw-r--r-- 1002/102 7 2004-11-19 03:24:02.000000000 oddlen
28 CHECK-NEXT: rwxr-xr-x 1002/102 1465 2004-11-19 03:24:02.000000000 very_long_bytecode_file_name.bc
29 CHECK-NEXT: rw-r--r-- 1002/102 2280 2004-11-19 03:24:02.000000000 IsNAN.o
26 CHECK: rw-r--r-- 1002/102 8 Nov 19 03:24 2004 evenlen
27 CHECK-NEXT: rw-r--r-- 1002/102 7 Nov 19 03:24 2004 oddlen
28 CHECK-NEXT: rwxr-xr-x 1002/102 1465 Nov 19 03:24 2004 very_long_bytecode_file_name.bc
29 CHECK-NEXT: rw-r--r-- 1002/102 2280 Nov 19 03:24 2004 IsNAN.o
3030
3131 Test reading a thin archive created by gnu ar
3232 RUN: env TZ=GMT llvm-ar tv Inputs/thin.a | FileCheck %s --check-prefix=THIN -strict-whitespace
3333
34 THIN: rw-r--r-- 1000/1000 8 2014-12-16 00:56:27.000000000 Inputs/evenlen
35 THIN-NEXT: rw-r--r-- 1000/1000 7 2014-12-16 00:56:27.000000000 Inputs/oddlen
36 THIN-NEXT: rwxr-xr-x 1000/1000 1465 2014-12-16 00:56:27.000000000 Inputs/very_long_bytecode_file_name.bc
37 THIN-NEXT: rw-r--r-- 1000/1000 2280 2014-12-16 00:56:27.000000000 Inputs/IsNAN.o
34 THIN: rw-r--r-- 1000/1000 8 Dec 16 00:56 2014 Inputs/evenlen
35 THIN-NEXT: rw-r--r-- 1000/1000 7 Dec 16 00:56 2014 Inputs/oddlen
36 THIN-NEXT: rwxr-xr-x 1000/1000 1465 Dec 16 00:56 2014 Inputs/very_long_bytecode_file_name.bc
37 THIN-NEXT: rw-r--r-- 1000/1000 2280 Dec 16 00:56 2014 Inputs/IsNAN.o
3838
3939 Test reading an archive with just a symbol table. We use to reject them.
4040 RUN: llvm-ar tv Inputs/symtab-only.a | FileCheck --allow-empty --check-prefix=EMPTY %s
4343 Test reading a thin archive with directory names.
4444 RUN: env TZ=GMT llvm-ar tv Inputs/thin-path.a | FileCheck %s --check-prefix=THINPATH -strict-whitespace
4545
46 THINPATH: rw-r--r-- 0/0 1224 1970-01-01 00:00:00.000000000 Inputs/test.o
47 THINPATH-NEXT: rw-r--r-- 0/0 1224 1970-01-01 00:00:00.000000000 Inputs/t/test2.o
46 THINPATH: rw-r--r-- 0/0 1224 Jan 1 00:00 1970 Inputs/test.o
47 THINPATH-NEXT: rw-r--r-- 0/0 1224 Jan 1 00:00 1970 Inputs/t/test2.o
None RUN: llvm-ar tv %S/Inputs/msvc-import.lib | FileCheck %s
0 RUN: env TZ=GMT llvm-ar tv %S/Inputs/msvc-import.lib | FileCheck %s
11
2 CHECK: --------- 0/0 0 1970-01-01 {{[0-9:.]+}} library.dll
2 CHECK: --------- 0/0 0 Jan 1 {{[0-9:.]+}} 1970 library.dll
2323 #include "llvm/Support/Errc.h"
2424 #include "llvm/Support/FileSystem.h"
2525 #include "llvm/Support/Format.h"
26 #include "llvm/Support/FormatVariadic.h"
2627 #include "llvm/Support/InitLLVM.h"
2728 #include "llvm/Support/LineIterator.h"
2829 #include "llvm/Support/MemoryBuffer.h"
366367 outs() << ' ' << format("%6llu", Size.get());
367368 auto ModTimeOrErr = C.getLastModified();
368369 failIfError(ModTimeOrErr.takeError());
369 outs() << ' ' << ModTimeOrErr.get();
370 // Note: formatv() only handles the default TimePoint<>, which is in
371 // nanoseconds.
372 // TODO: fix format_provider> to allow other units.
373 sys::TimePoint<> ModTimeInNs = ModTimeOrErr.get();
374 outs() << ' ' << formatv("{0:%b %e %H:%M %Y}", ModTimeInNs);
370375 outs() << ' ';
371376 }
372377