Skip to content

Commit fdd4e9f

Browse files
authored
[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.
1 parent 774b12c commit fdd4e9f

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

clang/lib/Driver/Driver.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,10 @@ static llvm::Triple computeTargetTriple(const Driver &D,
637637
}
638638
}
639639

640+
// Currently the only architecture supported by *-uefi triples are x86_64.
641+
if (Target.isUEFI() && Target.getArch() != llvm::Triple::x86_64)
642+
D.Diag(diag::err_target_unknown_triple) << Target.str();
643+
640644
// The `-maix[32|64]` flags are only valid for AIX targets.
641645
if (Arg *A = Args.getLastArgNoClaim(options::OPT_maix32, options::OPT_maix64);
642646
A && !Target.isOSAIX())

clang/test/Driver/uefi-constructed-args.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// RUN: %clang -### --target=x86_64-unknown-uefi -g -- %s 2>&1 \
2+
// RUN: | FileCheck -check-prefixes=CHECK %s
13
// RUN: %clang_cl -### --target=x86_64-unknown-uefi -g -- %s 2>&1 \
24
// RUN: | FileCheck -check-prefixes=CHECK %s
35
// CHECK: "-cc1"

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,21 @@
6363
// RUN: not %clang --target=powerpc-apple-darwin -o /dev/null %s 2> %t.err
6464
// RUN: FileCheck --input-file=%t.err --check-prefix=CHECK-PPCMAC %s
6565
// CHECK-PPCMAC: error: unknown target triple 'unknown-apple-macosx{{.*}}'
66+
67+
// RUN: not %clang --target=aarch64-unknown-uefi -o %t.o %s 2> %t.err
68+
// RUN: FileCheck --input-file=%t.err --check-prefix=CHECK-AARCH64 %s
69+
// RUN: not %clang_cl --target=aarch64-unknown-uefi -o %t.o %s 2> %t.err
70+
// RUN: FileCheck --input-file=%t.err --check-prefix=CHECK-AARCH64 %s
71+
// CHECK-AARCH64: error: unknown target triple 'aarch64-unknown-uefi'{{$}}
72+
73+
// RUN: not %clang --target=arm-unknown-uefi -o %t.o %s 2> %t.err
74+
// RUN: FileCheck --input-file=%t.err -check-prefixes=CHECK-ARM %s
75+
// RUN: not %clang_cl --target=arm-unknown-uefi -o %t.o %s 2> %t.err
76+
// RUN: FileCheck --input-file=%t.err -check-prefixes=CHECK-ARM %s
77+
// CHECK-ARM: error: unknown target triple 'arm-unknown-uefi'{{$}}
78+
79+
// RUN: not %clang --target=x86-unknown-uefi -o %t.o %s 2> %t.err
80+
// RUN: FileCheck --input-file=%t.err -check-prefixes=CHECK-x86 %s
81+
// RUN: not %clang_cl --target=x86-unknown-uefi -o %t.o %s 2> %t.err
82+
// RUN: FileCheck --input-file=%t.err -check-prefixes=CHECK-x86 %s
83+
// CHECK-x86: error: unknown target triple 'x86-unknown-uefi'{{$}}

0 commit comments

Comments
 (0)