This is an archive of the discontinued LLVM Phabricator instance.

[Driver] Use VFS for GetProgramPath() (NFCI)
AbandonedPublic

Authored by nikic on May 24 2023, 6:14 AM.

Details

Reviewers
MaskRay
Summary

To allow unit testing this code path, switch to using VFS instead of the real file system.

Diff Detail

Event Timeline

nikic created this revision.May 24 2023, 6:14 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 24 2023, 6:14 AM
Herald added a subscriber: StephenFan. · View Herald Transcript
MaskRay accepted this revision.May 24 2023, 12:10 PM

Looks great!

clang/lib/Driver/Driver.cpp
5979

Change to lower case while updating the signature.

This revision is now accepted and ready to land.May 24 2023, 12:10 PM

Unfortunately, it looks like there are legitimate failures of flang tests on Windows in pre-merge checks, thanks to this bit of magic in the Windows implementation of can_execute: https://github.com/llvm/llvm-project/blob/f0687b47a0ce82da07127fee4fe6af801df54ca6/llvm/lib/Support/Windows/Path.inc#L643-L646 So when checking whether flang-new is executable, it will also check for flang-new.exe and we end up returning the former. Now we end up returning the latter. Not sure what to do about this.

nikic abandoned this revision.May 25 2023, 12:19 AM

I don't see a good way forward here. fs::can_execute has platform specific code. I don't want to replicate its logic here, and making VFS platform-dependent also seems dubious. The cleanest solution would be to make fs::can_execute itself operate on VFS, but I think this doesn't really work with the current layering. There is also a related problem that findProgramByName() isn't VFS-based either, so there remains a partial dependency on the real FS.