This is an archive of the discontinued LLVM Phabricator instance.

[clang][Driver] Fix crash with unsupported architectures in MinGW and CrossWindows.
ClosedPublic

Authored by k-mana on Apr 21 2023, 10:07 AM.

Details

Summary

MinGW and CrossWindows crash if the target is an unsupported target architecture.
Changed it to emit an error message.

Fixes https://github.com/llvm/llvm-project/issues/59545

Diff Detail

Event Timeline

k-mana created this revision.Apr 21 2023, 10:07 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 21 2023, 10:07 AM
k-mana requested review of this revision.Apr 21 2023, 10:07 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 21 2023, 10:07 AM
shafik added a subscriber: shafik.Apr 21 2023, 11:49 AM

Thank you for this fix. Can you please add a summary in the details explaining the motivation for this fix and a link to the github bug report as well.

fhahn resigned from this revision.Apr 28 2023, 2:30 AM

Sorry, I am not familiar at all with this code. Perhaps @shafik could suggest more appropriate reviewers

I think the code changes make sense; these are trivial to hit by a user, so they shouldn't be llvm_unreachable.

clang/test/Driver/unsupported-target-arch.c
33

Separate side note; the suggested option -triple isn't really a clang driver level option, and -arch is only relevant for darwin targets (AFAIK) - so maybe the error message text should be revised?

junaire edited reviewers, added: MaskRay; removed: fhahn.Apr 28 2023, 2:56 AM
k-mana edited the summary of this revision. (Show Details)Apr 29 2023, 12:34 AM
mstorsjo accepted this revision.May 1 2023, 8:05 AM

LGTM. If you don’t have commit access, please say your preferred git author name for the commit, i.e. Real Name <email@address>.

This revision is now accepted and ready to land.May 1 2023, 8:05 AM

I don't have commit access.
Please commit at KOMATA Manabu <k-mana@mve.biglobe.ne.jp>.

MaskRay accepted this revision.May 1 2023, 6:27 PM

Looks great!

clang/test/Driver/unsupported-target-arch.c
33

The part ", please use -triple or -arch" is almost always wrong.

For cc1, the error is due to a specified but unknown -triple, we should not suggest specifying -triple.
For driver, -triple and -arch are not driver options.

I just removed the hint from the diagnostic.

mstorsjo added inline comments.May 2 2023, 1:13 AM
clang/test/Driver/unsupported-target-arch.c
33

-arch is a driver option, for darwin targets though. But I agree that it's probably best to leave it out since it's more misleading than helping here (and -triple is indeed not a relevant option here).