aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Driver/Driver.cpp
diff options
context:
space:
mode:
authorSimon Tatham <simon.tatham@arm.com>2024-09-02 16:56:03 +0100
committerGitHub <noreply@github.com>2024-09-02 16:56:03 +0100
commit26bf0b4ae7df7f5350f71afd40a57cdf8f98c588 (patch)
treea4bb02f2a862063d38948a1f70da60272bf1da5c /clang/lib/Driver/Driver.cpp
parent30d56bedd0a77c4c075e4cdc6191611bb84c8a49 (diff)
downloadllvm-26bf0b4ae7df7f5350f71afd40a57cdf8f98c588.zip
llvm-26bf0b4ae7df7f5350f71afd40a57cdf8f98c588.tar.gz
llvm-26bf0b4ae7df7f5350f71afd40a57cdf8f98c588.tar.bz2
[clang][Driver] Add a custom error option in multilib.yaml. (#105684)
Sometimes a collection of multilibs has a gap in it, where a set of driver command-line options can't work with any of the available libraries. For example, the Arm MVE extension requires special startup code (you need to initialize FPSCR.LTPSIZE), and also benefits greatly from -mfloat-abi=hard. So a multilib provider might build a library for systems without MVE, and another for MVE with -mfloat-abi=hard, anticipating that that's what most MVE users would want. But then if a user compiles for MVE _without_ -mfloat-abi=hard, thhey can't use either of those libraries – one has an ABI mismatch, and the other will fail to set up LTPSIZE. In that situation, it's useful to include a multilib.yaml entry for the unworkable intermediate situation, and have it map to a fatal error message rather than a set of actual libraries. Then the user gets a build failure with a sensible explanation, instead of selecting an unworkable library and silently generating bad output. The new regression test demonstrates this case. This patch introduces extra syntax into multilib.yaml, so that a record in the `Variants` list can omit the `Dir` key, and in its place, provide a `FatalError` key. Then, if that variant is selected, the error message is emitted as a clang diagnostic, and multilib selection fails. In order to emit the error message in `MultilibSet::select`, I had to pass a `Driver &` to that function, which involved plumbing one through to every call site, and in the unit tests, constructing one specially.
Diffstat (limited to 'clang/lib/Driver/Driver.cpp')
-rw-r--r--clang/lib/Driver/Driver.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 43002ad..5b3783e 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -2296,7 +2296,8 @@ bool Driver::HandleImmediateArgs(Compilation &C) {
if (C.getArgs().hasArg(options::OPT_print_multi_lib)) {
for (const Multilib &Multilib : TC.getMultilibs())
- llvm::outs() << Multilib << "\n";
+ if (!Multilib.isFatalError())
+ llvm::outs() << Multilib << "\n";
return false;
}