[PATCH] powerpc: Enable Rust for ppc64le

Mukesh Kumar Chaurasiya (IBM) posted 1 patch 3 days, 10 hours ago
arch/powerpc/Kconfig                  |  1 +
arch/powerpc/Makefile                 |  9 +++++----
arch/powerpc/include/asm/jump_label.h | 23 +++++++++++++----------
rust/Makefile                         |  1 +
scripts/generate_rust_target.rs       | 24 ++++++++++++++++++++++++
5 files changed, 44 insertions(+), 14 deletions(-)
[PATCH] powerpc: Enable Rust for ppc64le
Posted by Mukesh Kumar Chaurasiya (IBM) 3 days, 10 hours ago
Enabling rust support for ppc64 only.

To support rust a new macro ARCH_STATIC_BRANCH_ASM in powerpc
is added to avoid duplication of inline asm between C and Rust.
This is inline with commit
aecaf181651c '("jump_label: adjust inline asm to be consistent")'

Tested on powernv9:

$ uname -rm
6.19.0-rc8+ ppc64le

$ sudo modprobe rust_minimal
[  632.890850] rust_minimal: Rust minimal sample (init)
[  632.890881] rust_minimal: Am I built-in? false
[  632.890898] rust_minimal: test_parameter: 1

$ sudo rmmod rust_minimal
[  648.272832] rust_minimal: My numbers are [72, 108, 200]
[  648.272873] rust_minimal: Rust minimal sample (exit)

$ sudo modprobe rust_print
[  843.410391] rust_print: Rust printing macros sample (init)
[  843.410424] rust_print: Emergency message (level 0) without args
[  843.410451] rust_print: Alert message (level 1) without args
[  843.410477] rust_print: Critical message (level 2) without args
[  843.410503] rust_print: Error message (level 3) without args
[  843.410530] rust_print: Warning message (level 4) without args
[  843.410557] rust_print: Notice message (level 5) without args
[  843.410594] rust_print: Info message (level 6) without args
[  843.410617] rust_print: A line that is continued without args
[  843.410646] rust_print: Emergency message (level 0) with args
[  843.410675] rust_print: Alert message (level 1) with args
[  843.410691] rust_print: Critical message (level 2) with args
[  843.410727] rust_print: Error message (level 3) with args
[  843.410761] rust_print: Warning message (level 4) with args
[  843.410796] rust_print: Notice message (level 5) with args
[  843.410821] rust_print: Info message (level 6) with args
[  843.410854] rust_print: A line that is continued with args
[  843.410892] rust_print: 1
[  843.410895] rust_print: "hello, world"
[  843.410924] rust_print: [samples/rust/rust_print_main.rs:35:5] c = "hello, world"
[  843.410977] rust_print: Arc<dyn Display> says 42
[  843.410979] rust_print: Arc<dyn Display> says hello, world

$ sudo rmmod rust_print
[  843.411003] rust_print: "hello, world"
[  888.499935] rust_print: Rust printing macros sample (exit)

Signed-off-by: Mukesh Kumar Chaurasiya (IBM) <mkchauras@gmail.com>
---
 arch/powerpc/Kconfig                  |  1 +
 arch/powerpc/Makefile                 |  9 +++++----
 arch/powerpc/include/asm/jump_label.h | 23 +++++++++++++----------
 rust/Makefile                         |  1 +
 scripts/generate_rust_target.rs       | 24 ++++++++++++++++++++++++
 5 files changed, 44 insertions(+), 14 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 9537a61ebae0..e9b8d761ed52 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -285,6 +285,7 @@ config PPC
 	select HAVE_RSEQ
 	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_RUST			if PPC64
 	select HAVE_SETUP_PER_CPU_AREA		if PPC64
 	select HAVE_SOFTIRQ_ON_OWN_STACK
 	select HAVE_STACKPROTECTOR		if PPC32 && $(cc-option,$(m32-flag) -mstack-protector-guard=tls -mstack-protector-guard-reg=r2 -mstack-protector-guard-offset=0)
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index a58b1029592c..7ad28cf0fd35 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -172,10 +172,11 @@ CFLAGS-y += $(CONFIG_TUNE_CPU)
 
 asinstr := $(call as-instr,lis 9$(comma)foo@high,-DHAVE_AS_ATHIGH=1)
 
-KBUILD_CPPFLAGS	+= -I $(srctree)/arch/powerpc $(asinstr)
-KBUILD_AFLAGS	+= $(AFLAGS-y)
-KBUILD_CFLAGS	+= $(CC_FLAGS_NO_FPU)
-KBUILD_CFLAGS	+= $(CFLAGS-y)
+KBUILD_CPPFLAGS		+= -I $(srctree)/arch/powerpc $(asinstr)
+KBUILD_AFLAGS		+= $(AFLAGS-y)
+KBUILD_CFLAGS		+= $(CC_FLAGS_NO_FPU)
+KBUILD_CFLAGS		+= $(CFLAGS-y)
+KBUILD_RUSTFLAGS        += -Ctarget-feature=-mma,-vsx,-hard-float,-altivec
 
 CHECKFLAGS	+= -m$(BITS) -D__powerpc__ -D__powerpc$(BITS)__
 ifdef CONFIG_CPU_BIG_ENDIAN
diff --git a/arch/powerpc/include/asm/jump_label.h b/arch/powerpc/include/asm/jump_label.h
index d4eaba459a0e..a6b211502bfe 100644
--- a/arch/powerpc/include/asm/jump_label.h
+++ b/arch/powerpc/include/asm/jump_label.h
@@ -15,14 +15,20 @@
 #define JUMP_ENTRY_TYPE		stringify_in_c(FTR_ENTRY_LONG)
 #define JUMP_LABEL_NOP_SIZE	4
 
+#define JUMP_TABLE_ENTRY(key, label)			\
+	".pushsection __jump_table,  \"aw\"	\n\t"	\
+	".long 1b - ., " label " - .		\n\t"	\
+	JUMP_ENTRY_TYPE key " - .		\n\t"	\
+	".popsection 				\n\t"
+
+#define ARCH_STATIC_BRANCH_ASM(key, label)		\
+	"1:	nop				\n\t"	\
+	JUMP_TABLE_ENTRY(key,label)
+
 static __always_inline bool arch_static_branch(struct static_key *key, bool branch)
 {
-	asm goto("1:\n\t"
-		 "nop # arch_static_branch\n\t"
-		 ".pushsection __jump_table,  \"aw\"\n\t"
-		 ".long 1b - ., %l[l_yes] - .\n\t"
-		 JUMP_ENTRY_TYPE "%c0 - .\n\t"
-		 ".popsection \n\t"
+	asm goto(
+		 ARCH_STATIC_BRANCH_ASM("%c0", "%l[l_yes]")
 		 : :  "i" (&((char *)key)[branch]) : : l_yes);
 
 	return false;
@@ -34,10 +40,7 @@ static __always_inline bool arch_static_branch_jump(struct static_key *key, bool
 {
 	asm goto("1:\n\t"
 		 "b %l[l_yes] # arch_static_branch_jump\n\t"
-		 ".pushsection __jump_table,  \"aw\"\n\t"
-		 ".long 1b - ., %l[l_yes] - .\n\t"
-		 JUMP_ENTRY_TYPE "%c0 - .\n\t"
-		 ".popsection \n\t"
+		 JUMP_TABLE_ENTRY("%c0", "%l[l_yes]")
 		 : :  "i" (&((char *)key)[branch]) : : l_yes);
 
 	return false;
diff --git a/rust/Makefile b/rust/Makefile
index 5d357dce1704..7a6daa822cbc 100644
--- a/rust/Makefile
+++ b/rust/Makefile
@@ -390,6 +390,7 @@ 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	:= powerpc64le-linux-gnu
 BINDGEN_TARGET_um	:= $(BINDGEN_TARGET_$(SUBARCH))
 BINDGEN_TARGET		:= $(BINDGEN_TARGET_$(SRCARCH))
 
diff --git a/scripts/generate_rust_target.rs b/scripts/generate_rust_target.rs
index 38b3416bb979..875579b37424 100644
--- a/scripts/generate_rust_target.rs
+++ b/scripts/generate_rust_target.rs
@@ -256,6 +256,30 @@ fn main() {
         }
     } else if cfg.has("LOONGARCH") {
         panic!("loongarch uses the builtin rustc loongarch64-unknown-none-softfloat target");
+    } else if cfg.has("PPC64") {
+        ts.push("arch", "powerpc64");
+        ts.push(
+            "data-layout",
+            if cfg.has("CPU_LITTLE_ENDIAN") {
+                "e-m:e-Fn32-i64:64-n32:64-S128-v256:256:256-v512:512:512"
+            } else {
+                "E-m:e-Fn32-i64:64-n32:64-S128-v256:256:256-v512:512:512"
+            },
+        );
+        ts.push("features", "-mma,-altivec,-vsx,-hard-float");
+        ts.push(
+            "llvm-target",
+            if cfg.has("CPU_LITTLE_ENDIAN") {
+                "powerpc64le-linux-gnu"
+            } else {
+                "powerpc64-linux-gnu"
+            },
+        );
+        if cfg.rustc_version_atleast(1, 91, 0) {
+            ts.push("target-pointer-width", 64);
+        } else {
+            ts.push("target-pointer-width", "64");
+        }
     } else {
         panic!("Unsupported architecture");
     }
-- 
2.52.0
Re: [PATCH] powerpc: Enable Rust for ppc64le
Posted by Miguel Ojeda 2 days, 21 hours ago
On Wed, Feb 4, 2026 at 6:54 AM Mukesh Kumar Chaurasiya (IBM)
<mkchauras@gmail.com> wrote:
>
> +    } else if cfg.has("PPC64") {

Can this be done via flags, i.e. avoiding the `target.json`?

We are trying to avoid adding new custom targets, since the idea is to
remove our reliance on `target.json`.

If it is not possible to do it via flags only, then we should talk to
upstream to add the needed flags or perhaps a new built-in target.

Thanks!

(By the way, Michael back in 2021 did the original integration of
ppc64le before Rust was merged into mainline -- he may want to take a
look at this :) I see he is in Cc).

Cheers,
Miguel
Re: [PATCH] powerpc: Enable Rust for ppc64le
Posted by Mukesh Kumar Chaurasiya 2 days, 21 hours ago
On Wed, Feb 04, 2026 at 06:49:23PM +0100, Miguel Ojeda wrote:
> On Wed, Feb 4, 2026 at 6:54 AM Mukesh Kumar Chaurasiya (IBM)
> <mkchauras@gmail.com> wrote:
> >
> > +    } else if cfg.has("PPC64") {
> 
> Can this be done via flags, i.e. avoiding the `target.json`?
> 
yeah sure. I'll do that.
> We are trying to avoid adding new custom targets, since the idea is to
> remove our reliance on `target.json`.
> 
> If it is not possible to do it via flags only, then we should talk to
> upstream to add the needed flags or perhaps a new built-in target.
> 
> Thanks!
> 
> (By the way, Michael back in 2021 did the original integration of
> ppc64le before Rust was merged into mainline -- he may want to take a
> look at this :) I see he is in Cc).
> 
> Cheers,
> Miguel
Re: [PATCH] powerpc: Enable Rust for ppc64le
Posted by Christophe Leroy (CS GROUP) 2 days, 22 hours ago
Hi Mukesh, hi Link,

Le 04/02/2026 à 05:24, Mukesh Kumar Chaurasiya (IBM) a écrit :
> [Vous ne recevez pas souvent de courriers de mkchauras@gmail.com. Découvrez pourquoi ceci est important à https://aka.ms/LearnAboutSenderIdentification ]
> 
> Enabling rust support for ppc64 only.

Link Mauve has sent a patch for rust support on PPC32 a few hours before 
you, see 
https://lore.kernel.org/r/20260204030507.8203-1-linkmauve@linkmauve.fr
Could you coordinate together to provide something supporting both PPC32 
and PPC64 ?

I see the following conflicts at the time being. I also have a few 
comments down.

diff --git a/Documentation/rust/arch-support.rst 
b/Documentation/rust/arch-support.rst
index 6e6a515d0899..70b9e192a7a0 100644
--- a/Documentation/rust/arch-support.rst
+++ b/Documentation/rust/arch-support.rst
@@ -18,6 +18,7 @@ Architecture   Level of support  Constraints
  ``arm``        Maintained        ARMv7 Little Endian only.
  ``arm64``      Maintained        Little Endian only.
  ``loongarch``  Maintained        \-
+``powerpc``    Maintained        32-bit Big Endian only.
  ``riscv``      Maintained        ``riscv64`` and LLVM/Clang only.
  ``um``         Maintained        \-
  ``x86``        Maintained        ``x86_64`` only.
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index b8d36a261009..80b2666fc5af 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -283,8 +283,10 @@ 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_RUST			if PPC64
  	select HAVE_SETUP_PER_CPU_AREA		if PPC64
  	select HAVE_SOFTIRQ_ON_OWN_STACK
  	select HAVE_STACKPROTECTOR		if PPC32 && $(cc-option,$(m32-flag) 
-mstack-protector-guard=tls -mstack-protector-guard-reg=r2 
-mstack-protector-guard-offset=0)
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index a58b1029592c..ac6fe8cc4ece 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
@@ -172,10 +174,11 @@ CFLAGS-y += $(CONFIG_TUNE_CPU)

  asinstr := $(call as-instr,lis 9$(comma)foo@high,-DHAVE_AS_ATHIGH=1)

-KBUILD_CPPFLAGS	+= -I $(srctree)/arch/powerpc $(asinstr)
-KBUILD_AFLAGS	+= $(AFLAGS-y)
-KBUILD_CFLAGS	+= $(CC_FLAGS_NO_FPU)
-KBUILD_CFLAGS	+= $(CFLAGS-y)
+KBUILD_CPPFLAGS		+= -I $(srctree)/arch/powerpc $(asinstr)
+KBUILD_AFLAGS		+= $(AFLAGS-y)
+KBUILD_CFLAGS		+= $(CC_FLAGS_NO_FPU)
+KBUILD_CFLAGS		+= $(CFLAGS-y)
+KBUILD_RUSTFLAGS        += -Ctarget-feature=-mma,-vsx,-hard-float,-altivec

  CHECKFLAGS	+= -m$(BITS) -D__powerpc__ -D__powerpc$(BITS)__
  ifdef CONFIG_CPU_BIG_ENDIAN
diff --git a/arch/powerpc/include/asm/jump_label.h 
b/arch/powerpc/include/asm/jump_label.h
index d4eaba459a0e..d2284c72d21b 100644
--- a/arch/powerpc/include/asm/jump_label.h
+++ b/arch/powerpc/include/asm/jump_label.h
@@ -15,14 +15,35 @@
  #define JUMP_ENTRY_TYPE		stringify_in_c(FTR_ENTRY_LONG)
  #define JUMP_LABEL_NOP_SIZE	4

+<<<<<<< HEAD
+/* This macro is also expanded on the Rust side. */
+#define ARCH_STATIC_BRANCH_ASM(key, label)		\
+	"1:\n\t"					\
+	"nop # arch_static_branch\n\t"			\
+	".pushsection __jump_table,  \"aw\"\n\t"	\
+	".long 1b - ., " label " - .\n\t"		\
+	 JUMP_ENTRY_TYPE key " - .\n\t"			\
+	 ".popsection \n\t"
+
  static __always_inline bool arch_static_branch(struct static_key *key, 
bool branch)
  {
-	asm goto("1:\n\t"
-		 "nop # arch_static_branch\n\t"
-		 ".pushsection __jump_table,  \"aw\"\n\t"
-		 ".long 1b - ., %l[l_yes] - .\n\t"
-		 JUMP_ENTRY_TYPE "%c0 - .\n\t"
-		 ".popsection \n\t"
+	asm goto(ARCH_STATIC_BRANCH_ASM("%c0", "%l[l_yes]")
+=======
+#define JUMP_TABLE_ENTRY(key, label)			\
+	".pushsection __jump_table,  \"aw\"	\n\t"	\
+	".long 1b - ., " label " - .		\n\t"	\
+	JUMP_ENTRY_TYPE key " - .		\n\t"	\
+	".popsection 				\n\t"
+
+#define ARCH_STATIC_BRANCH_ASM(key, label)		\
+	"1:	nop				\n\t"	\
+	JUMP_TABLE_ENTRY(key,label)
+
+static __always_inline bool arch_static_branch(struct static_key *key, 
bool branch)
+{
+	asm goto(
+		 ARCH_STATIC_BRANCH_ASM("%c0", "%l[l_yes]")
+>>>>>>> rust64
  		 : :  "i" (&((char *)key)[branch]) : : l_yes);

  	return false;
@@ -34,10 +55,7 @@ static __always_inline bool 
arch_static_branch_jump(struct static_key *key, bool
  {
  	asm goto("1:\n\t"
  		 "b %l[l_yes] # arch_static_branch_jump\n\t"
-		 ".pushsection __jump_table,  \"aw\"\n\t"
-		 ".long 1b - ., %l[l_yes] - .\n\t"
-		 JUMP_ENTRY_TYPE "%c0 - .\n\t"
-		 ".popsection \n\t"
+		 JUMP_TABLE_ENTRY("%c0", "%l[l_yes]")
  		 : :  "i" (&((char *)key)[branch]) : : l_yes);

  	return false;
diff --git a/rust/Makefile b/rust/Makefile
index 5d357dce1704..9b72c1e96191 100644
--- a/rust/Makefile
+++ b/rust/Makefile
@@ -383,13 +383,19 @@ bindgen_skip_c_flags := -mno-fp-ret-in-387 
-mpreferred-stack-boundary=% \
  	-fno-inline-functions-called-once -fsanitize=bounds-strict \
  	-fstrict-flex-arrays=% -fmin-function-alignment=% \
  	-fzero-init-padding-bits=% -mno-fdpic \
-	--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
+<<<<<<< HEAD
+BINDGEN_TARGET_powerpc	:= powerpc-linux-gnu
+=======
+BINDGEN_TARGET_powerpc	:= powerpc64le-linux-gnu
+>>>>>>> rust64
  BINDGEN_TARGET_um	:= $(BINDGEN_TARGET_$(SUBARCH))
  BINDGEN_TARGET		:= $(BINDGEN_TARGET_$(SRCARCH))

diff --git a/scripts/generate_rust_target.rs 
b/scripts/generate_rust_target.rs
index 38b3416bb979..1860af50b926 100644
--- a/scripts/generate_rust_target.rs
+++ b/scripts/generate_rust_target.rs
@@ -188,6 +188,16 @@ fn main() {
          panic!("arm uses the builtin rustc target");
      } else if cfg.has("ARM64") {
          panic!("arm64 uses the builtin rustc aarch64-unknown-none 
target");
+    } else if cfg.has("PPC32") {
+        ts.push("arch", "powerpc");
+        ts.push("data-layout", "E-m:e-p:32:32-Fn32-i64:64-n32");
+        ts.push("features", "+soft-float");
+        ts.push("llvm-target", "powerpc-unknown-eabi");
+        if cfg.rustc_version_atleast(1, 91, 0) {
+            ts.push("target-pointer-width", 32);
+        } else {
+            ts.push("target-pointer-width", "32");
+        }
      } else if cfg.has("RISCV") {
          if cfg.has("64BIT") {
              panic!("64-bit RISC-V uses the builtin rustc 
riscv64-unknown-none-elf target");
@@ -256,6 +266,30 @@ fn main() {
          }
      } else if cfg.has("LOONGARCH") {
          panic!("loongarch uses the builtin rustc 
loongarch64-unknown-none-softfloat target");
+    } else if cfg.has("PPC64") {
+        ts.push("arch", "powerpc64");
+        ts.push(
+            "data-layout",
+            if cfg.has("CPU_LITTLE_ENDIAN") {
+                "e-m:e-Fn32-i64:64-n32:64-S128-v256:256:256-v512:512:512"
+            } else {
+                "E-m:e-Fn32-i64:64-n32:64-S128-v256:256:256-v512:512:512"
+            },
+        );
+        ts.push("features", "-mma,-altivec,-vsx,-hard-float");
+        ts.push(
+            "llvm-target",
+            if cfg.has("CPU_LITTLE_ENDIAN") {
+                "powerpc64le-linux-gnu"
+            } else {
+                "powerpc64-linux-gnu"
+            },
+        );
+        if cfg.rustc_version_atleast(1, 91, 0) {
+            ts.push("target-pointer-width", 64);
+        } else {
+            ts.push("target-pointer-width", "64");
+        }
      } else {
          panic!("Unsupported architecture");
      }

[...]

> ---
>   arch/powerpc/Kconfig                  |  1 +
>   arch/powerpc/Makefile                 |  9 +++++----
>   arch/powerpc/include/asm/jump_label.h | 23 +++++++++++++----------
>   rust/Makefile                         |  1 +
>   scripts/generate_rust_target.rs       | 24 ++++++++++++++++++++++++
>   5 files changed, 44 insertions(+), 14 deletions(-)
> 
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index 9537a61ebae0..e9b8d761ed52 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -285,6 +285,7 @@ config PPC
>          select HAVE_RSEQ
>          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_RUST                        if PPC64

Keep in alphabetic order

>          select HAVE_SETUP_PER_CPU_AREA          if PPC64
>          select HAVE_SOFTIRQ_ON_OWN_STACK
>          select HAVE_STACKPROTECTOR              if PPC32 && $(cc-option,$(m32-flag) -mstack-protector-guard=tls -mstack-protector-guard-reg=r2 -mstack-protector-guard-offset=0)
> diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
> index a58b1029592c..7ad28cf0fd35 100644
> --- a/arch/powerpc/Makefile
> +++ b/arch/powerpc/Makefile
> @@ -172,10 +172,11 @@ CFLAGS-y += $(CONFIG_TUNE_CPU)
> 
>   asinstr := $(call as-instr,lis 9$(comma)foo@high,-DHAVE_AS_ATHIGH=1)
> 
> -KBUILD_CPPFLAGS        += -I $(srctree)/arch/powerpc $(asinstr)
> -KBUILD_AFLAGS  += $(AFLAGS-y)
> -KBUILD_CFLAGS  += $(CC_FLAGS_NO_FPU)
> -KBUILD_CFLAGS  += $(CFLAGS-y)
> +KBUILD_CPPFLAGS                += -I $(srctree)/arch/powerpc $(asinstr)
> +KBUILD_AFLAGS          += $(AFLAGS-y)
> +KBUILD_CFLAGS          += $(CC_FLAGS_NO_FPU)
> +KBUILD_CFLAGS          += $(CFLAGS-y)
> +KBUILD_RUSTFLAGS        += -Ctarget-feature=-mma,-vsx,-hard-float,-altivec
> 
>   CHECKFLAGS     += -m$(BITS) -D__powerpc__ -D__powerpc$(BITS)__
>   ifdef CONFIG_CPU_BIG_ENDIAN
> diff --git a/arch/powerpc/include/asm/jump_label.h b/arch/powerpc/include/asm/jump_label.h
> index d4eaba459a0e..a6b211502bfe 100644
> --- a/arch/powerpc/include/asm/jump_label.h
> +++ b/arch/powerpc/include/asm/jump_label.h
> @@ -15,14 +15,20 @@
>   #define JUMP_ENTRY_TYPE                stringify_in_c(FTR_ENTRY_LONG)
>   #define JUMP_LABEL_NOP_SIZE    4
> 
> +#define JUMP_TABLE_ENTRY(key, label)                   \
> +       ".pushsection __jump_table,  \"aw\"     \n\t"   \
> +       ".long 1b - ., " label " - .            \n\t"   \
> +       JUMP_ENTRY_TYPE key " - .               \n\t"   \
> +       ".popsection                            \n\t"
> +
> +#define ARCH_STATIC_BRANCH_ASM(key, label)             \
> +       "1:     nop                             \n\t"   \
> +       JUMP_TABLE_ENTRY(key,label)
> +
>   static __always_inline bool arch_static_branch(struct static_key *key, bool branch)
>   {
> -       asm goto("1:\n\t"
> -                "nop # arch_static_branch\n\t"
> -                ".pushsection __jump_table,  \"aw\"\n\t"
> -                ".long 1b - ., %l[l_yes] - .\n\t"
> -                JUMP_ENTRY_TYPE "%c0 - .\n\t"
> -                ".popsection \n\t"
> +       asm goto(
> +                ARCH_STATIC_BRANCH_ASM("%c0", "%l[l_yes]")
>                   : :  "i" (&((char *)key)[branch]) : : l_yes);
> 
>          return false;
> @@ -34,10 +40,7 @@ static __always_inline bool arch_static_branch_jump(struct static_key *key, bool
>   {
>          asm goto("1:\n\t"
>                   "b %l[l_yes] # arch_static_branch_jump\n\t"
> -                ".pushsection __jump_table,  \"aw\"\n\t"
> -                ".long 1b - ., %l[l_yes] - .\n\t"
> -                JUMP_ENTRY_TYPE "%c0 - .\n\t"
> -                ".popsection \n\t"
> +                JUMP_TABLE_ENTRY("%c0", "%l[l_yes]")
>                   : :  "i" (&((char *)key)[branch]) : : l_yes);
> 
>          return false;
> diff --git a/rust/Makefile b/rust/Makefile
> index 5d357dce1704..7a6daa822cbc 100644
> --- a/rust/Makefile
> +++ b/rust/Makefile
> @@ -390,6 +390,7 @@ 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 := powerpc64le-linux-gnu

This needs to depend on CONFIG_PPC64 and CONFIG_CPU_LITTLE_ENDIAN.


>   BINDGEN_TARGET_um      := $(BINDGEN_TARGET_$(SUBARCH))
>   BINDGEN_TARGET         := $(BINDGEN_TARGET_$(SRCARCH))
> 
> diff --git a/scripts/generate_rust_target.rs b/scripts/generate_rust_target.rs
> index 38b3416bb979..875579b37424 100644
> --- a/scripts/generate_rust_target.rs
> +++ b/scripts/generate_rust_target.rs
> @@ -256,6 +256,30 @@ fn main() {
>           }
>       } else if cfg.has("LOONGARCH") {
>           panic!("loongarch uses the builtin rustc loongarch64-unknown-none-softfloat target");
> +    } else if cfg.has("PPC64") {

Shouldn't this be done closer to PPC32 ?

> +        ts.push("arch", "powerpc64");
> +        ts.push(
> +            "data-layout",
> +            if cfg.has("CPU_LITTLE_ENDIAN") {
> +                "e-m:e-Fn32-i64:64-n32:64-S128-v256:256:256-v512:512:512"
> +            } else {
> +                "E-m:e-Fn32-i64:64-n32:64-S128-v256:256:256-v512:512:512"
> +            },
> +        );
> +        ts.push("features", "-mma,-altivec,-vsx,-hard-float");
> +        ts.push(
> +            "llvm-target",
> +            if cfg.has("CPU_LITTLE_ENDIAN") {
> +                "powerpc64le-linux-gnu"
> +            } else {
> +                "powerpc64-linux-gnu"
> +            },
> +        );
> +        if cfg.rustc_version_atleast(1, 91, 0) {
> +            ts.push("target-pointer-width", 64);
> +        } else {
> +            ts.push("target-pointer-width", "64");
> +        }
>       } else {
>           panic!("Unsupported architecture");
>       }
> --
> 2.52.0
> 

Re: [PATCH] powerpc: Enable Rust for ppc64le
Posted by Mukesh Kumar Chaurasiya 2 days, 21 hours ago
On Wed, Feb 04, 2026 at 06:11:13PM +0100, Christophe Leroy (CS GROUP) wrote:
> Hi Mukesh, hi Link,
> 
> Le 04/02/2026 à 05:24, Mukesh Kumar Chaurasiya (IBM) a écrit :
> > [Vous ne recevez pas souvent de courriers de mkchauras@gmail.com. Découvrez pourquoi ceci est important à https://aka.ms/LearnAboutSenderIdentification ]
> > 
> > Enabling rust support for ppc64 only.
> 
> Link Mauve has sent a patch for rust support on PPC32 a few hours before
> you, see
> https://lore.kernel.org/r/20260204030507.8203-1-linkmauve@linkmauve.fr
> Could you coordinate together to provide something supporting both PPC32 and
> PPC64 ?
> 
Hey Christophe,
Sure.
> I see the following conflicts at the time being. I also have a few comments
> down.
> 
Ohk.
> diff --git a/Documentation/rust/arch-support.rst
> b/Documentation/rust/arch-support.rst
> index 6e6a515d0899..70b9e192a7a0 100644
> --- a/Documentation/rust/arch-support.rst
> +++ b/Documentation/rust/arch-support.rst
> @@ -18,6 +18,7 @@ Architecture   Level of support  Constraints
>  ``arm``        Maintained        ARMv7 Little Endian only.
>  ``arm64``      Maintained        Little Endian only.
>  ``loongarch``  Maintained        \-
> +``powerpc``    Maintained        32-bit Big Endian only.
>  ``riscv``      Maintained        ``riscv64`` and LLVM/Clang only.
>  ``um``         Maintained        \-
>  ``x86``        Maintained        ``x86_64`` only.
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index b8d36a261009..80b2666fc5af 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -283,8 +283,10 @@ 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_RUST			if PPC64
>  	select HAVE_SETUP_PER_CPU_AREA		if PPC64
>  	select HAVE_SOFTIRQ_ON_OWN_STACK
>  	select HAVE_STACKPROTECTOR		if PPC32 && $(cc-option,$(m32-flag)
> -mstack-protector-guard=tls -mstack-protector-guard-reg=r2
> -mstack-protector-guard-offset=0)
> diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
> index a58b1029592c..ac6fe8cc4ece 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
> @@ -172,10 +174,11 @@ CFLAGS-y += $(CONFIG_TUNE_CPU)
> 
>  asinstr := $(call as-instr,lis 9$(comma)foo@high,-DHAVE_AS_ATHIGH=1)
> 
> -KBUILD_CPPFLAGS	+= -I $(srctree)/arch/powerpc $(asinstr)
> -KBUILD_AFLAGS	+= $(AFLAGS-y)
> -KBUILD_CFLAGS	+= $(CC_FLAGS_NO_FPU)
> -KBUILD_CFLAGS	+= $(CFLAGS-y)
> +KBUILD_CPPFLAGS		+= -I $(srctree)/arch/powerpc $(asinstr)
> +KBUILD_AFLAGS		+= $(AFLAGS-y)
> +KBUILD_CFLAGS		+= $(CC_FLAGS_NO_FPU)
> +KBUILD_CFLAGS		+= $(CFLAGS-y)
> +KBUILD_RUSTFLAGS        += -Ctarget-feature=-mma,-vsx,-hard-float,-altivec
> 
>  CHECKFLAGS	+= -m$(BITS) -D__powerpc__ -D__powerpc$(BITS)__
>  ifdef CONFIG_CPU_BIG_ENDIAN
> diff --git a/arch/powerpc/include/asm/jump_label.h
> b/arch/powerpc/include/asm/jump_label.h
> index d4eaba459a0e..d2284c72d21b 100644
> --- a/arch/powerpc/include/asm/jump_label.h
> +++ b/arch/powerpc/include/asm/jump_label.h
> @@ -15,14 +15,35 @@
>  #define JUMP_ENTRY_TYPE		stringify_in_c(FTR_ENTRY_LONG)
>  #define JUMP_LABEL_NOP_SIZE	4
> 
> +<<<<<<< HEAD
> +/* This macro is also expanded on the Rust side. */
> +#define ARCH_STATIC_BRANCH_ASM(key, label)		\
> +	"1:\n\t"					\
> +	"nop # arch_static_branch\n\t"			\
> +	".pushsection __jump_table,  \"aw\"\n\t"	\
> +	".long 1b - ., " label " - .\n\t"		\
> +	 JUMP_ENTRY_TYPE key " - .\n\t"			\
> +	 ".popsection \n\t"
> +
>  static __always_inline bool arch_static_branch(struct static_key *key, bool
> branch)
>  {
> -	asm goto("1:\n\t"
> -		 "nop # arch_static_branch\n\t"
> -		 ".pushsection __jump_table,  \"aw\"\n\t"
> -		 ".long 1b - ., %l[l_yes] - .\n\t"
> -		 JUMP_ENTRY_TYPE "%c0 - .\n\t"
> -		 ".popsection \n\t"
> +	asm goto(ARCH_STATIC_BRANCH_ASM("%c0", "%l[l_yes]")
> +=======
> +#define JUMP_TABLE_ENTRY(key, label)			\
> +	".pushsection __jump_table,  \"aw\"	\n\t"	\
> +	".long 1b - ., " label " - .		\n\t"	\
> +	JUMP_ENTRY_TYPE key " - .		\n\t"	\
> +	".popsection 				\n\t"
> +
> +#define ARCH_STATIC_BRANCH_ASM(key, label)		\
> +	"1:	nop				\n\t"	\
> +	JUMP_TABLE_ENTRY(key,label)
> +
> +static __always_inline bool arch_static_branch(struct static_key *key, bool
> branch)
> +{
> +	asm goto(
> +		 ARCH_STATIC_BRANCH_ASM("%c0", "%l[l_yes]")
> +>>>>>>> rust64
>  		 : :  "i" (&((char *)key)[branch]) : : l_yes);
> 
>  	return false;
> @@ -34,10 +55,7 @@ static __always_inline bool
> arch_static_branch_jump(struct static_key *key, bool
>  {
>  	asm goto("1:\n\t"
>  		 "b %l[l_yes] # arch_static_branch_jump\n\t"
> -		 ".pushsection __jump_table,  \"aw\"\n\t"
> -		 ".long 1b - ., %l[l_yes] - .\n\t"
> -		 JUMP_ENTRY_TYPE "%c0 - .\n\t"
> -		 ".popsection \n\t"
> +		 JUMP_TABLE_ENTRY("%c0", "%l[l_yes]")
>  		 : :  "i" (&((char *)key)[branch]) : : l_yes);
> 
>  	return false;
> diff --git a/rust/Makefile b/rust/Makefile
> index 5d357dce1704..9b72c1e96191 100644
> --- a/rust/Makefile
> +++ b/rust/Makefile
> @@ -383,13 +383,19 @@ bindgen_skip_c_flags := -mno-fp-ret-in-387
> -mpreferred-stack-boundary=% \
>  	-fno-inline-functions-called-once -fsanitize=bounds-strict \
>  	-fstrict-flex-arrays=% -fmin-function-alignment=% \
>  	-fzero-init-padding-bits=% -mno-fdpic \
> -	--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
> +<<<<<<< HEAD
> +BINDGEN_TARGET_powerpc	:= powerpc-linux-gnu
> +=======
> +BINDGEN_TARGET_powerpc	:= powerpc64le-linux-gnu
> +>>>>>>> rust64
>  BINDGEN_TARGET_um	:= $(BINDGEN_TARGET_$(SUBARCH))
>  BINDGEN_TARGET		:= $(BINDGEN_TARGET_$(SRCARCH))
> 
> diff --git a/scripts/generate_rust_target.rs
> b/scripts/generate_rust_target.rs
> index 38b3416bb979..1860af50b926 100644
> --- a/scripts/generate_rust_target.rs
> +++ b/scripts/generate_rust_target.rs
> @@ -188,6 +188,16 @@ fn main() {
>          panic!("arm uses the builtin rustc target");
>      } else if cfg.has("ARM64") {
>          panic!("arm64 uses the builtin rustc aarch64-unknown-none target");
> +    } else if cfg.has("PPC32") {
> +        ts.push("arch", "powerpc");
> +        ts.push("data-layout", "E-m:e-p:32:32-Fn32-i64:64-n32");
> +        ts.push("features", "+soft-float");
> +        ts.push("llvm-target", "powerpc-unknown-eabi");
> +        if cfg.rustc_version_atleast(1, 91, 0) {
> +            ts.push("target-pointer-width", 32);
> +        } else {
> +            ts.push("target-pointer-width", "32");
> +        }
>      } else if cfg.has("RISCV") {
>          if cfg.has("64BIT") {
>              panic!("64-bit RISC-V uses the builtin rustc
> riscv64-unknown-none-elf target");
> @@ -256,6 +266,30 @@ fn main() {
>          }
>      } else if cfg.has("LOONGARCH") {
>          panic!("loongarch uses the builtin rustc
> loongarch64-unknown-none-softfloat target");
> +    } else if cfg.has("PPC64") {
> +        ts.push("arch", "powerpc64");
> +        ts.push(
> +            "data-layout",
> +            if cfg.has("CPU_LITTLE_ENDIAN") {
> +                "e-m:e-Fn32-i64:64-n32:64-S128-v256:256:256-v512:512:512"
> +            } else {
> +                "E-m:e-Fn32-i64:64-n32:64-S128-v256:256:256-v512:512:512"
> +            },
> +        );
> +        ts.push("features", "-mma,-altivec,-vsx,-hard-float");
> +        ts.push(
> +            "llvm-target",
> +            if cfg.has("CPU_LITTLE_ENDIAN") {
> +                "powerpc64le-linux-gnu"
> +            } else {
> +                "powerpc64-linux-gnu"
> +            },
> +        );
> +        if cfg.rustc_version_atleast(1, 91, 0) {
> +            ts.push("target-pointer-width", 64);
> +        } else {
> +            ts.push("target-pointer-width", "64");
> +        }
>      } else {
>          panic!("Unsupported architecture");
>      }
> 
> [...]
> 
> > ---
> >   arch/powerpc/Kconfig                  |  1 +
> >   arch/powerpc/Makefile                 |  9 +++++----
> >   arch/powerpc/include/asm/jump_label.h | 23 +++++++++++++----------
> >   rust/Makefile                         |  1 +
> >   scripts/generate_rust_target.rs       | 24 ++++++++++++++++++++++++
> >   5 files changed, 44 insertions(+), 14 deletions(-)
> > 
> > diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> > index 9537a61ebae0..e9b8d761ed52 100644
> > --- a/arch/powerpc/Kconfig
> > +++ b/arch/powerpc/Kconfig
> > @@ -285,6 +285,7 @@ config PPC
> >          select HAVE_RSEQ
> >          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_RUST                        if PPC64
> 
> Keep in alphabetic order
> 
Sure.
> >          select HAVE_SETUP_PER_CPU_AREA          if PPC64
> >          select HAVE_SOFTIRQ_ON_OWN_STACK
> >          select HAVE_STACKPROTECTOR              if PPC32 && $(cc-option,$(m32-flag) -mstack-protector-guard=tls -mstack-protector-guard-reg=r2 -mstack-protector-guard-offset=0)
> > diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
> > index a58b1029592c..7ad28cf0fd35 100644
> > --- a/arch/powerpc/Makefile
> > +++ b/arch/powerpc/Makefile
> > @@ -172,10 +172,11 @@ CFLAGS-y += $(CONFIG_TUNE_CPU)
> > 
> >   asinstr := $(call as-instr,lis 9$(comma)foo@high,-DHAVE_AS_ATHIGH=1)
> > 
> > -KBUILD_CPPFLAGS        += -I $(srctree)/arch/powerpc $(asinstr)
> > -KBUILD_AFLAGS  += $(AFLAGS-y)
> > -KBUILD_CFLAGS  += $(CC_FLAGS_NO_FPU)
> > -KBUILD_CFLAGS  += $(CFLAGS-y)
> > +KBUILD_CPPFLAGS                += -I $(srctree)/arch/powerpc $(asinstr)
> > +KBUILD_AFLAGS          += $(AFLAGS-y)
> > +KBUILD_CFLAGS          += $(CC_FLAGS_NO_FPU)
> > +KBUILD_CFLAGS          += $(CFLAGS-y)
> > +KBUILD_RUSTFLAGS        += -Ctarget-feature=-mma,-vsx,-hard-float,-altivec
> > 
> >   CHECKFLAGS     += -m$(BITS) -D__powerpc__ -D__powerpc$(BITS)__
> >   ifdef CONFIG_CPU_BIG_ENDIAN
> > diff --git a/arch/powerpc/include/asm/jump_label.h b/arch/powerpc/include/asm/jump_label.h
> > index d4eaba459a0e..a6b211502bfe 100644
> > --- a/arch/powerpc/include/asm/jump_label.h
> > +++ b/arch/powerpc/include/asm/jump_label.h
> > @@ -15,14 +15,20 @@
> >   #define JUMP_ENTRY_TYPE                stringify_in_c(FTR_ENTRY_LONG)
> >   #define JUMP_LABEL_NOP_SIZE    4
> > 
> > +#define JUMP_TABLE_ENTRY(key, label)                   \
> > +       ".pushsection __jump_table,  \"aw\"     \n\t"   \
> > +       ".long 1b - ., " label " - .            \n\t"   \
> > +       JUMP_ENTRY_TYPE key " - .               \n\t"   \
> > +       ".popsection                            \n\t"
> > +
> > +#define ARCH_STATIC_BRANCH_ASM(key, label)             \
> > +       "1:     nop                             \n\t"   \
> > +       JUMP_TABLE_ENTRY(key,label)
> > +
> >   static __always_inline bool arch_static_branch(struct static_key *key, bool branch)
> >   {
> > -       asm goto("1:\n\t"
> > -                "nop # arch_static_branch\n\t"
> > -                ".pushsection __jump_table,  \"aw\"\n\t"
> > -                ".long 1b - ., %l[l_yes] - .\n\t"
> > -                JUMP_ENTRY_TYPE "%c0 - .\n\t"
> > -                ".popsection \n\t"
> > +       asm goto(
> > +                ARCH_STATIC_BRANCH_ASM("%c0", "%l[l_yes]")
> >                   : :  "i" (&((char *)key)[branch]) : : l_yes);
> > 
> >          return false;
> > @@ -34,10 +40,7 @@ static __always_inline bool arch_static_branch_jump(struct static_key *key, bool
> >   {
> >          asm goto("1:\n\t"
> >                   "b %l[l_yes] # arch_static_branch_jump\n\t"
> > -                ".pushsection __jump_table,  \"aw\"\n\t"
> > -                ".long 1b - ., %l[l_yes] - .\n\t"
> > -                JUMP_ENTRY_TYPE "%c0 - .\n\t"
> > -                ".popsection \n\t"
> > +                JUMP_TABLE_ENTRY("%c0", "%l[l_yes]")
> >                   : :  "i" (&((char *)key)[branch]) : : l_yes);
> > 
> >          return false;
> > diff --git a/rust/Makefile b/rust/Makefile
> > index 5d357dce1704..7a6daa822cbc 100644
> > --- a/rust/Makefile
> > +++ b/rust/Makefile
> > @@ -390,6 +390,7 @@ 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 := powerpc64le-linux-gnu
> 
> This needs to depend on CONFIG_PPC64 and CONFIG_CPU_LITTLE_ENDIAN.
> 
Yeah, will fix this.
> 
> >   BINDGEN_TARGET_um      := $(BINDGEN_TARGET_$(SUBARCH))
> >   BINDGEN_TARGET         := $(BINDGEN_TARGET_$(SRCARCH))
> > 
> > diff --git a/scripts/generate_rust_target.rs b/scripts/generate_rust_target.rs
> > index 38b3416bb979..875579b37424 100644
> > --- a/scripts/generate_rust_target.rs
> > +++ b/scripts/generate_rust_target.rs
> > @@ -256,6 +256,30 @@ fn main() {
> >           }
> >       } else if cfg.has("LOONGARCH") {
> >           panic!("loongarch uses the builtin rustc loongarch64-unknown-none-softfloat target");
> > +    } else if cfg.has("PPC64") {
> 
> Shouldn't this be done closer to PPC32 ?
> 
Yeah, I will build the 64 support over 32 and keep them together.
> > +        ts.push("arch", "powerpc64");
> > +        ts.push(
> > +            "data-layout",
> > +            if cfg.has("CPU_LITTLE_ENDIAN") {
> > +                "e-m:e-Fn32-i64:64-n32:64-S128-v256:256:256-v512:512:512"
> > +            } else {
> > +                "E-m:e-Fn32-i64:64-n32:64-S128-v256:256:256-v512:512:512"
> > +            },
> > +        );
> > +        ts.push("features", "-mma,-altivec,-vsx,-hard-float");
> > +        ts.push(
> > +            "llvm-target",
> > +            if cfg.has("CPU_LITTLE_ENDIAN") {
> > +                "powerpc64le-linux-gnu"
> > +            } else {
> > +                "powerpc64-linux-gnu"
> > +            },
> > +        );
> > +        if cfg.rustc_version_atleast(1, 91, 0) {
> > +            ts.push("target-pointer-width", 64);
> > +        } else {
> > +            ts.push("target-pointer-width", "64");
> > +        }
> >       } else {
> >           panic!("Unsupported architecture");
> >       }
> > --
> > 2.52.0
> > 
>