* [PATCH V7 0/4] Rust support for powerpc
@ 2026-03-29 16:02 Mukesh Kumar Chaurasiya (IBM)
2026-03-29 16:02 ` [PATCH V7 1/4] rust: Fix a race condition in Makefile Mukesh Kumar Chaurasiya (IBM)
` (4 more replies)
0 siblings, 5 replies; 10+ messages in thread
From: Mukesh Kumar Chaurasiya (IBM) @ 2026-03-29 16:02 UTC (permalink / raw)
To: maddy, mpe, npiggin, chleroy, peterz, jpoimboe, jbaron, aliceryhl,
rostedt, ardb, ojeda, boqun, gary, bjorn3_gh, lossin, a.hindborg,
tmgross, dakr, linuxppc-dev, linux-kernel, rust-for-linux
Cc: Mukesh Kumar Chaurasiya (IBM)
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.
We are actively working with our LLVM team to get the target for ppc,
ppc64 and ppc64le in the rust compiler.
[1] https://lore.kernel.org/all/20260204030507.8203-1-linkmauve@linkmauve.fr
[2] https://lore.kernel.org/all/20260204042417.83903-1-mkchauras@gmail.com
Changelog:
V6 -> V7:
- Documentation removed as powerpc is still under development
- Added a fix for race condition in rust/Makefile
V6: https://lore.kernel.org/all/20260210090023.2587534-1-mkchauras@gmail.com
V5 -> V6:
- Added a missing Tested by from Venkat which got missed since V3
- Support is marked as Maintained instead of experimental
V5: https://lore.kernel.org/all/20260210053756.2088302-1-mkchauras@gmail.com
V4 -> V5:
- Removed a nested ifdef from PPC64 for Little endian toolchain
V4: https://lore.kernel.org/all/20260209105456.1551677-1-mkchauras@gmail.com
V3 -> V4:
- Co-developed-by header added in patch 1
V3: https://lore.kernel.org/all/20260205180429.3280657-1-mkchauras@gmail.com
V2 -> V3:
- Splited HAVE_RUST in 2 lines
- BINDGEN_TARGET_powerpc initialized before assigning the same to
BINDGEN_TARGET
V2: https://lore.kernel.org/all/20260204210125.613350-1-mkchauras@gmail.com
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) (3):
rust: Fix a race condition in Makefile
powerpc/jump_label: adjust inline asm to be consistent
powerpc: Enable Rust for ppc64le
arch/powerpc/Kconfig | 2 ++
arch/powerpc/Makefile | 7 +++++++
arch/powerpc/include/asm/jump_label.h | 23 +++++++++++++----------
rust/Makefile | 13 +++++++++++--
4 files changed, 33 insertions(+), 12 deletions(-)
--
2.53.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH V7 1/4] rust: Fix a race condition in Makefile
2026-03-29 16:02 [PATCH V7 0/4] Rust support for powerpc Mukesh Kumar Chaurasiya (IBM)
@ 2026-03-29 16:02 ` Mukesh Kumar Chaurasiya (IBM)
2026-03-29 17:25 ` Miguel Ojeda
2026-03-29 16:02 ` [PATCH V7 2/4] powerpc/jump_label: adjust inline asm to be consistent Mukesh Kumar Chaurasiya (IBM)
` (3 subsequent siblings)
4 siblings, 1 reply; 10+ messages in thread
From: Mukesh Kumar Chaurasiya (IBM) @ 2026-03-29 16:02 UTC (permalink / raw)
To: maddy, mpe, npiggin, chleroy, peterz, jpoimboe, jbaron, aliceryhl,
rostedt, ardb, ojeda, boqun, gary, bjorn3_gh, lossin, a.hindborg,
tmgross, dakr, linuxppc-dev, linux-kernel, rust-for-linux
Cc: Mukesh Kumar Chaurasiya (IBM)
When compiling with -j1 flag in powerpc, the libproc_macro finds the
libcore.rmeta both in toolchain and local rust directory. libproc_macro
should use the toolchain provided libcore.rmeta.
So for this, make libproc_macro2 libquote and libsyn dependent on core.o
so that libcore.rmeta is generated after these 3 files are done
compiling.
Signed-off-by: Mukesh Kumar Chaurasiya (IBM) <mkchauras@gmail.com>
---
rust/Makefile | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/rust/Makefile b/rust/Makefile
index 9801af2e1e02..8e62f6fcf94f 100644
--- a/rust/Makefile
+++ b/rust/Makefile
@@ -650,7 +650,8 @@ $(obj)/core.o: private skip_flags = $(core-skip_flags)
$(obj)/core.o: private rustc_objcopy = $(foreach sym,$(redirect-intrinsics),--redefine-sym $(sym)=__rust$(sym))
$(obj)/core.o: private rustc_target_flags = $(core-flags)
$(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs \
- $(wildcard $(objtree)/include/config/RUSTC_VERSION_TEXT) FORCE
+ $(wildcard $(objtree)/include/config/RUSTC_VERSION_TEXT) FORCE \
+ | $(obj)/libproc_macro2.rlib $(obj)/libquote.rlib $(obj)/libsyn.rlib FORCE
+$(call if_changed_rule,rustc_library)
ifneq ($(or $(CONFIG_X86_64),$(CONFIG_X86_32)),)
$(obj)/core.o: scripts/target.json
--
2.53.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH V7 2/4] powerpc/jump_label: adjust inline asm to be consistent
2026-03-29 16:02 [PATCH V7 0/4] Rust support for powerpc Mukesh Kumar Chaurasiya (IBM)
2026-03-29 16:02 ` [PATCH V7 1/4] rust: Fix a race condition in Makefile Mukesh Kumar Chaurasiya (IBM)
@ 2026-03-29 16:02 ` Mukesh Kumar Chaurasiya (IBM)
2026-03-29 18:28 ` Gary Guo
2026-03-29 16:02 ` [PATCH V7 3/4] rust: Add PowerPC support Mukesh Kumar Chaurasiya (IBM)
` (2 subsequent siblings)
4 siblings, 1 reply; 10+ messages in thread
From: Mukesh Kumar Chaurasiya (IBM) @ 2026-03-29 16:02 UTC (permalink / raw)
To: maddy, mpe, npiggin, chleroy, peterz, jpoimboe, jbaron, aliceryhl,
rostedt, ardb, ojeda, boqun, gary, bjorn3_gh, lossin, a.hindborg,
tmgross, dakr, linuxppc-dev, linux-kernel, rust-for-linux
Cc: 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")'
Co-developed-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>
Signed-off-by: Mukesh Kumar Chaurasiya (IBM) <mkchauras@gmail.com>
---
arch/powerpc/include/asm/jump_label.h | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
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;
--
2.53.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH V7 3/4] rust: Add PowerPC support
2026-03-29 16:02 [PATCH V7 0/4] Rust support for powerpc Mukesh Kumar Chaurasiya (IBM)
2026-03-29 16:02 ` [PATCH V7 1/4] rust: Fix a race condition in Makefile Mukesh Kumar Chaurasiya (IBM)
2026-03-29 16:02 ` [PATCH V7 2/4] powerpc/jump_label: adjust inline asm to be consistent Mukesh Kumar Chaurasiya (IBM)
@ 2026-03-29 16:02 ` Mukesh Kumar Chaurasiya (IBM)
2026-03-29 16:02 ` [PATCH V7 4/4] powerpc: Enable Rust for ppc64le Mukesh Kumar Chaurasiya (IBM)
2026-03-29 16:20 ` [PATCH V7 0/4] Rust support for powerpc Miguel Ojeda
4 siblings, 0 replies; 10+ messages in thread
From: Mukesh Kumar Chaurasiya (IBM) @ 2026-03-29 16:02 UTC (permalink / raw)
To: maddy, mpe, npiggin, chleroy, peterz, jpoimboe, jbaron, aliceryhl,
rostedt, ardb, ojeda, boqun, gary, bjorn3_gh, lossin, a.hindborg,
tmgross, dakr, linuxppc-dev, linux-kernel, rust-for-linux
Cc: Link Mauve, Mukesh Kumar Chaurasiya (IBM)
From: Link Mauve <linkmauve@linkmauve.fr>
For now only Big Endian 32-bit PowerPC is supported, as that is the only
hardware I have. This has been tested on the Nintendo Wii so far, but I
plan on also using it on the GameCube, Wii U and Apple G4.
These changes aren’t the only ones required to get the kernel to compile
and link on PowerPC, libcore will also have to be changed to not use
integer division to format u64, u128 and core::time::Duration, otherwise
__udivdi3() and __umoddi3() will have to be added. I have tested this
change by replacing the three implementations with unimplemented!() and
it linked just fine.
Signed-off-by: Link Mauve <linkmauve@linkmauve.fr>
Signed-off-by: Mukesh Kumar Chaurasiya (IBM) <mkchauras@gmail.com>
---
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 10240cb80904..1246b3add8ff 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -284,6 +284,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 8e62f6fcf94f..7ea7570e3f17 100644
--- a/rust/Makefile
+++ b/rust/Makefile
@@ -402,13 +402,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
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH V7 4/4] powerpc: Enable Rust for ppc64le
2026-03-29 16:02 [PATCH V7 0/4] Rust support for powerpc Mukesh Kumar Chaurasiya (IBM)
` (2 preceding siblings ...)
2026-03-29 16:02 ` [PATCH V7 3/4] rust: Add PowerPC support Mukesh Kumar Chaurasiya (IBM)
@ 2026-03-29 16:02 ` Mukesh Kumar Chaurasiya (IBM)
2026-03-29 18:33 ` Gary Guo
2026-03-29 16:20 ` [PATCH V7 0/4] Rust support for powerpc Miguel Ojeda
4 siblings, 1 reply; 10+ messages in thread
From: Mukesh Kumar Chaurasiya (IBM) @ 2026-03-29 16:02 UTC (permalink / raw)
To: maddy, mpe, npiggin, chleroy, peterz, jpoimboe, jbaron, aliceryhl,
rostedt, ardb, ojeda, boqun, gary, bjorn3_gh, lossin, a.hindborg,
tmgross, dakr, linuxppc-dev, linux-kernel, rust-for-linux
Cc: Mukesh Kumar Chaurasiya (IBM), Link Mauve, Venkat Rao Bagalkote
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)
Reviewed-by: Link Mauve <linkmauve@linkmauve.fr>
Tested-by: Link Mauve <linkmauve@linkmauve.fr>
Reviewed-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>
Tested-by: Venkat Rao Bagalkote <venkat88@linux.ibm.com>
Signed-off-by: Mukesh Kumar Chaurasiya (IBM) <mkchauras@gmail.com>
---
arch/powerpc/Kconfig | 1 +
arch/powerpc/Makefile | 7 ++++++-
rust/Makefile | 6 ++++++
3 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 1246b3add8ff..a5f50434daf3 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -285,6 +285,7 @@ config PPC
select HAVE_RELIABLE_STACKTRACE
select HAVE_RSEQ
select HAVE_RUST if PPC32
+ select HAVE_RUST if 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
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 589613eaa5dc..9385db478c59 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -61,7 +61,12 @@ else
KBUILD_LDFLAGS_MODULE += $(objtree)/arch/powerpc/lib/crtsavres.o
endif
-KBUILD_RUSTFLAGS += --target=powerpc-unknown-linux-gnu
+ifdef CONFIG_PPC64
+KBUILD_RUSTFLAGS += --target=powerpc64le-unknown-linux-gnu
+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
diff --git a/rust/Makefile b/rust/Makefile
index 7ea7570e3f17..7fe4cbbd176e 100644
--- a/rust/Makefile
+++ b/rust/Makefile
@@ -410,7 +410,13 @@ 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
+
+ifdef CONFIG_PPC64
+BINDGEN_TARGET_powerpc := powerpc64le-linux-gnu
+else
BINDGEN_TARGET_powerpc := powerpc-linux-gnu
+endif
+
BINDGEN_TARGET_um := $(BINDGEN_TARGET_$(SUBARCH))
BINDGEN_TARGET := $(BINDGEN_TARGET_$(SRCARCH))
--
2.53.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH V7 0/4] Rust support for powerpc
2026-03-29 16:02 [PATCH V7 0/4] Rust support for powerpc Mukesh Kumar Chaurasiya (IBM)
` (3 preceding siblings ...)
2026-03-29 16:02 ` [PATCH V7 4/4] powerpc: Enable Rust for ppc64le Mukesh Kumar Chaurasiya (IBM)
@ 2026-03-29 16:20 ` Miguel Ojeda
4 siblings, 0 replies; 10+ messages in thread
From: Miguel Ojeda @ 2026-03-29 16:20 UTC (permalink / raw)
To: Mukesh Kumar Chaurasiya (IBM)
Cc: maddy, mpe, npiggin, chleroy, peterz, jpoimboe, jbaron, aliceryhl,
rostedt, ardb, ojeda, boqun, gary, bjorn3_gh, lossin, a.hindborg,
tmgross, dakr, linuxppc-dev, linux-kernel, rust-for-linux
On Sun, Mar 29, 2026 at 6:03 PM Mukesh Kumar Chaurasiya (IBM)
<mkchauras@gmail.com> wrote:
>
> We are actively working with our LLVM team to get the target for ppc,
> ppc64 and ppc64le in the rust compiler.
That sounds great -- I imagine you refer to a `-none` target? Are
there any links to e.g. upstream Rust issues or PRs that could be nice
to add for context, if any?
It may be good to put this in the commit message. Also, other links
that we should add:
Link: https://github.com/Rust-for-Linux/linux/issues/105
Link: https://github.com/linuxppc/issues/issues/451
Thanks!
Cheers,
Miguel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH V7 1/4] rust: Fix a race condition in Makefile
2026-03-29 16:02 ` [PATCH V7 1/4] rust: Fix a race condition in Makefile Mukesh Kumar Chaurasiya (IBM)
@ 2026-03-29 17:25 ` Miguel Ojeda
2026-03-29 18:26 ` Gary Guo
0 siblings, 1 reply; 10+ messages in thread
From: Miguel Ojeda @ 2026-03-29 17:25 UTC (permalink / raw)
To: Mukesh Kumar Chaurasiya (IBM)
Cc: maddy, mpe, npiggin, chleroy, peterz, jpoimboe, jbaron, aliceryhl,
rostedt, ardb, ojeda, boqun, gary, bjorn3_gh, lossin, a.hindborg,
tmgross, dakr, linuxppc-dev, linux-kernel, rust-for-linux
On Sun, Mar 29, 2026 at 6:03 PM Mukesh Kumar Chaurasiya (IBM)
<mkchauras@gmail.com> wrote:
>
> When compiling with -j1 flag in powerpc, the libproc_macro finds the
> libcore.rmeta both in toolchain and local rust directory. libproc_macro
> should use the toolchain provided libcore.rmeta.
By toolchain, do you mean the sysroot one or something else?
We should make it such that `rustc` does not try to use them to begin
with, e.g. we added `--sysroot=/dev/null` to prevent that in the past,
please see:
71479eee9da8 ("rust: Suppress searching builtin sysroot")
In other words, we should try to avoid adding dependencies (even if
order-only) to workaround the issue, but instead we should get rid of
the root issue.
Otherwise, after a build, if we rebuild only one of them, wouldn't it
find again both? i.e. this is not really a "race condition".
From the original message, I see this was happening when building the
host libraries, because the targets happen to match, i.e. you are
doing a native build on powerpc, right?
Perhaps we could put the host `.rmeta`s separately, or something like that.
Thanks!
Cheers,
Miguel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH V7 1/4] rust: Fix a race condition in Makefile
2026-03-29 17:25 ` Miguel Ojeda
@ 2026-03-29 18:26 ` Gary Guo
0 siblings, 0 replies; 10+ messages in thread
From: Gary Guo @ 2026-03-29 18:26 UTC (permalink / raw)
To: Miguel Ojeda, Mukesh Kumar Chaurasiya (IBM)
Cc: maddy, mpe, npiggin, chleroy, peterz, jpoimboe, jbaron, aliceryhl,
rostedt, ardb, ojeda, boqun, gary, bjorn3_gh, lossin, a.hindborg,
tmgross, dakr, linuxppc-dev, linux-kernel, rust-for-linux
On Sun Mar 29, 2026 at 6:25 PM BST, Miguel Ojeda wrote:
> On Sun, Mar 29, 2026 at 6:03 PM Mukesh Kumar Chaurasiya (IBM)
> <mkchauras@gmail.com> wrote:
>>
>> When compiling with -j1 flag in powerpc, the libproc_macro finds the
>> libcore.rmeta both in toolchain and local rust directory. libproc_macro
>> should use the toolchain provided libcore.rmeta.
>
> By toolchain, do you mean the sysroot one or something else?
>
> We should make it such that `rustc` does not try to use them to begin
> with, e.g. we added `--sysroot=/dev/null` to prevent that in the past,
> please see:
>
> 71479eee9da8 ("rust: Suppress searching builtin sysroot")
>
> In other words, we should try to avoid adding dependencies (even if
> order-only) to workaround the issue, but instead we should get rid of
> the root issue.
>
> Otherwise, after a build, if we rebuild only one of them, wouldn't it
> find again both? i.e. this is not really a "race condition".
>
> From the original message, I see this was happening when building the
> host libraries, because the targets happen to match, i.e. you are
> doing a native build on powerpc, right?
>
> Perhaps we could put the host `.rmeta`s separately, or something like that.
Yeah, we can either remove `-L$(objtree)/$(obj)` and specify `--extern
dep=path-to-dep`, or we can store host libraries to something like
`$(objtree)/$(obj)/host` and use that instead.
The latter should be an easier fix. Also, I can see that we're already having
`-L$(objtree)/$(obj)/test`.
Best,
Gary
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH V7 2/4] powerpc/jump_label: adjust inline asm to be consistent
2026-03-29 16:02 ` [PATCH V7 2/4] powerpc/jump_label: adjust inline asm to be consistent Mukesh Kumar Chaurasiya (IBM)
@ 2026-03-29 18:28 ` Gary Guo
0 siblings, 0 replies; 10+ messages in thread
From: Gary Guo @ 2026-03-29 18:28 UTC (permalink / raw)
To: Mukesh Kumar Chaurasiya (IBM), maddy, mpe, npiggin, chleroy,
peterz, jpoimboe, jbaron, aliceryhl, rostedt, ardb, ojeda, boqun,
gary, bjorn3_gh, lossin, a.hindborg, tmgross, dakr, linuxppc-dev,
linux-kernel, rust-for-linux
On Sun Mar 29, 2026 at 5:02 PM BST, Mukesh Kumar Chaurasiya (IBM) wrote:
> 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")'
>
> Co-developed-by: Madhavan Srinivasan <maddy@linux.ibm.com>
> Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
> Reviewed-by: Alice Ryhl <aliceryhl@google.com>
> Reviewed-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>
> Signed-off-by: Mukesh Kumar Chaurasiya (IBM) <mkchauras@gmail.com>
Reviewed-by: Gary Guo <gary@garyguo.net>
> ---
> arch/powerpc/include/asm/jump_label.h | 23 +++++++++++++----------
> 1 file changed, 13 insertions(+), 10 deletions(-)
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH V7 4/4] powerpc: Enable Rust for ppc64le
2026-03-29 16:02 ` [PATCH V7 4/4] powerpc: Enable Rust for ppc64le Mukesh Kumar Chaurasiya (IBM)
@ 2026-03-29 18:33 ` Gary Guo
0 siblings, 0 replies; 10+ messages in thread
From: Gary Guo @ 2026-03-29 18:33 UTC (permalink / raw)
To: Mukesh Kumar Chaurasiya (IBM), maddy, mpe, npiggin, chleroy,
peterz, jpoimboe, jbaron, aliceryhl, rostedt, ardb, ojeda, boqun,
gary, bjorn3_gh, lossin, a.hindborg, tmgross, dakr, linuxppc-dev,
linux-kernel, rust-for-linux
Cc: Link Mauve, Venkat Rao Bagalkote
On Sun Mar 29, 2026 at 5:02 PM BST, Mukesh Kumar Chaurasiya (IBM) wrote:
> Enabling rust support for ppc64le only.
This line looks inaccurate now given previous commit just enabled it for PPC32
too.
>
> 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)
>
> Reviewed-by: Link Mauve <linkmauve@linkmauve.fr>
> Tested-by: Link Mauve <linkmauve@linkmauve.fr>
> Reviewed-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>
> Tested-by: Venkat Rao Bagalkote <venkat88@linux.ibm.com>
> Signed-off-by: Mukesh Kumar Chaurasiya (IBM) <mkchauras@gmail.com>
> ---
> arch/powerpc/Kconfig | 1 +
> arch/powerpc/Makefile | 7 ++++++-
> rust/Makefile | 6 ++++++
> 3 files changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index 1246b3add8ff..a5f50434daf3 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -285,6 +285,7 @@ config PPC
> select HAVE_RELIABLE_STACKTRACE
> select HAVE_RSEQ
> select HAVE_RUST if PPC32
> + select HAVE_RUST if 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
> diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
> index 589613eaa5dc..9385db478c59 100644
> --- a/arch/powerpc/Makefile
> +++ b/arch/powerpc/Makefile
> @@ -61,7 +61,12 @@ else
> KBUILD_LDFLAGS_MODULE += $(objtree)/arch/powerpc/lib/crtsavres.o
> endif
>
> -KBUILD_RUSTFLAGS += --target=powerpc-unknown-linux-gnu
> +ifdef CONFIG_PPC64
> +KBUILD_RUSTFLAGS += --target=powerpc64le-unknown-linux-gnu
It looks like all it takes to enable PPC BE is to have
#ifdef CONFIG_CPU_LITTLE_ENDIAN
KBUILD_RUSTFLAGS += --target=powerpc64le-unknown-linux-gnu
#else
KBUILD_RUSTFLAGS += --target=powerpc64-unknown-linux-gnu
#endif
(and similarly add bindgen target)?
I think it might worth having PPC32/PPC64/PPC64LE all enabled in a single
commit, and then you can just claim Rust is enabled for PPC and have an
unconditional
select HAVE_RUST
Thoughts?
Best,
Gary
> +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
> diff --git a/rust/Makefile b/rust/Makefile
> index 7ea7570e3f17..7fe4cbbd176e 100644
> --- a/rust/Makefile
> +++ b/rust/Makefile
> @@ -410,7 +410,13 @@ 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
> +
> +ifdef CONFIG_PPC64
> +BINDGEN_TARGET_powerpc := powerpc64le-linux-gnu
> +else
> BINDGEN_TARGET_powerpc := powerpc-linux-gnu
> +endif
> +
> BINDGEN_TARGET_um := $(BINDGEN_TARGET_$(SUBARCH))
> BINDGEN_TARGET := $(BINDGEN_TARGET_$(SRCARCH))
>
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2026-03-29 18:33 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-29 16:02 [PATCH V7 0/4] Rust support for powerpc Mukesh Kumar Chaurasiya (IBM)
2026-03-29 16:02 ` [PATCH V7 1/4] rust: Fix a race condition in Makefile Mukesh Kumar Chaurasiya (IBM)
2026-03-29 17:25 ` Miguel Ojeda
2026-03-29 18:26 ` Gary Guo
2026-03-29 16:02 ` [PATCH V7 2/4] powerpc/jump_label: adjust inline asm to be consistent Mukesh Kumar Chaurasiya (IBM)
2026-03-29 18:28 ` Gary Guo
2026-03-29 16:02 ` [PATCH V7 3/4] rust: Add PowerPC support Mukesh Kumar Chaurasiya (IBM)
2026-03-29 16:02 ` [PATCH V7 4/4] powerpc: Enable Rust for ppc64le Mukesh Kumar Chaurasiya (IBM)
2026-03-29 18:33 ` Gary Guo
2026-03-29 16:20 ` [PATCH V7 0/4] Rust support for powerpc Miguel Ojeda
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox