From fd6e636cc18a087a90c3000eb2f9221a56429240 Mon Sep 17 00:00:00 2001 From: James Wainwright Date: Thu, 22 Aug 2024 11:20:09 +0100 Subject: [PATCH] Enable supported bitmanip extensions for Rust demos Ibex supports a few more bitmanip extensions but they're not supported in upstream LLVM / Rust. --- sw/rust/.cargo/config.toml | 3 +++ sw/rust/demo/hello_world/README.md | 2 +- sw/rust/riscv32imcb-unknown-none-elf.json | 23 +++++++++++++++++++++++ sw/rust/rust-toolchain.toml | 2 +- 4 files changed, 28 insertions(+), 2 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..f98cc883 100644 --- a/sw/rust/.cargo/config.toml +++ b/sw/rust/.cargo/config.toml @@ -5,6 +5,9 @@ [build] target = "riscv32imc-unknown-none-elf" +# Enable supported bitmanip extension features. +rustflags = ["-Ctarget-feature=+zba,+zbb,+zbc,+zbs"] + [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..f70d2254 100644 --- a/sw/rust/rust-toolchain.toml +++ b/sw/rust/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -targets = ["riscv32imc-unknown-none-elf"] channel = "nightly" +components = ["rust-src"]