diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp b/clang/lib/Driver/ToolChains/BareMetal.cpp --- a/clang/lib/Driver/ToolChains/BareMetal.cpp +++ b/clang/lib/Driver/ToolChains/BareMetal.cpp @@ -125,6 +125,20 @@ return true; } +/// Is the triple aarch64-none-elf? +static bool isAArch64BareMetal(const llvm::Triple &Triple) { + if (Triple.getArch() != llvm::Triple::aarch64) + return false; + + if (Triple.getVendor() != llvm::Triple::UnknownVendor) + return false; + + if (Triple.getOS() != llvm::Triple::UnknownOS) + return false; + + return Triple.getEnvironmentName() == "elf"; +} + static bool isRISCVBareMetal(const llvm::Triple &Triple) { if (Triple.getArch() != llvm::Triple::riscv32 && Triple.getArch() != llvm::Triple::riscv64) @@ -151,7 +165,8 @@ } bool BareMetal::handlesTarget(const llvm::Triple &Triple) { - return isARMBareMetal(Triple) || isRISCVBareMetal(Triple); + return isARMBareMetal(Triple) || isAArch64BareMetal(Triple) || + isRISCVBareMetal(Triple); } Tool *BareMetal::buildLinker() const { diff --git a/clang/test/Driver/baremetal.cpp b/clang/test/Driver/baremetal.cpp --- a/clang/test/Driver/baremetal.cpp +++ b/clang/test/Driver/baremetal.cpp @@ -102,6 +102,16 @@ // RUN: | FileCheck %s --check-prefix=CHECK-SYSROOT-INC // CHECK-SYSROOT-INC-NOT: "-internal-isystem" "include" +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target aarch64-none-elf \ +// RUN: | FileCheck --check-prefix=CHECK-AARCH64-NO-HOST-INC %s +// Verify that the bare metal driver does not include any host system paths: +// CHECK-AARCH64-NO-HOST-INC: InstalledDir: [[INSTALLEDDIR:.+]] +// CHECK-AARCH64-NO-HOST-INC: "-resource-dir" "[[RESOURCE:[^"]+]]" +// CHECK-AARCH64-NO-HOST-INC-SAME: "-internal-isystem" "[[INSTALLEDDIR]]/../lib/clang-runtimes/aarch64-none-elf/include/c++/v1" +// CHECK-AARCH64-NO-HOST-INC-SAME: "-internal-isystem" "[[RESOURCE]]/include" +// CHECK-AARCH64-NO-HOST-INC-SAME: "-internal-isystem" "[[INSTALLEDDIR]]/../lib/clang-runtimes/aarch64-none-elf/include" + // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target riscv64-unknown-elf \ // RUN: -L some/directory/user/asked/for \ diff --git a/clang/test/Driver/gcc_forward.c b/clang/test/Driver/gcc_forward.c --- a/clang/test/Driver/gcc_forward.c +++ b/clang/test/Driver/gcc_forward.c @@ -1,4 +1,4 @@ -// RUN: %clang -### %s -target aarch64-none-elf \ +// RUN: %clang -### %s -target x86-none-elf \ // RUN: --coverage -e _start -fuse-ld=lld --ld-path=ld -nostartfiles \ // RUN: -nostdlib -r -rdynamic -specs=nosys.specs -static -static-pie \ // RUN: 2>&1 | FileCheck --check-prefix=FORWARD %s