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]>
Link: https://github.com/rust-lang/compiler-team/issues/986
Signed-off-by: Mukesh Kumar Chaurasiya (IBM) <[email protected]>
---
 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 f7ce5fff81f0..badd7c99b87f 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 7aa8fcad4c43..61e7dc496fe4 100644
--- a/rust/Makefile
+++ b/rust/Makefile
@@ -448,7 +448,8 @@ 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
@@ -458,6 +459,7 @@ BINDGEN_TARGET_loongarch    := loongarch64-linux-gnusf
 BINDGEN_TARGET_s390    := s390x-linux-gnu
 # This is only for i386 UM builds, which need the 32-bit target not -m32
 BINDGEN_TARGET_i386    := i386-linux-gnu
+BINDGEN_TARGET_powerpc := powerpc-linux-gnu
 BINDGEN_TARGET_um      := $(BINDGEN_TARGET_$(SUBARCH))
 BINDGEN_TARGET         := $(BINDGEN_TARGET_$(SRCARCH))
 
-- 
2.55.0


Reply via email to