This is an archive of the discontinued LLVM Phabricator instance.

[Driver][BareMetal] Error if no matching multilib
ClosedPublic

Authored by michaelplatings on Jun 19 2023, 8:48 AM.

Details

Summary

Previously if no matching multilib was found then the user would
typically see an error like "fatal error: 'stdio.h' file not found"
which gives no indication as to the underlying problem.
With this change the user will instead see an error like

clang: error: no multilib found matching flags: --target=thumbv7em-none-unknown-eabi -march=...
clang: note: available multilibs are:
--target=armv4t-none-unknown-eabi
--target=thumbv6m-none-unknown-eabi -mfpu=none
...

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptJun 19 2023, 8:48 AM
michaelplatings requested review of this revision.Jun 19 2023, 8:48 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 19 2023, 8:48 AM
simon_tatham accepted this revision.Jun 20 2023, 2:17 AM
simon_tatham added a subscriber: simon_tatham.

LGTM.

One of the thoughts I mentioned offline before this patch was written was that maybe the error would need to be conditional, via a directive inside multilib.yaml itself – perhaps some users want to fall off the end of the multilib list without error and continue using the default sysroot, whereas others want to diagnose "sorry, no library at all is available to support your flags"? But I suppose there won't be a large user base who were already using this particular YAML technique in the former mode, or at all, because it's so new. And if necessary one could reorganise to put multilib.yaml in its own directory, and add a final catch-all entry pointing at the fallback sysroot. So it should be OK to have the error unconditional.

clang/test/Driver/baremetal-multilib.yaml
88–90

I'm not sure what the purpose of this addition is. It doesn't seem to be listed in the expected error messages (but it's presumably being printed anyway, and skipped over because the checks don't say -NEXT?). Did it sneak in here from another commit, perhaps?

This revision is now accepted and ready to land.Jun 20 2023, 2:17 AM
michaelplatings marked an inline comment as done.Jun 20 2023, 2:31 AM

Thanks @simon_tatham. I agree there's definitely scope to improve this. The behaviour is quite specific so I kept the code in the BareMetal toolchain rather than as part of the core Multilib class. Other toolchains may require different behaviour as you say.

This change also doesn't address the layered multilib scenario. In that scenario multiple multilibs may be required to match to get a complete set of headers and libraries. But this change moves us in the right direction.

clang/test/Driver/baremetal-multilib.yaml
88–90

Sorry I forgot to explain this already. With the new error, CHECK-NO-EXECUTE-ONLY-ASM started failing because no multilib variant matched. I added this variant to fix that.

This revision was automatically updated to reflect the committed changes.