On Sun, Apr 26, 2026 at 04:29:31PM +0530, Mukesh Kumar Chaurasiya (IBM) wrote:
> From: Link Mauve <[email protected]>
> 
> 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 <[email protected]>
> Link: https://github.com/Rust-for-Linux/linux/issues/105
> Link: https://github.com/linuxppc/issues/issues/451
> Acked-by: Gary Guo <[email protected]>
> Signed-off-by: Mukesh Kumar Chaurasiya (IBM) <[email protected]>

Upstream Issue for powerpc target.
Link: https://github.com/rust-lang/compiler-team/issues/986

Regards,
Mukesh
> ---
>  arch/powerpc/Kconfig  | 1 +
>  arch/powerpc/Makefile | 2 ++
>  rust/Makefile         | 4 +++-
>  3 files changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index e93df95b79e7..4ac897b650d4 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -285,6 +285,7 @@ config PPC
>       select HAVE_REGS_AND_STACK_ACCESS_API
>       select HAVE_RELIABLE_STACKTRACE
>       select HAVE_RSEQ
> +     select HAVE_RUST                        if PPC32
>       select HAVE_SAMPLE_FTRACE_DIRECT        if 
> HAVE_DYNAMIC_FTRACE_WITH_DIRECT_CALLS
>       select HAVE_SAMPLE_FTRACE_DIRECT_MULTI  if 
> HAVE_DYNAMIC_FTRACE_WITH_DIRECT_CALLS
>       select HAVE_SETUP_PER_CPU_AREA          if PPC64
> diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
> index a58b1029592c..589613eaa5dc 100644
> --- a/arch/powerpc/Makefile
> +++ b/arch/powerpc/Makefile
> @@ -61,6 +61,8 @@ else
>  KBUILD_LDFLAGS_MODULE += $(objtree)/arch/powerpc/lib/crtsavres.o
>  endif
>  
> +KBUILD_RUSTFLAGS     += --target=powerpc-unknown-linux-gnu
> +
>  ifdef CONFIG_CPU_LITTLE_ENDIAN
>  KBUILD_CPPFLAGS      += -mlittle-endian
>  KBUILD_LDFLAGS       += -EL
> diff --git a/rust/Makefile b/rust/Makefile
> index d70fb186cae9..54096ce8a675 100644
> --- a/rust/Makefile
> +++ b/rust/Makefile
> @@ -400,13 +400,15 @@ bindgen_skip_c_flags := -mno-fp-ret-in-387 
> -mpreferred-stack-boundary=% \
>       -fstrict-flex-arrays=% -fmin-function-alignment=% \
>       -fzero-init-padding-bits=% -mno-fdpic \
>       -fdiagnostics-show-context -fdiagnostics-show-context=% \
> -     --param=% --param asan-% -fno-isolate-erroneous-paths-dereference
> +     --param=% --param asan-% -fno-isolate-erroneous-paths-dereference \
> +     -ffixed-r2 -mmultiple -mno-readonly-in-sdata
>  
>  # Derived from `scripts/Makefile.clang`.
>  BINDGEN_TARGET_x86   := x86_64-linux-gnu
>  BINDGEN_TARGET_arm64 := aarch64-linux-gnu
>  BINDGEN_TARGET_arm   := arm-linux-gnueabi
>  BINDGEN_TARGET_loongarch     := loongarch64-linux-gnusf
> +BINDGEN_TARGET_powerpc       := powerpc-linux-gnu
>  BINDGEN_TARGET_um    := $(BINDGEN_TARGET_$(SUBARCH))
>  BINDGEN_TARGET               := $(BINDGEN_TARGET_$(SRCARCH))
>  
> -- 
> 2.53.0
> 

Reply via email to