[Concept,08/13] ulib: riscv: Enable Rust demo for qemu-riscv64

Message ID 20260220001926.2366140-9-sjg@u-boot.org
State New
Headers
Series ulib: Enable the Rust demo on more architectures |

Commit Message

Simon Glass Feb. 20, 2026, 12:19 a.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

The Rust ulib demo currently works on x86 (32-bit and 64-bit) but not
on RISC-V. Unlike x86, RISC-V has no calling-convention mismatch, so
Rust's extern "C" naturally matches the standard ABI with no extra
flags.

Add the riscv64gc-unknown-none-elf built-in Rust target (which already
has panic-strategy: abort) and enable CONFIG_RUST_EXAMPLES in the
qemu-riscv64 defconfig so that rust-demo.bin is produced alongside
demo.bin

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---

 configs/qemu-riscv64_defconfig | 1 +
 scripts/Makefile.ulib-example  | 2 ++
 2 files changed, 3 insertions(+)
  

Patch

diff --git a/configs/qemu-riscv64_defconfig b/configs/qemu-riscv64_defconfig
index 4423d36b782..d30b017169e 100644
--- a/configs/qemu-riscv64_defconfig
+++ b/configs/qemu-riscv64_defconfig
@@ -24,3 +24,4 @@  CONFIG_UTHREAD=y
 CONFIG_UNIT_TEST=y
 CONFIG_ULIB=y
 CONFIG_EXAMPLES=y
+CONFIG_RUST_EXAMPLES=y
diff --git a/scripts/Makefile.ulib-example b/scripts/Makefile.ulib-example
index a398f3e9621..ae3f75b33fb 100644
--- a/scripts/Makefile.ulib-example
+++ b/scripts/Makefile.ulib-example
@@ -25,6 +25,8 @@  RUST_TARGET_x86 := i686-unknown-linux-gnu
 RUST_TARGET_x86_64 := x86_64-unknown-none
 RUST_FLAGS_x86 := -C panic=abort -C relocation-model=static
 RUST_FLAGS_x86_64 :=
+RUST_TARGET_riscv := riscv64gc-unknown-none-elf
+RUST_FLAGS_riscv :=
 
 ifdef CONFIG_X86_64
 RUST_TARGET := $(RUST_TARGET_$(EXAMPLE_ARCH)_64)