[PATCH] D111134: Add basic aarch64-none-elf bare metal driver.
Kristof Beyls via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 7 05:59:33 PDT 2021
kristof.beyls updated this revision to Diff 377816.
kristof.beyls added a comment.
Updated test based on feedback from @MaskRay
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D111134/new/
https://reviews.llvm.org/D111134
Files:
clang/lib/Driver/ToolChains/BareMetal.cpp
clang/test/Driver/baremetal.cpp
clang/test/Driver/gcc_forward.c
Index: clang/test/Driver/gcc_forward.c
===================================================================
--- clang/test/Driver/gcc_forward.c
+++ 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
Index: clang/test/Driver/baremetal.cpp
===================================================================
--- clang/test/Driver/baremetal.cpp
+++ clang/test/Driver/baremetal.cpp
@@ -102,6 +102,17 @@
// 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 \
Index: clang/lib/Driver/ToolChains/BareMetal.cpp
===================================================================
--- clang/lib/Driver/ToolChains/BareMetal.cpp
+++ clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -125,6 +125,21 @@
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 +166,8 @@
}
bool BareMetal::handlesTarget(const llvm::Triple &Triple) {
- return isARMBareMetal(Triple) || isRISCVBareMetal(Triple);
+ return isARMBareMetal(Triple) || isAArch64BareMetal(Triple) ||
+ isRISCVBareMetal(Triple);
}
Tool *BareMetal::buildLinker() const {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111134.377816.patch
Type: text/x-patch
Size: 2758 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211007/d51c3715/attachment.bin>
More information about the cfe-commits
mailing list