Skip to content

Commit b964fb2

Browse files
linkmauvemaddy-kerneldev
authored andcommitted
rust: Add PowerPC support
For now only Big Endian 32-bit PowerPC is supported, as that is the only hardware I have. This has been tested on the Nintendo Wii so far, but I plan on also using it on the GameCube, Wii U and Apple G4. These changes aren’t the only ones required to get the kernel to compile and link on PowerPC, libcore will also have to be changed to not use integer division to format u64, u128 and core::time::Duration, otherwise __udivdi3() and __umoddi3() will have to be added. I have tested this change by replacing the three implementations with unimplemented!() and it linked just fine. Signed-off-by: Link Mauve <linkmauve@linkmauve.fr> Signed-off-by: Mukesh Kumar Chaurasiya (IBM) <mkchauras@gmail.com> Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com> Link: https://patch.msgid.link/20260210090023.2587534-3-mkchauras@gmail.com
1 parent 3263451 commit b964fb2

4 files changed

Lines changed: 7 additions & 1 deletion

File tree

Documentation/rust/arch-support.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Architecture Level of support Constraints
1818
``arm`` Maintained ARMv7 Little Endian only.
1919
``arm64`` Maintained Little Endian only.
2020
``loongarch`` Maintained \-
21+
``powerpc`` Maintained 32-bit Big Endian only.
2122
``riscv`` Maintained ``riscv64`` and LLVM/Clang only.
2223
``um`` Maintained \-
2324
``x86`` Maintained ``x86_64`` only.

arch/powerpc/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ config PPC
284284
select HAVE_REGS_AND_STACK_ACCESS_API
285285
select HAVE_RELIABLE_STACKTRACE
286286
select HAVE_RSEQ
287+
select HAVE_RUST if PPC32
287288
select HAVE_SAMPLE_FTRACE_DIRECT if HAVE_DYNAMIC_FTRACE_WITH_DIRECT_CALLS
288289
select HAVE_SAMPLE_FTRACE_DIRECT_MULTI if HAVE_DYNAMIC_FTRACE_WITH_DIRECT_CALLS
289290
select HAVE_SETUP_PER_CPU_AREA if PPC64

arch/powerpc/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ else
6161
KBUILD_LDFLAGS_MODULE += $(objtree)/arch/powerpc/lib/crtsavres.o
6262
endif
6363

64+
KBUILD_RUSTFLAGS += --target=powerpc-unknown-linux-gnu
65+
6466
ifdef CONFIG_CPU_LITTLE_ENDIAN
6567
KBUILD_CPPFLAGS += -mlittle-endian
6668
KBUILD_LDFLAGS += -EL

rust/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,13 +402,15 @@ bindgen_skip_c_flags := -mno-fp-ret-in-387 -mpreferred-stack-boundary=% \
402402
-fstrict-flex-arrays=% -fmin-function-alignment=% \
403403
-fzero-init-padding-bits=% -mno-fdpic \
404404
-fdiagnostics-show-context -fdiagnostics-show-context=% \
405-
--param=% --param asan-% -fno-isolate-erroneous-paths-dereference
405+
--param=% --param asan-% -fno-isolate-erroneous-paths-dereference \
406+
-ffixed-r2 -mmultiple -mno-readonly-in-sdata
406407

407408
# Derived from `scripts/Makefile.clang`.
408409
BINDGEN_TARGET_x86 := x86_64-linux-gnu
409410
BINDGEN_TARGET_arm64 := aarch64-linux-gnu
410411
BINDGEN_TARGET_arm := arm-linux-gnueabi
411412
BINDGEN_TARGET_loongarch := loongarch64-linux-gnusf
413+
BINDGEN_TARGET_powerpc := powerpc-linux-gnu
412414
BINDGEN_TARGET_um := $(BINDGEN_TARGET_$(SUBARCH))
413415
BINDGEN_TARGET := $(BINDGEN_TARGET_$(SRCARCH))
414416

0 commit comments

Comments
 (0)