Skip to content

Commit

Permalink
Add custom Rust target supporting bitmanip extensions
Browse files Browse the repository at this point in the history
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
```
  • Loading branch information
jwnrt committed Aug 22, 2024
1 parent bce6eff commit ce5329a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion sw/rust/.cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion sw/rust/demo/hello_world/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions sw/rust/riscv32imcb-unknown-none-elf.json
Original file line number Diff line number Diff line change
@@ -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"
}
2 changes: 1 addition & 1 deletion sw/rust/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
targets = ["riscv32imc-unknown-none-elf"]
channel = "nightly"
components = ["rust-src"]

0 comments on commit ce5329a

Please sign in to comment.