This is an archive of the discontinued LLVM Phabricator instance.

[clang] fix linker executable path in test
ClosedPublic

Authored by ashay-github on Sep 13 2022, 6:25 AM.

Details

Summary

A previous patch (https://reviews.llvm.org/D132810) introduced a test
that fails on systems where the linker executable (ld) has a .exe
extension. This patch updates the regex in the test so that lit can
look for both ld as well as ld.exe.

Diff Detail

Event Timeline

ashay-github created this revision.Sep 13 2022, 6:25 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 13 2022, 6:25 AM
ashay-github requested review of this revision.Sep 13 2022, 6:25 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 13 2022, 6:25 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Ah sorry about that, I didn't realize the command includes .exe on Windows. (For the record, ld" matches both ld and ld.lld.)

clang/test/Driver/mingw-cfguard.c
6

Literal dot needs to be escaped as \. in regex.

Ah sorry about that, I didn't realize the command includes .exe on Windows. (For the record, ld" matches both ld and ld.lld.)

No, iirc these quotes are checked as literal part of the matched string here; otherwise the pattern ld" would match ld.exe" too. So to match any linker name, I'd write ld{{.*}}" or maybe something like ld{{[\.a-z]*}}", modulo regex syntax.

alvinhochun added a comment.EditedSep 13 2022, 8:25 AM

Ah sorry about that, I didn't realize the command includes .exe on Windows. (For the record, ld" matches both ld and ld.lld.)

No, iirc these quotes are checked as literal part of the matched string here; otherwise the pattern ld" would match ld.exe" too. So to match any linker name, I'd write ld{{.*}}" or maybe something like ld{{[\.a-z]*}}", modulo regex syntax.

Oops, I meant ld" and ld.lld", because both ends in ld".

Ah sorry about that, I didn't realize the command includes .exe on Windows. (For the record, ld" matches both ld and ld.lld.)

No, iirc these quotes are checked as literal part of the matched string here; otherwise the pattern ld" would match ld.exe" too. So to match any linker name, I'd write ld{{.*}}" or maybe something like ld{{[\.a-z]*}}", modulo regex syntax.

Oops, I meant ld" and ld.lld", because both ends in ld".

Oh, I see - that's very sneaky!

Thanks! I updated the regex to be ld{{.*}}".

ashay-github updated this revision to Diff 459791.EditedSep 13 2022, 10:06 AM

Updated the regex to ld{{(.lld)?}}{{(.exe)?}}", so that it matches the
following sequences: ld", ld.lld", ld.exe", ld.lld.exe".

@alvinhochun @mstorsjo Let me know if you'd like to see more changes. With the new regex, the tests pass at my end as well as in the Phabricator CI.

This revision is now accepted and ready to land.Sep 14 2022, 9:05 AM
This revision was automatically updated to reflect the committed changes.

The literal dots have not been escaped as \., but the current change works anyway and the chance of false positives here should be very low. I guess this is acceptable.