[clang] fdd4e9f - [clang] UEFI handle unsupported triples. (#124824)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 29 14:42:33 PST 2025
Author: Prabhuk
Date: 2025-01-29T14:42:29-08:00
New Revision: fdd4e9f1012c01403eeb31fd0297a13397dc40a2
URL: https://github.com/llvm/llvm-project/commit/fdd4e9f1012c01403eeb31fd0297a13397dc40a2
DIFF: https://github.com/llvm/llvm-project/commit/fdd4e9f1012c01403eeb31fd0297a13397dc40a2.diff
LOG: [clang] UEFI handle unsupported triples. (#124824)
The only architecture currently being supported (still a WIP) is
x86_64. Other UEFI triples targeting other architectures will now
report an `unknown target triple` error.
Added:
Modified:
clang/lib/Driver/Driver.cpp
clang/test/Driver/uefi-constructed-args.c
clang/test/Driver/unsupported-target-arch.c
Removed:
################################################################################
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 87855fdb799710..684f7715bf45d2 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -637,6 +637,10 @@ static llvm::Triple computeTargetTriple(const Driver &D,
}
}
+ // Currently the only architecture supported by *-uefi triples are x86_64.
+ if (Target.isUEFI() && Target.getArch() != llvm::Triple::x86_64)
+ D.Diag(diag::err_target_unknown_triple) << Target.str();
+
// The `-maix[32|64]` flags are only valid for AIX targets.
if (Arg *A = Args.getLastArgNoClaim(options::OPT_maix32, options::OPT_maix64);
A && !Target.isOSAIX())
diff --git a/clang/test/Driver/uefi-constructed-args.c b/clang/test/Driver/uefi-constructed-args.c
index 3cc5abe6974539..44d2271e0c8bab 100644
--- a/clang/test/Driver/uefi-constructed-args.c
+++ b/clang/test/Driver/uefi-constructed-args.c
@@ -1,3 +1,5 @@
+// RUN: %clang -### --target=x86_64-unknown-uefi -g -- %s 2>&1 \
+// RUN: | FileCheck -check-prefixes=CHECK %s
// RUN: %clang_cl -### --target=x86_64-unknown-uefi -g -- %s 2>&1 \
// RUN: | FileCheck -check-prefixes=CHECK %s
// CHECK: "-cc1"
diff --git a/clang/test/Driver/unsupported-target-arch.c b/clang/test/Driver/unsupported-target-arch.c
index 8df0ee9fe7d06f..c0ec235439bcaf 100644
--- a/clang/test/Driver/unsupported-target-arch.c
+++ b/clang/test/Driver/unsupported-target-arch.c
@@ -63,3 +63,21 @@
// RUN: not %clang --target=powerpc-apple-darwin -o /dev/null %s 2> %t.err
// RUN: FileCheck --input-file=%t.err --check-prefix=CHECK-PPCMAC %s
// CHECK-PPCMAC: error: unknown target triple 'unknown-apple-macosx{{.*}}'
+
+// RUN: not %clang --target=aarch64-unknown-uefi -o %t.o %s 2> %t.err
+// RUN: FileCheck --input-file=%t.err --check-prefix=CHECK-AARCH64 %s
+// RUN: not %clang_cl --target=aarch64-unknown-uefi -o %t.o %s 2> %t.err
+// RUN: FileCheck --input-file=%t.err --check-prefix=CHECK-AARCH64 %s
+// CHECK-AARCH64: error: unknown target triple 'aarch64-unknown-uefi'{{$}}
+
+// RUN: not %clang --target=arm-unknown-uefi -o %t.o %s 2> %t.err
+// RUN: FileCheck --input-file=%t.err -check-prefixes=CHECK-ARM %s
+// RUN: not %clang_cl --target=arm-unknown-uefi -o %t.o %s 2> %t.err
+// RUN: FileCheck --input-file=%t.err -check-prefixes=CHECK-ARM %s
+// CHECK-ARM: error: unknown target triple 'arm-unknown-uefi'{{$}}
+
+// RUN: not %clang --target=x86-unknown-uefi -o %t.o %s 2> %t.err
+// RUN: FileCheck --input-file=%t.err -check-prefixes=CHECK-x86 %s
+// RUN: not %clang_cl --target=x86-unknown-uefi -o %t.o %s 2> %t.err
+// RUN: FileCheck --input-file=%t.err -check-prefixes=CHECK-x86 %s
+// CHECK-x86: error: unknown target triple 'x86-unknown-uefi'{{$}}
More information about the cfe-commits
mailing list