From ed810e18823a75979e8d198e2b9f02e12c1dc9a9 Mon Sep 17 00:00:00 2001 From: James Wainwright Date: Thu, 22 Aug 2024 11:20:09 +0100 Subject: [PATCH] Add custom Rust target supporting bitmanip extensions This target description is the same as `riscv32imc-unknown-none-elf` but with the `Zba`, `Zbb`, `Zbs` (collectively `B`), and `Zbc` extensions enabled. Ibex supports more, but upstream LLVM does not. You can check the built-in `riscv32imc-unknown-none-elf` JSON file to compare against using this command: ```sh rustc +nightly \ -Z unstable-options \ --target=riscv32imc-unknown-none-elf \ --print target-spec-json ``` --- sw/rust/.cargo/config.toml | 2 +- sw/rust/demo/hello_world/README.md | 2 +- sw/rust/riscv32imcb-unknown-none-elf.json | 23 +++++++++++++++++++++++ sw/rust/rust-toolchain.toml | 1 - 4 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 sw/rust/riscv32imcb-unknown-none-elf.json diff --git a/sw/rust/.cargo/config.toml b/sw/rust/.cargo/config.toml index 60b2a756..9528254e 100644 --- a/sw/rust/.cargo/config.toml +++ b/sw/rust/.cargo/config.toml @@ -3,7 +3,7 @@ # SPDX-License-Identifier: Apache-2.0 [build] -target = "riscv32imc-unknown-none-elf" +target = "riscv32imcb-unknown-none-elf.json" [target.riscv32imc-unknown-none-elf] runner = "../../util/load_demo_system.sh run" diff --git a/sw/rust/demo/hello_world/README.md b/sw/rust/demo/hello_world/README.md index 13596567..9aa41ebd 100644 --- a/sw/rust/demo/hello_world/README.md +++ b/sw/rust/demo/hello_world/README.md @@ -9,7 +9,7 @@ How to run this demo: 4. Run the gdb: ```console -$ riscv32-unknown-elf-gdb ../../target/riscv32imc-unknown-none-elf/debug/led +$ riscv32-unknown-elf-gdb ../../target/riscv32imcb-unknown-none-elf/debug/led (gdb) # Connect to OpenOCD (gdb) target remote :3333 diff --git a/sw/rust/riscv32imcb-unknown-none-elf.json b/sw/rust/riscv32imcb-unknown-none-elf.json new file mode 100644 index 00000000..0ce2d53f --- /dev/null +++ b/sw/rust/riscv32imcb-unknown-none-elf.json @@ -0,0 +1,23 @@ +{ + "arch": "riscv32", + "atomic-cas": false, + "cpu": "generic-rv32", + "crt-objects-fallback": "false", + "data-layout": "e-m:e-p:32:32-i64:64-n32-S128", + "eh-frame-header": false, + "emit-debug-gdb-scripts": false, + "features": "+m,+c,+zba,+zbb,+zbc,+zbs,+forced-atomics", + "is-builtin": false, + "linker": "rust-lld", + "linker-flavor": "gnu-lld", + "llvm-target": "riscv32", + "max-atomic-width": 32, + "metadata": { + "description": "Bare RISC-V (RV32IMCBZbc ISA)", + "host_tools": false, + "std": false + }, + "panic-strategy": "abort", + "relocation-model": "static", + "target-pointer-width": "32" +} diff --git a/sw/rust/rust-toolchain.toml b/sw/rust/rust-toolchain.toml index 5269f09c..5d56faf9 100644 --- a/sw/rust/rust-toolchain.toml +++ b/sw/rust/rust-toolchain.toml @@ -1,3 +1,2 @@ [toolchain] -targets = ["riscv32imc-unknown-none-elf"] channel = "nightly"