This is an archive of the discontinued LLVM Phabricator instance.

[llvm-ar] Use POSIX-specified timestamps for 'tv'.
ClosedPublic

Authored by rupprecht on Oct 5 2018, 12:24 PM.

Details

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.

Diff Detail

Repository
rL LLVM

Event Timeline

rupprecht created this revision.Oct 5 2018, 12:24 PM
MaskRay accepted this revision.Oct 5 2018, 2:53 PM
MaskRay added inline comments.
tools/llvm-ar/llvm-ar.cpp
375 ↗(On Diff #168504)

LG.

The format specifier is what FreeBSD ar uses.

http://src.illumos.org/source/xref/freebsd-head/usr.bin/ar/read.c#145

An interesting finding is that GNU ar (binutils-gdb/binutils/bucomm.c) uses ctime in a horrible way:

	  const char *ctime_result = (const char *) ctime (&when);
	  bfd_size_type size;

	  /* PR binutils/17605: Check for corrupt time values.  */
	  if (ctime_result == NULL)
	    sprintf (timebuf, _("<time data corrupt>"));
	  else
	    /* POSIX format:  skip weekday and seconds from ctime output.  */
	    sprintf (timebuf, "%.12s %.4s", ctime_result + 4, ctime_result + 20);
This revision is now accepted and ready to land.Oct 5 2018, 2:53 PM
This revision was automatically updated to reflect the committed changes.