Add cheriot-baremetal toolchain support This adds support for the cheriot-baremetal ABI intended for code that runs before the CHERIoT loader. This can be selected using --config=cheriot-baremetal on the cmd line. Change-Id: I86a1c4b9b68292cba2708b3c4e50e456c35b87ff
diff --git a/.bazelrc b/.bazelrc index bf3b43b..daac0b0 100644 --- a/.bazelrc +++ b/.bazelrc
@@ -28,6 +28,7 @@ build:kelvin --platforms=//platforms/riscv32:kelvin build:sparrow --platforms=@matcha//platforms/riscv32:sparrow build:cheriot --platforms=@matcha//platforms/cheri/riscv32:cheriot +build:cheriot-baremetal --platforms=@matcha//platforms/cheri/riscv32:cheriot-baremetal # Support airgapped build environment build:airgapped_env --//rules:build_env='airgapped'
diff --git a/constraints/extension/BUILD.bazel b/constraints/extension/BUILD.bazel index f92a5c9..63ba63b 100644 --- a/constraints/extension/BUILD.bazel +++ b/constraints/extension/BUILD.bazel
@@ -6,3 +6,7 @@ name = "cheri", constraint_setting = ":extension", ) +constraint_value( + name = "cheri-baremetal", + constraint_setting = ":extension", +)
diff --git a/platforms/cheri/riscv32/BUILD.bazel b/platforms/cheri/riscv32/BUILD.bazel index 0a72252..14ca641 100644 --- a/platforms/cheri/riscv32/BUILD.bazel +++ b/platforms/cheri/riscv32/BUILD.bazel
@@ -7,3 +7,10 @@ "//constraints/extension:cheri", ], ) +platform( + name = "cheriot-baremetal", + constraint_values = [ + "@platforms//cpu:riscv32", + "//constraints/extension:cheri-baremetal", + ], +)
diff --git a/platforms/cheri/riscv32/devices.bzl b/platforms/cheri/riscv32/devices.bzl index a0670c2..31a928f 100644 --- a/platforms/cheri/riscv32/devices.bzl +++ b/platforms/cheri/riscv32/devices.bzl
@@ -25,4 +25,27 @@ ), }, ), + device_config( + name = "cheriot-baremetal", + architecture = "rv32imcxcheri", + feature_set = "//platforms/cheri/riscv32/features:rv32imcxcheri", + constraints = [ + "@platforms//cpu:riscv32", + "//constraints/extension:cheri-baremetal", + ], + substitutions = { + "ARCHITECTURE": "rv32imcxcheri", + "ABI": "cheriot-baremetal", + "CMODEL": "medany", + "ENDIAN": "little", + "TARGET": "riscv32-unknown-elf", + "[STACK_PROTECTOR]": "", + "[SYSTEM_LIBRARY_PATHS]": listify_flags( + "-L{}", + [ + "external/cheriot-llvm/baremetal/baremetal-riscv32-purecap/riscv32-unknown-elf/lib/", + ], + ), + }, + ), ]