This is an archive of the discontinued LLVM Phabricator instance.

[Driver] Always use Unix-style paths in the Darwin driver
AbandonedPublic

Authored by ldionne on May 27 2019, 1:18 PM.

Details

Summary

Otherwise, the unit tests seem to be confused on Windows. Note that it
would in theory be better to always use the platform's path, however we
don't seem to have a good way of handling that with FileCheck right now.
This change makes the handling of paths on Darwin consistent with what
we do on Linux, and also with what we used to do (for several paths)
before the refactoring in r361278.

Event Timeline

ldionne created this revision.May 27 2019, 1:18 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 27 2019, 1:18 PM

A few notes:

  • I did setup a Windows machine and run the tests on it
  • I'd welcome a better way to solve this problem than ripping out the use of llvm::sys::path::append, but I wasn't able to find anything in FileCheck that would do it

This doesn’t look okay to me, because this would prevent building for Darwin when running on Windows. I added a couple of reviewers that have Windows experience and might have ideas for how to fix the tests without breaking the portability of the driver.

rnk added a comment.May 28 2019, 11:33 AM

So, there's nothing wrong, functionally speaking, with what we do today, right? It's just inconvenient to test.

The difficulty of testing the driver has been a long standing problem. I think we might want to instead invent some new kind of alternative to -### for writing driver tests that is more FileCheck friendly. For example, we could print flags one-per line, without quoting. I think it would also be reasonable to do some dumb string post-processing to rewrite Windows-style paths to Unix style paths so they always look the same.

In D62493#1519708, @rnk wrote:

So, there's nothing wrong, functionally speaking, with what we do today, right? It's just inconvenient to test.

What we do for Darwin today (without this patch) is functionally correct, but hard to test.

What we do for other platforms (e.g. Linux) today is probably not correct, since we use Unix-style paths all around the place.

The difficulty of testing the driver has been a long standing problem. I think we might want to instead invent some new kind of alternative to -### for writing driver tests that is more FileCheck friendly. For example, we could print flags one-per line, without quoting. I think it would also be reasonable to do some dumb string post-processing to rewrite Windows-style paths to Unix style paths so they always look the same.

Would it make sense to be able to define FileCheck variables (with -DFOO) while giving them a type? If I could specify that I'm passing paths to FileCheck and it normalized them for the platform the tests are being run on, I think that would solve the issue. Do you think that's an idea worth pursuing?

ldionne abandoned this revision.Jun 2 2021, 3:41 PM