This is an archive of the discontinued LLVM Phabricator instance.

[lld][COFF] Don't handle an input file multiple times when retrying
ClosedPublic

Authored by aeubanks on Jun 5 2023, 2:34 PM.

Details

Summary

Follow up to D151815.

Or else we properly handle the first instance of a file, then error out on the second instance of the same file.

Diff Detail

Event Timeline

aeubanks created this revision.Jun 5 2023, 2:34 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 5 2023, 2:34 PM
aeubanks requested review of this revision.Jun 5 2023, 2:34 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 5 2023, 2:34 PM
rnk added inline comments.Jun 5 2023, 3:15 PM
lld/COFF/Driver.cpp
259

This is confusing, if the file really doesn't exist at all, won't findFile return none on the first attempt, and with your change, we will never report a file not found error? What happens, does findFile return the string without modification?

lld/test/COFF/winsysroot.test
32

Please add a test that uses /winsysroot, and also has a non-existing library, such as notfound.lib. It seems very similar to the LIB test case at the bottom, but I'm not totally sure.

aeubanks updated this revision to Diff 528624.Jun 5 2023, 4:32 PM

add/update tests

aeubanks added inline comments.Jun 5 2023, 4:33 PM
lld/COFF/Driver.cpp
259

yeah, findFile is weird in that it only returns null when visiting a file more than once, not if the file is not found (where it just returns the path unmodified)

rnk accepted this revision.Jun 6 2023, 9:46 AM
rnk added a subscriber: mstorsjo.

lgtm

lld/COFF/Driver.cpp
259

Can I trouble you to take on a follow-up to fix up the naming?

I see that findFile has this filtering behavior: return the filename if it is new. I propose renaming it to findFileIfNew, and then all of the doFind* variants can be renamed find*. The same treatment has to be applied to findLib.

+@mstorsjo , do you find the suggested naming better?

This revision is now accepted and ready to land.Jun 6 2023, 9:46 AM