This is an archive of the discontinued LLVM Phabricator instance.

[llvm-strip] Add support for -p/--preserve-dates
ClosedPublic

Authored by rupprecht on Aug 14 2018, 4:18 PM.

Diff Detail

Event Timeline

rupprecht created this revision.Aug 14 2018, 4:18 PM
jhenderson added inline comments.Aug 15 2018, 2:56 AM
test/tools/llvm-objcopy/strip-preserve-time.test
2

Have you run this test both on Windows and Linux to ensure the they work the same? I know a colleague had some issues with access times on Windows at one point, for example.

4

The comments in the file should end in a full stop, I think.

6

I'm slightly worried that this might lead to a flaky test, because there's a race condition here: if another process accesses the file some time between file creation and checking, then we'll presumably get a failure (and I could see a virus scanner doing just that...).

15

I'd prefer it if you use a different output file for each case. It'll make it easier to debug any issues with failing tests, because all of the different cases will be available.

tools/llvm-objcopy/llvm-objcopy.cpp
680

Should this be static?

rupprecht marked 5 inline comments as done.
  • Use different objects in test/fix static-ness of stat restore method
rupprecht added inline comments.Aug 15 2018, 10:06 AM
test/tools/llvm-objcopy/strip-preserve-time.test
2

I don't have access to a Windows machine, but I'll ask a coworker to patch it and take a look.

I'd actually rather use stat if this is linux-only, but I assume that ls is more portable.

6

I'm not sure if there's a good solution for this. At the very least, I can watch build bots once this is submitted to see if this test causes flakiness. Very little time goes by between file creation and running llvm-strip, so it _probably_ won't cause issues, but I don't know how virus scanners work.

jhenderson accepted this revision.Aug 16 2018, 3:07 AM

If I get a chance, I'll verify this on Windows. Otherwise, this LGTM.

test/tools/llvm-objcopy/strip-preserve-time.test
6

Yeah, I don't really know either. If it starts causing flakiness, we might just want to sacrifice that part of the test, and just verify it manually...

35

Nit: I don't think you need the 's' part of this command.

This revision is now accepted and ready to land.Aug 16 2018, 3:07 AM
  • Fix tests for windows compatibility
rupprecht marked 3 inline comments as done.Aug 16 2018, 10:56 AM
rupprecht added inline comments.
test/tools/llvm-objcopy/strip-preserve-time.test
6

So, apparently windows is fine with "ls -lu" etc., but barfs on the parens used to pipe several commands to FileCheck

$ "C:\src\clang\bin\llvm-strip.EXE" "-p" "C:\src\clang\test\tools\llvm-objcopy\Output\strip-preserve-time.test.tmp.1.o" "-o" "C:\src\clang\test\tools\llvm-objcopy\Output\strip-preserve-time.test.tmp-preserved.1.o"
$ ":" "RUN: at line 8"
$ "(ls" "-lu" "C:\src\clang\test\tools\llvm-objcopy\Output\strip-preserve-time.test.tmp-preserved.1.o"
# command stderr:
'(ls': command not found
error: command failed with exit status: 127

Splitting it into two with different access/modify time check-prefixes seems to work.

rupprecht marked an inline comment as done.
  • crs->cr
This revision was automatically updated to reflect the committed changes.
jhenderson added inline comments.Aug 17 2018, 1:59 AM
llvm/trunk/test/tools/llvm-objcopy/strip-preserve-time.test
16–17 ↗(On Diff #161082)

Great! I think what you've done here is fine, but for reference, you could have done it in an equally valid way using output redirection. I think either approach works though.

# RUN: ls -lu %t-preserved.2.o > %t.out.txt
# RUN: ls -l %t-preserved.2.o >> %t.out.txt
# RUN: FileCheck %s --input-file %t.out.txt --check-prefix=CHECK-PRESERVE