Skip to contentSkip to conversation

Rust support for powerpc

PATCH Superseded Mukesh Kumar Chaurasiya (IBM) 8 participants 17 messages Feb 4 – Feb 16

Subsystems (4)

v2 of 17 Superseded Latest is v17 →

lore
Share & tools
lore
#0 lore raw

v2 cover Rust support for powerpc

Enable experimental rust support for ppc64le and ppc32be. The patch for ppc32 has been provided by Link Mauve[1] and ppc64le support[2] has been merged over it. ppc32 needs some toolchain fixes mentioned in the patch rust: Add PowerPC support and the discussion for that is done here[1].

This has been tested on powernv9 hardware and power10 pseries qemu. I I request Link to test the ppc32 part as i don't have a hardware to test it out.

[1] https://lore.kernel.org/all/[email protected]
[2] https://lore.kernel.org/all/[email protected]

Changelog:
V1 -> V2:
- jump label fix for rust has been moved to a separate patch
- PPC32 support has been taken
- rust support has been marked experimental
- target.json dependency has been removed
- HAVE_RUST now depends on CPU_LITTLE_ENDIAN for PPC64

Link Mauve (1):
rust: Add PowerPC support

Mukesh Kumar Chaurasiya (IBM) (2):
powerpc/jump_label: adjust inline asm to be consistent
powerpc: Enable Rust for ppc64le

 Documentation/rust/arch-support.rst   |  1 +
 arch/powerpc/Kconfig                  |  1 +
 arch/powerpc/Makefile                 |  9 +++++++++
 arch/powerpc/include/asm/jump_label.h | 23 +++++++++++++----------
 rust/Makefile                         | 11 ++++++++++-
 5 files changed, 34 insertions(+), 11 deletions(-)
Signature · 1 line
2.52.0
#1 lore raw

PATCH v2 1/3 powerpc/jump_label: adjust inline asm to be consistent

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

---
 arch/powerpc/include/asm/jump_label.h | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)
arch/powerpc/include/asm/jump_label.h +13 -10
index d4eaba459a0e..a6b211502bfe 100644
@@ -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;
Signature · 1 line
2.52.0
reviewer Reviewed-by on v2 1/3
#2 lore raw

Re: [PATCH V2 1/3] powerpc/jump_label: adjust inline asm to be consistent

Le 04/02/2026 à 22:01, Mukesh Kumar Chaurasiya (IBM) a écrit :

Quoted 8 lines

[Vous ne recevez pas souvent de courriers de [email protected]. Découvrez pourquoi ceci est important à https://aka.ms/LearnAboutSenderIdentification ]

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

Quoted 50 lines
---
  arch/powerpc/include/asm/jump_label.h | 23 +++++++++++++----------
  1 file changed, 13 insertions(+), 10 deletions(-)
arch/powerpc/include/asm/jump_label.h +13 -11
index d4eaba459a0e..a6b211502bfe 100644
@@ -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;
--

2.52.0

maintainer Reviewed-by on v2 1/3
#3 lore raw

Re: [PATCH V2 1/3] powerpc/jump_label: adjust inline asm to be consistent

In reply to Mukesh Kumar Chaurasiya (IBM)
Quoted 6 lines · Mukesh Kumar Chaurasiya (IBM)

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

#4 lore raw

PATCH v2 2/3 rust: Add PowerPC support

In reply to Mukesh Kumar Chaurasiya (IBM)

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.

---
 Documentation/rust/arch-support.rst | 1 +
 arch/powerpc/Kconfig                | 1 +
 arch/powerpc/Makefile               | 2 ++
 rust/Makefile                       | 4 +++-
 4 files changed, 7 insertions(+), 1 deletion(-)
Documentation/rust/arch-support.rst +1 -0
index 6e6a515d0899..e26a94808e97 100644
@@ -18,6 +18,7 @@ Architecture   Level of support  Constraints
 ``arm``        Maintained        ARMv7 Little Endian only.
 ``arm64``      Maintained        Little Endian only.
 ``loongarch``  Maintained        \-
+``powerpc``    Experimental      32-bit Big Endian only.
 ``riscv``      Maintained        ``riscv64`` and LLVM/Clang only.
 ``um``         Maintained        \-
 ``x86``        Maintained        ``x86_64`` only.
arch/powerpc/Kconfig +1 -0
index 9537a61ebae0..17db23b82e91 100644
@@ -283,6 +283,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
arch/powerpc/Makefile +2 -0
index a58b1029592c..9fd82c75dcbd 100644
@@ -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
rust/Makefile +3 -1
index 4dcc2eff51cb..ae22f2c5f0b3 100644
@@ -384,13 +384,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))
 
Signature · 1 line
2.52.0
#5 lore raw

PATCH v2 3/3 powerpc: Enable Rust for ppc64le

In reply to Mukesh Kumar Chaurasiya (IBM)

Enabling rust support for ppc64le only.

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)
---
 Documentation/rust/arch-support.rst | 2 +-
 arch/powerpc/Kconfig                | 2 +-
 arch/powerpc/Makefile               | 9 ++++++++-
 rust/Makefile                       | 9 ++++++++-
 4 files changed, 18 insertions(+), 4 deletions(-)
Documentation/rust/arch-support.rst +1 -1
index e26a94808e97..627471ac9238 100644
@@ -18,7 +18,7 @@ Architecture   Level of support  Constraints
 ``arm``        Maintained        ARMv7 Little Endian only.
 ``arm64``      Maintained        Little Endian only.
 ``loongarch``  Maintained        \-
-``powerpc``    Experimental      32-bit Big Endian only.
+``powerpc``    Experimental      64-bit Little Endian. 32-bit Big Endian.
 ``riscv``      Maintained        ``riscv64`` and LLVM/Clang only.
 ``um``         Maintained        \-
 ``x86``        Maintained        ``x86_64`` only.
arch/powerpc/Kconfig +1 -1
index 17db23b82e91..c5dd03713af2 100644
@@ -283,7 +283,7 @@ config PPC
 	select HAVE_REGS_AND_STACK_ACCESS_API
 	select HAVE_RELIABLE_STACKTRACE
 	select HAVE_RSEQ
-	select HAVE_RUST			if PPC32
+	select HAVE_RUST			if PPC32 || (PPC64 && CPU_LITTLE_ENDIAN)
 	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
arch/powerpc/Makefile +8 -1
index 9fd82c75dcbd..f93816ddc036 100644
@@ -61,7 +61,14 @@ else
 KBUILD_LDFLAGS_MODULE += $(objtree)/arch/powerpc/lib/crtsavres.o
 endif
 
-KBUILD_RUSTFLAGS += --target=powerpc-unknown-linux-gnu
+ifdef CONFIG_PPC64
+ifdef CONFIG_CPU_LITTLE_ENDIAN
+KBUILD_RUSTFLAGS	+= --target=powerpc64le-unknown-linux-gnu
+endif
+KBUILD_RUSTFLAGS	+= -Ctarget-feature=-mma,-vsx,-hard-float,-altivec
+else
+KBUILD_RUSTFLAGS	+= --target=powerpc-unknown-linux-gnu
+endif
 
 ifdef CONFIG_CPU_LITTLE_ENDIAN
 KBUILD_CPPFLAGS	+= -mlittle-endian
rust/Makefile +8 -1
index ae22f2c5f0b3..c3961fd0d9a4 100644
@@ -392,10 +392,17 @@ 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))
 
+ifdef CONFIG_PPC64
+ifdef CONFIG_CPU_LITTLE_ENDIAN
+BINDGEN_TARGET_powerpc	:= powerpc64le-linux-gnu
+endif
+else
+BINDGEN_TARGET_powerpc	:= powerpc-linux-gnu
+endif
+
 # All warnings are inhibited since GCC builds are very experimental,
 # many GCC warnings are not supported by Clang, they may only appear in
 # some configurations, with new GCC versions, etc.
Signature · 1 line
2.52.0
reviewer Reviewed-by on v2 3/3
#6 lore raw

Re: [PATCH V2 3/3] powerpc: Enable Rust for ppc64le

Le 04/02/2026 à 22:01, Mukesh Kumar Chaurasiya (IBM) a écrit :

Quoted 42 lines

[Vous ne recevez pas souvent de courriers de [email protected]. Découvrez pourquoi ceci est important à https://aka.ms/LearnAboutSenderIdentification ]

Enabling rust support for ppc64le only.

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
Quoted 5 lines
$ sudo rmmod rust_print
[  843.411003] rust_print: "hello, world"
[  888.499935] rust_print: Rust printing macros sample (exit)

Small comment below

Quoted 25 lines
---
  Documentation/rust/arch-support.rst | 2 +-
  arch/powerpc/Kconfig                | 2 +-
  arch/powerpc/Makefile               | 9 ++++++++-
  rust/Makefile                       | 9 ++++++++-
  4 files changed, 18 insertions(+), 4 deletions(-)
Documentation/rust/arch-support.rst +1 -1
index e26a94808e97..627471ac9238 100644
@@ -18,7 +18,7 @@ Architecture   Level of support  Constraints
  ``arm``        Maintained        ARMv7 Little Endian only.
  ``arm64``      Maintained        Little Endian only.
  ``loongarch``  Maintained        \-
-``powerpc``    Experimental      32-bit Big Endian only.
+``powerpc``    Experimental      64-bit Little Endian. 32-bit Big Endian.
  ``riscv``      Maintained        ``riscv64`` and LLVM/Clang only.
  ``um``         Maintained        \-
  ``x86``        Maintained        ``x86_64`` only.
arch/powerpc/Kconfig +0 -0
index 17db23b82e91..c5dd03713af2 100644

arch/powerpc/Kconfig config PPC · line 286

Quoted 5 lines
arch/powerpc/Kconfig +1 -1
@@ -283,7 +283,7 @@ config PPC
         select HAVE_REGS_AND_STACK_ACCESS_API
         select HAVE_RELIABLE_STACKTRACE
         select HAVE_RSEQ
-       select HAVE_RUST                        if PPC32
+       select HAVE_RUST                        if PPC32 || (PPC64 && CPU_LITTLE_ENDIAN)

Would be better to leave the first line as is and add a second line as follows:

	select HAVE_RUST			if PPC64 && CPU_LITTLE_ENDIAN
Quoted 49 lines
arch/powerpc/Kconfig +0 -0
         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
arch/powerpc/Makefile +8 -1
index 9fd82c75dcbd..f93816ddc036 100644
@@ -61,7 +61,14 @@ else
  KBUILD_LDFLAGS_MODULE += $(objtree)/arch/powerpc/lib/crtsavres.o
  endif
 
-KBUILD_RUSTFLAGS += --target=powerpc-unknown-linux-gnu
+ifdef CONFIG_PPC64
+ifdef CONFIG_CPU_LITTLE_ENDIAN
+KBUILD_RUSTFLAGS       += --target=powerpc64le-unknown-linux-gnu
+endif
+KBUILD_RUSTFLAGS       += -Ctarget-feature=-mma,-vsx,-hard-float,-altivec
+else
+KBUILD_RUSTFLAGS       += --target=powerpc-unknown-linux-gnu
+endif
 
  ifdef CONFIG_CPU_LITTLE_ENDIAN
  KBUILD_CPPFLAGS        += -mlittle-endian
rust/Makefile +8 -2
index ae22f2c5f0b3..c3961fd0d9a4 100644
@@ -392,10 +392,17 @@ 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))
 
+ifdef CONFIG_PPC64
+ifdef CONFIG_CPU_LITTLE_ENDIAN
+BINDGEN_TARGET_powerpc := powerpc64le-linux-gnu
+endif
+else
+BINDGEN_TARGET_powerpc := powerpc-linux-gnu
+endif
+
  # All warnings are inhibited since GCC builds are very experimental,
  # many GCC warnings are not supported by Clang, they may only appear in
  # some configurations, with new GCC versions, etc.
--

2.52.0

Reviewed-by Tested-by on v2 3/3
#7 lore raw

Re: [PATCH V2 3/3] powerpc: Enable Rust for ppc64le

In reply to Mukesh Kumar Chaurasiya (IBM)

On Thu, Feb 05, 2026 at 02:31:25AM +0530, Mukesh Kumar Chaurasiya (IBM) wrote:
[…]

Quoted 9 lines
rust/Makefile +0 -1
index ae22f2c5f0b3..c3961fd0d9a4 100644
@@ -392,10 +392,17 @@ 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

rust/Makefile BINDGEN_TARGET_x86 := x86_64-linux-gnu · line 404

Quoted 10 lines
rust/Makefile +7 -0
 BINDGEN_TARGET_um	:= $(BINDGEN_TARGET_$(SUBARCH))
 BINDGEN_TARGET		:= $(BINDGEN_TARGET_$(SRCARCH))
 
+ifdef CONFIG_PPC64
+ifdef CONFIG_CPU_LITTLE_ENDIAN
+BINDGEN_TARGET_powerpc	:= powerpc64le-linux-gnu
+endif
+else
+BINDGEN_TARGET_powerpc	:= powerpc-linux-gnu
+endif

You define BINDGEN_TARGET_powerpc after BINDGEN_TARGET has been set to the value of $(BINDGEN_TARGET_$(SRCARCH)), so it is empty and bindgen then gets passed --target= which makes it fail here, with this error message:

```
bindgen ../rust/bindings/bindings_helper.h --blocklist-type __kernel_s?size_t --blocklist-type __kernel_ptrdiff_t --opaque-type xregs_state --opaque-type desc_struct --opaque-type arch_lbr_state --opaque-type local_apic --opaque-type alt_instr --opaque-type x86_msi_data --opaque-type x86_msi_addr_lo --opaque-type kunit_try_catch --opaque-type spinlock --no-doc-comments --blocklist-function __list_.*_report --blocklist-item ARCH_SLAB_MINALIGN --blocklist-item ARCH_KMALLOC_MINALIGN --with-derive-custom-struct .*=MaybeZeroable --with-derive-custom-union .*=MaybeZeroable --rust-target 1.68 --use-core --with-derive-default --ctypes-prefix ffi --no-layout-tests --no-debug '.*' --enable-function-attribute-detection -o rust/bindings/bindings_generated.rs -- -Wp,-MMD,rust/bindings/.bindings_generated.rs.d -nostdinc -I../arch/powerpc/include -I./arch/powerpc/include/generated -I../include -I./include -I../arch/powerpc/include/uapi -I./arch/powerpc/include/generated/uapi -I../include/uapi -I./include/generated/uapi -include ../include/linux/compiler-version.h -include ../include/linux/kconfig.h -include ../include/linux/compiler_types.h -D__KERNEL__ -mbig-endian -m32 -I ../arch/powerpc -fmacro-prefix-map=../= -std=gnu11 -fshort-wchar -funsigned-char -fno-common -fno-PIE -fno-strict-aliasing -msoft-float -mcpu=powerpc -mno-prefixed -mno-pcrel -mno-altivec -mno-vsx -mno-mma -fno-asynchronous-unwind-tables -mbig-endian -fno-delete-null-pointer-checks -Os -fno-stack-protector -fomit-frame-pointer -ftrivial-auto-var-init=zero -fno-strict-overflow -fno-stack-check -fno-builtin-wcslen -Wall -Wextra -Wundef -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Werror=strict-prototypes -Wno-format-security -Wno-trigraphs -Wno-frame-address -Wno-address-of-packed-member -Wmissing-declarations -Wmissing-prototypes -Wframe-larger-than=1280 -Wno-main -Wno-dangling-pointer -Wvla-larger-than=1 -Wno-pointer-sign -Wcast-function-type -Wno-array-bounds -Wno-stringop-overflow -Wno-alloc-size-larger-than -Wimplicit-fallthrough=5 -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -Wenum-conversion -Wunused -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-packed-not-aligned -Wno-format-overflow -Wno-format-truncation -Wno-stringop-truncation -Wno-override-init -Wno-missing-field-initializers -Wno-type-limits -Wno-shift-negative-value -Wno-maybe-uninitialized -Wno-sign-compare -Wno-unused-parameter -DGCC_PLUGINS -I../rust -Irust -DKBUILD_MODFILE='"rust/bindings_generated"' -DKBUILD_BASENAME='"bindings_generated"' -DKBUILD_MODNAME='"bindings_generated"' -D__KBUILD_MODNAME=kmod_bindings_generated -w --target= -fno-builtin -D__BINDGEN__ -DMODULE  ; sed -Ei 's/pub const RUST_CONST_HELPER_([a-zA-Z0-9_]*)/pub const /g' rust/bindings/bindings_generated.rs
error: unsupported option '-mbig-endian' for target ''
error: unsupported option '-mcpu=' for target ''
error: unsupported option '-mno-prefixed' for target ''
error: unsupported option '-mno-pcrel' for target ''
error: unsupported option '-mno-altivec' for target ''
error: unsupported option '-mno-vsx' for target ''
error: unsupported option '-mno-mma' for target ''
error: unsupported option '-mbig-endian' for target ''
error: unknown target triple 'unknown'
panicked at bindgen/ir/context.rs:562:15:
libclang error; possible causes include:
- Invalid flag syntax
- Unrecognized flags
- Invalid flag arguments
- File I/O errors
- Host vs. target architecture mismatch
If you encounter an error missing from this list, please file an issue or a PR!
```

Did this work on PPC64?

Quoted 7 lines
rust/Makefile +1 -0
+
 # All warnings are inhibited since GCC builds are very experimental,
 # many GCC warnings are not supported by Clang, they may only appear in
 # some configurations, with new GCC versions, etc.
Signature · 1 line
2.52.0

With this fixed:

Signature · 1 line
Link Mauve
#8 lore raw

Re: [PATCH V2 3/3] powerpc: Enable Rust for ppc64le

Quoted 46 lines · Link Mauve

On Thu, Feb 05, 2026 at 02:31:25AM +0530, Mukesh Kumar Chaurasiya (IBM) wrote:
[…]

Quoted 9 lines
rust/Makefile +0 -1
index ae22f2c5f0b3..c3961fd0d9a4 100644
@@ -392,10 +392,17 @@ 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

rust/Makefile BINDGEN_TARGET_x86 := x86_64-linux-gnu · line 404

Quoted 10 lines
rust/Makefile +7 -0
  BINDGEN_TARGET_um	:= $(BINDGEN_TARGET_$(SUBARCH))
  BINDGEN_TARGET		:= $(BINDGEN_TARGET_$(SRCARCH))
 
+ifdef CONFIG_PPC64
+ifdef CONFIG_CPU_LITTLE_ENDIAN
+BINDGEN_TARGET_powerpc	:= powerpc64le-linux-gnu
+endif
+else
+BINDGEN_TARGET_powerpc	:= powerpc-linux-gnu
+endif

You define BINDGEN_TARGET_powerpc after BINDGEN_TARGET has been set to the value of $(BINDGEN_TARGET_$(SRCARCH)), so it is empty and bindgen then gets passed --target= which makes it fail here, with this error message:

```
bindgen ../rust/bindings/bindings_helper.h --blocklist-type __kernel_s?size_t --blocklist-type __kernel_ptrdiff_t --opaque-type xregs_state --opaque-type desc_struct --opaque-type arch_lbr_state --opaque-type local_apic --opaque-type alt_instr --opaque-type x86_msi_data --opaque-type x86_msi_addr_lo --opaque-type kunit_try_catch --opaque-type spinlock --no-doc-comments --blocklist-function __list_.*_report --blocklist-item ARCH_SLAB_MINALIGN --blocklist-item ARCH_KMALLOC_MINALIGN --with-derive-custom-struct .*=MaybeZeroable --with-derive-custom-union .*=MaybeZeroable --rust-target 1.68 --use-core --with-derive-default --ctypes-prefix ffi --no-layout-tests --no-debug '.*' --enable-function-attribute-detection -o rust/bindings/bindings_generated.rs -- -Wp,-MMD,rust/bindings/.bindings_generated.rs.d -nostdinc -I../arch/powerpc/include -I./arch/powerpc/include/generated -I../include -I./include -I../arch/powerpc/include/uapi -I./arch/powerpc/include/generated/uapi -I../include/uapi -I./include/generated/uapi -include ../include/linux/compiler-version.h -include ../include/linux/kconfig.h -include ../include/linux/compiler_types.h -D__KERNEL__ -mbig-endian -m32 -I ../arch/powerpc -fmacro-prefix-map=../= -std=gnu11 -fshort-wchar -funsigned-char -fno-common -fno-PIE -fno-strict-aliasing -msoft-float -mcpu=powerpc -mno-prefixed -mno-pcrel -mno-altivec -mno-vsx -mno-mma -fno-asynchronous-unwind-tables -mbig-endian -fno-delete-null-pointer-checks -Os -fno-stack-protector -fomit-frame-pointer -ftrivial-auto-var-init=zero -fno-strict-overflow -fno-stack-check -fno-builtin-wcslen -Wall -Wextra -Wundef -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Werror=strict-prototypes -Wno-format-security -Wno-trigraphs -Wno-frame-address -Wno-address-of-packed-member -Wmissing-declarations -Wmissing-prototypes -Wframe-larger-than=1280 -Wno-main -Wno-dangling-pointer -Wvla-larger-than=1 -Wno-pointer-sign -Wcast-function-type -Wno-array-bounds -Wno-stringop-overflow -Wno-alloc-size-larger-than -Wimplicit-fallthrough=5 -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -Wenum-conversion -Wunused -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-packed-not-aligned -Wno-format-overflow -Wno-format-truncation -Wno-stringop-truncation -Wno-override-init -Wno-missing-field-initializers -Wno-type-limits -Wno-shift-negative-value -Wno-maybe-uninitialized -Wno-sign-compare -Wno-unused-parameter -DGCC_PLUGINS -I../rust -Irust -DKBUILD_MODFILE='"rust/bindings_generated"' -DKBUILD_BASENAME='"bindings_generated"' -DKBUILD_MODNAME='"bindings_generated"' -D__KBUILD_MODNAME=kmod_bindings_generated -w --target= -fno-builtin -D__BINDGEN__ -DMODULE  ; sed -Ei 's/pub const RUST_CONST_HELPER_([a-zA-Z0-9_]*)/pub const /g' rust/bindings/bindings_generated.rs
error: unsupported option '-mbig-endian' for target ''
error: unsupported option '-mcpu=' for target ''
error: unsupported option '-mno-prefixed' for target ''
error: unsupported option '-mno-pcrel' for target ''
error: unsupported option '-mno-altivec' for target ''
error: unsupported option '-mno-vsx' for target ''
error: unsupported option '-mno-mma' for target ''
error: unsupported option '-mbig-endian' for target ''
error: unknown target triple 'unknown'
panicked at bindgen/ir/context.rs:562:15:
libclang error; possible causes include:
- Invalid flag syntax
- Unrecognized flags
- Invalid flag arguments
- File I/O errors
- Host vs. target architecture mismatch
If you encounter an error missing from this list, please file an issue or a PR!
```
Quoted 1 line

Did this work on PPC64?

On ppc64le, I am not able to get a successful Rust‑enabled build yet. I am consistently hitting bindgen/libclang failures during the prepare phase.

Build Failures:

error: unsupported option '-mlong-double-128' for target 'unknown'
error: unsupported argument 'medium' to option '-mcmodel=' for target 'unknown'
error: unknown target triple 'unknown'
panicked at bindgen-0.72.1/ir/context.rs:562:15:
libclang error; possible causes include:
- Invalid flag syntax
- Unrecognized flags
- Invalid flag arguments
- File I/O errors
- Host vs. target architecture mismatch

make[2]: *** [rust/Makefile:468: rust/bindings/bindings_generated.rs] Error 101 make[2]: *** Deleting file 'rust/bindings/bindings_generated.rs'

make[2]: *** [rust/Makefile:488: rust/bindings/bindings_helpers_generated.rs] Error 101 make[2]: *** Deleting file 'rust/bindings/bindings_helpers_generated.rs'

make[2]: *** [rust/Makefile:474: rust/uapi/uapi_generated.rs] Error 101 make[2]: *** Deleting file 'rust/uapi/uapi_generated.rs'

make[2]: *** [rust/Makefile:643: rust/core.o] Error 1 make[1]: *** [/root/linux/Makefile:1320: prepare] Error 2
make: *** [Makefile:248: __sub-make] Error 2

Regards,

Venkat.

Quoted 11 lines
Quoted 7 lines
rust/Makefile +1 -0
+
  # All warnings are inhibited since GCC builds are very experimental,
  # many GCC warnings are not supported by Clang, they may only appear in
  # some configurations, with new GCC versions, etc.
Signature · 1 line
2.52.0

With this fixed:

#9 lore raw

Re: [PATCH V2 3/3] powerpc: Enable Rust for ppc64le

Quoted 79 lines · Venkat Rao Bagalkote
Quoted 45 lines · Link Mauve

On Thu, Feb 05, 2026 at 02:31:25AM +0530, Mukesh Kumar Chaurasiya (IBM) wrote:
[…]

Quoted 8 lines
rust/Makefile +0 -0
index ae22f2c5f0b3..c3961fd0d9a4 100644
@@ -392,10 +392,17 @@ 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

rust/Makefile BINDGEN_TARGET_x86 := x86_64-linux-gnu · line 403

Quoted 10 lines
rust/Makefile +7 -1
-BINDGEN_TARGET_powerpc	:= powerpc-linux-gnu
  BINDGEN_TARGET_um	:= $(BINDGEN_TARGET_$(SUBARCH))
  BINDGEN_TARGET		:= $(BINDGEN_TARGET_$(SRCARCH))
+ifdef CONFIG_PPC64
+ifdef CONFIG_CPU_LITTLE_ENDIAN
+BINDGEN_TARGET_powerpc	:= powerpc64le-linux-gnu
+endif
+else
+BINDGEN_TARGET_powerpc	:= powerpc-linux-gnu
+endif

You define BINDGEN_TARGET_powerpc after BINDGEN_TARGET has been set to the value of $(BINDGEN_TARGET_$(SRCARCH)), so it is empty and bindgen then gets passed --target= which makes it fail here, with this error message:

```
bindgen ../rust/bindings/bindings_helper.h --blocklist-type __kernel_s?size_t --blocklist-type __kernel_ptrdiff_t --opaque-type xregs_state --opaque-type desc_struct --opaque-type arch_lbr_state --opaque-type local_apic --opaque-type alt_instr --opaque-type x86_msi_data --opaque-type x86_msi_addr_lo --opaque-type kunit_try_catch --opaque-type spinlock --no-doc-comments --blocklist-function __list_.*_report --blocklist-item ARCH_SLAB_MINALIGN --blocklist-item ARCH_KMALLOC_MINALIGN --with-derive-custom-struct .*=MaybeZeroable --with-derive-custom-union .*=MaybeZeroable --rust-target 1.68 --use-core --with-derive-default --ctypes-prefix ffi --no-layout-tests --no-debug '.*' --enable-function-attribute-detection -o rust/bindings/bindings_generated.rs -- -Wp,-MMD,rust/bindings/.bindings_generated.rs.d -nostdinc -I../arch/powerpc/include -I./arch/powerpc/include/generated -I../include -I./include -I../arch/powerpc/include/uapi -I./arch/powerpc/include/generated/uapi -I../include/uapi -I./include/generated/uapi -include ../include/linux/compiler-version.h -include ../include/linux/kconfig.h -include ../include/linux/compiler_types.h -D__KERNEL__ -mbig-endian -m32 -I ../arch/powerpc -fmacro-prefix-map=../= -std=gnu11 -fshort-wchar -funsigned-char -fno-common -fno-PIE -fno-strict-aliasing -msoft-float -mcpu=powerpc -mno-prefixed -mno-pcrel -mno-altivec -mno-vsx -mno-mma -fno-asynchronous-unwind-tables -mbig-endian -fno-delete-null-pointer-checks -Os -fno-stack-protector -fomit-frame-pointer -ftrivial-auto-var-init=zero -fno-strict-overflow -fno-stack-check -fno-builtin-wcslen -Wall -Wextra -Wundef -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Werror=strict-prototypes -Wno-format-security -Wno-trigraphs -Wno-frame-address -Wno-address-of-packed-member -Wmissing-declarations -Wmissing-prototypes -Wframe-larger-than=1280 -Wno-main -Wno-dangling-pointer -Wvla-larger-than=1 -Wno-pointer-sign -Wcast-function-type -Wno-array-bounds -Wno-stringop-overflow -Wno-alloc-size-larger-than -Wimplicit-fallthrough=5 -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -Wenum-conversion -Wunused -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-packed-not-aligned -Wno-format-overflow -Wno-format-truncation -Wno-stringop-truncation -Wno-override-init -Wno-missing-field-initializers -Wno-type-limits -Wno-shift-negative-value -Wno-maybe-uninitialized -Wno-sign-compare -Wno-unused-parameter -DGCC_PLUGINS -I../rust -Irust -DKBUILD_MODFILE='"rust/bindings_generated"' -DKBUILD_BASENAME='"bindings_generated"' -DKBUILD_MODNAME='"bindings_generated"' -D__KBUILD_MODNAME=kmod_bindings_generated -w --target= -fno-builtin -D__BINDGEN__ -DMODULE  ; sed -Ei 's/pub const RUST_CONST_HELPER_([a-zA-Z0-9_]*)/pub const /g' rust/bindings/bindings_generated.rs
error: unsupported option '-mbig-endian' for target ''
error: unsupported option '-mcpu=' for target ''
error: unsupported option '-mno-prefixed' for target ''
error: unsupported option '-mno-pcrel' for target ''
error: unsupported option '-mno-altivec' for target ''
error: unsupported option '-mno-vsx' for target ''
error: unsupported option '-mno-mma' for target ''
error: unsupported option '-mbig-endian' for target ''
error: unknown target triple 'unknown'
panicked at bindgen/ir/context.rs:562:15:
libclang error; possible causes include:
- Invalid flag syntax
- Unrecognized flags
- Invalid flag arguments
- File I/O errors
- Host vs. target architecture mismatch
If you encounter an error missing from this list, please file an issue or a PR!
```
Quoted 1 line

Did this work on PPC64?

On ppc64le, I am not able to get a successful Rust‑enabled build yet. I am consistently hitting bindgen/libclang failures during the prepare phase.

Build Failures:

error: unsupported option '-mlong-double-128' for target 'unknown'
error: unsupported argument 'medium' to option '-mcmodel=' for target 'unknown'
error: unknown target triple 'unknown'
panicked at bindgen-0.72.1/ir/context.rs:562:15:
libclang error; possible causes include:
- Invalid flag syntax
- Unrecognized flags
- Invalid flag arguments
- File I/O errors
- Host vs. target architecture mismatch

make[2]: *** [rust/Makefile:468: rust/bindings/bindings_generated.rs] Error 101
make[2]: *** Deleting file 'rust/bindings/bindings_generated.rs'

make[2]: *** [rust/Makefile:488:
rust/bindings/bindings_helpers_generated.rs] Error 101 make[2]: *** Deleting file 'rust/bindings/bindings_helpers_generated.rs'

make[2]: *** [rust/Makefile:474: rust/uapi/uapi_generated.rs] Error 101 make[2]: *** Deleting file 'rust/uapi/uapi_generated.rs'

Quoted 9 lines

make[2]: *** [rust/Makefile:643: rust/core.o] Error 1 make[1]: *** [/root/linux/Makefile:1320: prepare] Error 2
make: *** [Makefile:248: __sub-make] Error 2

Regards,

Venkat.

hey,

use rust version nightly-2026-01-28

the latest one has some issue. I just raised a bug for the rustc here[1].

[1] https://github.com/rust-lang/rust/issues/152177

Regards,
Mukesh

Quoted 11 lines
Quoted 11 lines
Quoted 7 lines
rust/Makefile +1 -0
+
  # All warnings are inhibited since GCC builds are very experimental,
  # many GCC warnings are not supported by Clang, they may only appear in
  # some configurations, with new GCC versions, etc.
Signature · 1 line
2.52.0

With this fixed:

#10 lore raw

Re: [PATCH V2 3/3] powerpc: Enable Rust for ppc64le

Quoted 7 lines · Mukesh Kumar Chaurasiya

use rust version nightly-2026-01-28

the latest one has some issue. I just raised a bug for the rustc here[1].

[1] https://github.com/rust-lang/rust/issues/152177

It appears to be a bug in LLVM 22 for ppc64, not present in 21.

If I understand correctly, then it may be fixed in 22.1.9 if it gets released.

Thanks Jubilee for the quick reply there!

Cc'ing Clang/LLVM build support, in case they didn't hear about it.

I linked it in our usual lists.

Cheers,
Miguel

#11 lore raw

Re: [PATCH V2 3/3] powerpc: Enable Rust for ppc64le

Quoted 10 lines · Miguel Ojeda
Quoted 7 lines · Mukesh Kumar Chaurasiya

use rust version nightly-2026-01-28

the latest one has some issue. I just raised a bug for the rustc here[1].

[1] https://github.com/rust-lang/rust/issues/152177

Quoted 7 lines

It appears to be a bug in LLVM 22 for ppc64, not present in 21.

If I understand correctly, then it may be fixed in 22.1.9 if it gets released.

Thanks Jubilee for the quick reply there!

Cc'ing Clang/LLVM build support, in case they didn't hear about it.

Thanks for the CC, I had not seen that issue. LLVM 22 is currently in the -rc phase and I see that the fix has been merged into the release/22.x branch as of yesterday so it should be in LLVM 21.1.0-rc3 when it get released on February 10. LLVM 21.1.8 was the last release of the 21.x series (hard to keep up with all the numbers...) and it sounds like this is only a regression from the LLVM 22 development cycle.

Cheers,
Nathan

#12 lore raw

Re: [PATCH V2 3/3] powerpc: Enable Rust for ppc64le

Quoted 7 lines · Nathan Chancellor

Thanks for the CC, I had not seen that issue. LLVM 22 is currently in the -rc phase and I see that the fix has been merged into the release/22.x branch as of yesterday so it should be in LLVM 21.1.0-rc3 when it get released on February 10. LLVM 21.1.8 was the last release of the 21.x series (hard to keep up with all the numbers...) and it sounds like this is only a regression from the LLVM 22 development cycle.

Yeah, sorry, mixed up 21.1.9 with the potential 22.1.9 in summer this year, bah!

Fixed my comment in the issue to avoid confusion.

Thanks!

Cheers,
Miguel

#13 lore raw

Re: [PATCH V2 3/3] powerpc: Enable Rust for ppc64le

In reply to Nathan Chancellor
Quoted 7 lines · Nathan Chancellor

Thanks for the CC, I had not seen that issue. LLVM 22 is currently in the -rc phase and I see that the fix has been merged into the release/22.x branch as of yesterday so it should be in LLVM 21.1.0-rc3 when it get released on February 10. LLVM 21.1.8 was the last release of the 21.x series (hard to keep up with all the numbers...) and it sounds like this is only a regression from the LLVM 22 development cycle.

Fixed as well for Rust 1.95.0 (expected 2026-04-16) when using the LLVM they provide.

https://github.com/rust-lang/rust/pull/152428

Cheers,
Miguel

#14 lore raw

Rust version requirement (was: [PATCH V2 3/3] powerpc: Enable Rust for ppc64le)

In reply to Mukesh Kumar Chaurasiya

On Thu, Feb 05, 2026 at 09:12:01PM +0530, Mukesh Kumar Chaurasiya wrote:
[...]

Quoted 6 lines

use rust version nightly-2026-01-28

the latest one has some issue. I just raised a bug for the rustc here[1].

[1] https://github.com/rust-lang/rust/issues/152177

Another reason to use a nightly version is that Rust inline assembly for PowerPC will only be stabilized[1] in version 1.94, so current release versions fail like this (tested with 1.91.1):

    error[E0658]: inline assembly is not stable yet on this architecture
      --> ../rust/kernel/sync/barrier.rs:19:14
       |
    19 |     unsafe { core::arch::asm!("") };
       |              ^^^^^^^^^^^^^^^^^^^^
       |
       = note: see issue #93335 <https://github.com/rust-lang/rust/issues/93335> for more information
       = help: add `#![feature(asm_experimental_arch)]` to the crate attributes to enable
       = note: this compiler was built on 2025-11-07; consider upgrading it if it is out of date

This is somewhat at odds with Documentation/process/changes.rst which only requires Rust 1.78. I wonder if the rust version requirement should generally be bumped, or if there should be arch-specific requirements somewhere in changes.rst or rust/arch-support.rst.

Best regards,
J. Neuschäfer

[1]: https://github.com/rust-lang/rust/pull/147996

maintainer
#15 lore raw

Re: Rust version requirement (was: [PATCH V2 3/3] powerpc: Enable Rust for ppc64le)

Quoted 28 lines · J. Neuschäfer

On Thu, Feb 05, 2026 at 09:12:01PM +0530, Mukesh Kumar Chaurasiya wrote:
[...]

Quoted 6 lines

use rust version nightly-2026-01-28

the latest one has some issue. I just raised a bug for the rustc here[1].

[1] https://github.com/rust-lang/rust/issues/152177

Another reason to use a nightly version is that Rust inline assembly for PowerPC will only be stabilized[1] in version 1.94, so current release versions fail like this (tested with 1.91.1):

    error[E0658]: inline assembly is not stable yet on this architecture
      --> ../rust/kernel/sync/barrier.rs:19:14
       |
    19 |     unsafe { core::arch::asm!("") };
       |              ^^^^^^^^^^^^^^^^^^^^
       |
       = note: see issue #93335 <https://github.com/rust-lang/rust/issues/93335> for more information
       = help: add `#![feature(asm_experimental_arch)]` to the crate attributes to enable
       = note: this compiler was built on 2025-11-07; consider upgrading it if it is out of date

This is somewhat at odds with Documentation/process/changes.rst which only requires Rust 1.78. I wonder if the rust version requirement should generally be bumped, or if there should be arch-specific requirements somewhere in changes.rst or rust/arch-support.rst.

Quoted 4 lines

Best regards,
J. Neuschäfer

[1]: https://github.com/rust-lang/rust/pull/147996

The MSRV is planned to be bumped to 1.85.

If it's available as a nightly feature on 1.78, then you can just add #![feature(asm_experimental_arch)] to lib.rs, which already enables several other stabilized feature on older compilers.

Otherwise powerpc support can always be gated to require a larger rustc version than other platforms.

Alice

#16 lore raw

Re: [PATCH V2 3/3] powerpc: Enable Rust for ppc64le

In reply to Link Mauve
Quoted 14 lines · Link Mauve

On Thu, Feb 05, 2026 at 02:31:25AM +0530, Mukesh Kumar Chaurasiya (IBM) wrote:
[…]

Quoted 12 lines
rust/Makefile +0 -1
index ae22f2c5f0b3..c3961fd0d9a4 100644
@@ -392,10 +392,17 @@ 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))
 
Quoted 12 lines

rust/Makefile BINDGEN_TARGET_x86 := x86_64-linux-gnu · line 404

Quoted 7 lines
rust/Makefile +7 -0
+ifdef CONFIG_PPC64
+ifdef CONFIG_CPU_LITTLE_ENDIAN
+BINDGEN_TARGET_powerpc	:= powerpc64le-linux-gnu
+endif
+else
+BINDGEN_TARGET_powerpc	:= powerpc-linux-gnu
+endif

You define BINDGEN_TARGET_powerpc after BINDGEN_TARGET has been set to the value of $(BINDGEN_TARGET_$(SRCARCH)), so it is empty and bindgen then gets passed --target= which makes it fail here, with this error message:

I am able to compile it and boot it on ppc64le qemu pseries and powernv9 hardware.

I agree this might cause an issue. Will fix this and send out a new revision.

Quoted 21 lines
```
bindgen ../rust/bindings/bindings_helper.h --blocklist-type __kernel_s?size_t --blocklist-type __kernel_ptrdiff_t --opaque-type xregs_state --opaque-type desc_struct --opaque-type arch_lbr_state --opaque-type local_apic --opaque-type alt_instr --opaque-type x86_msi_data --opaque-type x86_msi_addr_lo --opaque-type kunit_try_catch --opaque-type spinlock --no-doc-comments --blocklist-function __list_.*_report --blocklist-item ARCH_SLAB_MINALIGN --blocklist-item ARCH_KMALLOC_MINALIGN --with-derive-custom-struct .*=MaybeZeroable --with-derive-custom-union .*=MaybeZeroable --rust-target 1.68 --use-core --with-derive-default --ctypes-prefix ffi --no-layout-tests --no-debug '.*' --enable-function-attribute-detection -o rust/bindings/bindings_generated.rs -- -Wp,-MMD,rust/bindings/.bindings_generated.rs.d -nostdinc -I../arch/powerpc/include -I./arch/powerpc/include/generated -I../include -I./include -I../arch/powerpc/include/uapi -I./arch/powerpc/include/generated/uapi -I../include/uapi -I./include/generated/uapi -include ../include/linux/compiler-version.h -include ../include/linux/kconfig.h -include ../include/linux/compiler_types.h -D__KERNEL__ -mbig-endian -m32 -I ../arch/powerpc -fmacro-prefix-map=../= -std=gnu11 -fshort-wchar -funsigned-char -fno-common -fno-PIE -fno-strict-aliasing -msoft-float -mcpu=powerpc -mno-prefixed -mno-pcrel -mno-altivec -mno-vsx -mno-mma -fno-asynchronous-unwind-tables -mbig-endian -fno-delete-null-pointer-checks -Os -fno-stack-protector -fomit-frame-pointer -ftrivial-auto-var-init=zero -fno-strict-overflow -fno-stack-check -fno-builtin-wcslen -Wall -Wextra -Wundef -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Werror=strict-prototypes -Wno-format-security -Wno-trigraphs -Wno-frame-address -Wno-address-of-packed-member -Wmissing-declarations -Wmissing-prototypes -Wframe-larger-than=1280 -Wno-main -Wno-dangling-pointer -Wvla-larger-than=1 -Wno-pointer-sign -Wcast-function-type -Wno-array-bounds -Wno-stringop-overflow -Wno-alloc-size-larger-than -Wimplicit-fallthrough=5 -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -Wenum-conversion -Wunused -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-packed-not-aligned -Wno-format-overflow -Wno-format-truncation -Wno-stringop-truncation -Wno-override-init -Wno-missing-field-initializers -Wno-type-limits -Wno-shift-negative-value -Wno-maybe-uninitialized -Wno-sign-compare -Wno-unused-parameter -DGCC_PLUGINS -I../rust -Irust -DKBUILD_MODFILE='"rust/bindings_generated"' -DKBUILD_BASENAME='"bindings_generated"' -DKBUILD_MODNAME='"bindings_generated"' -D__KBUILD_MODNAME=kmod_bindings_generated -w --target= -fno-builtin -D__BINDGEN__ -DMODULE  ; sed -Ei 's/pub const RUST_CONST_HELPER_([a-zA-Z0-9_]*)/pub const /g' rust/bindings/bindings_generated.rs
error: unsupported option '-mbig-endian' for target ''
error: unsupported option '-mcpu=' for target ''
error: unsupported option '-mno-prefixed' for target ''
error: unsupported option '-mno-pcrel' for target ''
error: unsupported option '-mno-altivec' for target ''
error: unsupported option '-mno-vsx' for target ''
error: unsupported option '-mno-mma' for target ''
error: unsupported option '-mbig-endian' for target ''
error: unknown target triple 'unknown'
panicked at bindgen/ir/context.rs:562:15:
libclang error; possible causes include:
- Invalid flag syntax
- Unrecognized flags
- Invalid flag arguments
- File I/O errors
- Host vs. target architecture mismatch
If you encounter an error missing from this list, please file an issue or a PR!
```
Quoted 2 lines

Did this work on PPC64?

ppc64be still has some missing things from the toolchain side. For ppc64le it does works, atleast on powernv9 hardware and pseries POWER10 qemu.

Quoted 8 lines
Quoted 7 lines
rust/Makefile +1 -0
+
 # All warnings are inhibited since GCC builds are very experimental,
 # many GCC warnings are not supported by Clang, they may only appear in
 # some configurations, with new GCC versions, etc.
Signature · 1 line
2.52.0
Quoted 4 lines

With this fixed:

Thanks.
Regards,
Mukesh

Quoted 2 lines
Signature · 1 line
Link Mauve