From: Simon Glass <simon.glass@canonical.com> There is no built-in i686-unknown-none Rust target, so use i686-unknown-linux-gnu with flags to disable unwinding and force static relocations, which produces a clean freestanding ELF 32-bit object suitable for linking into U-Boot. Select the Rust target and flags based on CONFIG_X86_64 so that the 64-bit build continues to use x86_64-unknown-none with its built-in defaults (PIE-compatible code, no unwinding). Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- scripts/Makefile.ulib-example | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/scripts/Makefile.ulib-example b/scripts/Makefile.ulib-example index 4d8af88b898..a398f3e9621 100644 --- a/scripts/Makefile.ulib-example +++ b/scripts/Makefile.ulib-example @@ -21,8 +21,18 @@ ULIB_EXAMPLES := demo # --- Rust examples --- RUSTC := rustc -RUST_TARGET_x86 := x86_64-unknown-none +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 := + +ifdef CONFIG_X86_64 +RUST_TARGET := $(RUST_TARGET_$(EXAMPLE_ARCH)_64) +RUST_FLAGS := $(RUST_FLAGS_$(EXAMPLE_ARCH)_64) +else RUST_TARGET := $(RUST_TARGET_$(EXAMPLE_ARCH)) +RUST_FLAGS := $(RUST_FLAGS_$(EXAMPLE_ARCH)) +endif ifeq ($(CONFIG_RUST_EXAMPLES),y) ULIB_EXAMPLES += rust-demo @@ -34,7 +44,8 @@ quiet_cmd_u-boot-example = LD $@ quiet_cmd_rustc_obj = RUSTC $@ cmd_rustc_obj = \ mkdir -p $(dir $@) && \ - MAKEFLAGS= $(RUSTC) --edition 2021 --emit=obj -o $@ --target=$(RUST_TARGET) $< + MAKEFLAGS= $(RUSTC) --edition 2021 --emit=obj -o $@ \ + --target=$(RUST_TARGET) $(RUST_FLAGS) $< examples/ulib/rust_demo.o: examples/ulib/rust_demo.rs FORCE $(call if_changed,rustc_obj) -- 2.43.0