Skip to contentSkip to conversation

Rust support for powerpc

PATCH Superseded Mukesh Kumar Chaurasiya (IBM) 4 participants 26 messages Apr 17 – Apr 22

Subsystems (4)

v11 of 17 Superseded Latest is v17 →

lore
Share & tools
lore
#0 lore raw

v11 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
- pseries P11 hardware
- pseries(9, 10) qemu
- powernv(9, 10) qemu
- rustdoc on x86 and powerpc64le
- rusttest on x86 and powerpc64le

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/[email protected]
[2] https://lore.kernel.org/all/[email protected]

Changelog:
V10 -> V11:
- Updated rust/Makefile
- Not all libraries are move to rust/host directory now. Only proc_macro2, quote and syn are moved
- Special handling for pin init is added. Details in commit
- Removed mkdir for rust/host, this is now handled by toolchain.
V10: https://lore.kernel.org/all/[email protected]/

V9 -> V10:
- rust/Makefile updated with review comments from Miguel
- Patch 1/4 updated with commit message and subject
V9: https://lore.kernel.org/all/[email protected]/

V8 -> V9:
- rust/Makefile updated with a directory instead of abspath
V8: https://lore.kernel.org/all/[email protected]/

V7 -> V8:
- rust/Makefile updated to separate host libraries from target
V7: https://lore.kernel.org/all/[email protected]/

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/[email protected]

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/[email protected]

V4 -> V5:
- Removed a nested ifdef from PPC64 for Little endian toolchain
V4: https://lore.kernel.org/all/[email protected]

V3 -> V4:
- Co-developed-by header added in patch 1
V3: https://lore.kernel.org/all/[email protected]

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/[email protected]

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 "multiple candidates for rmeta dependency core" error 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                         | 48 +++++++++++++++++----------
 4 files changed, 52 insertions(+), 28 deletions(-)
Signature · 1 line
2.53.0
#1 lore raw

PATCH v11 1/4 rust: Fix "multiple candidates for rmeta dependency core" error

When building Rust code for powerpc64le with LLVM=1 and -j1, rustc encounters an error: "multiple candidates for rmeta dependency core found", with two candidates:
1. The host's standard library from the rustup toolchain
2. The kernel's custom libcore.rmeta in the rust/ directory

This occurs because the build system uses -L$(objtree)/rust for host library builds (proc_macro2, quote, syn), which causes rustc to search the rust/ directory. During this search, rustc finds both the kernel's custom libcore.rmeta and gains access to the host's standard library, creating a conflict.

The solution is to separate host libraries into a dedicated rust/host/ subdirectory and use -L$(objtree)/rust/host for host builds instead of -L$(objtree)/rust. This ensures that:

1. Host library builds (proc_macro2, quote, syn) only search rust/host/ and never encounter the kernel's libcore.rmeta
2. Proc macro builds use -L$(objtree)/rust/host to find their dependencies

Special handling is added for rustdoc-pin_init, which is a host build (to access the alloc crate) but depends on proc macros from the main rust/ directory. It uses explicit --extern paths to reference the proc macros without adding -L$(objtree)/rust, which would reintroduce the conflict.

The rust/host/ directory is added to clean-files to ensure it's removed during make clean.

---
 rust/Makefile | 38 +++++++++++++++++++++-----------------
 1 file changed, 21 insertions(+), 17 deletions(-)
rust/Makefile +21 -17
index 9801af2e1e02..e234b8a39358 100644
@@ -3,6 +3,9 @@
 # Where to place rustdoc generated documentation
 rustdoc_output := $(objtree)/Documentation/output/rust/rustdoc
 
+# Clean generated host directory
+clean-files := host/
+
 obj-$(CONFIG_RUST) += core.o compiler_builtins.o ffi.o
 always-$(CONFIG_RUST) += exports_core_generated.h
 
@@ -27,7 +30,7 @@ endif
 
 obj-$(CONFIG_RUST) += exports.o
 
-always-$(CONFIG_RUST) += libproc_macro2.rlib libquote.rlib libsyn.rlib
+always-$(CONFIG_RUST) += host/libproc_macro2.rlib host/libquote.rlib host/libsyn.rlib
 
 always-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated.rs
 always-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated_kunit.c
@@ -150,7 +153,7 @@ quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $<
 	OBJTREE=$(abspath $(objtree)) \
 	$(RUSTDOC) $(filter-out $(skip_flags) --remap-path-prefix=% --remap-path-scope=%, \
 			$(if $(rustdoc_host),$(rust_common_flags),$(rust_flags))) \
-		$(rustc_target_flags) -L$(objtree)/$(obj) \
+		$(rustc_target_flags) -L$(objtree)/$(obj)$(if $(rustdoc_host),/host) \
 		-Zunstable-options --generate-link-to-definition \
 		--output $(rustdoc_output) \
 		--crate-name $(subst rustdoc-,,$@) \
@@ -237,6 +240,7 @@ rustdoc-pin_init_internal: $(src)/pin-init/internal/src/lib.rs \
 
 rustdoc-pin_init: private rustdoc_host = yes
 rustdoc-pin_init: private rustc_target_flags = $(pin_init-flags) \
+    --extern pin_init_internal=$(objtree)/$(obj)/$(libpin_init_internal_name) \
     --extern alloc --cfg feature=\"alloc\"
 rustdoc-pin_init: $(src)/pin-init/src/lib.rs rustdoc-pin_init_internal \
     rustdoc-macros FORCE
@@ -528,23 +532,23 @@ quiet_cmd_rustc_procmacrolibrary = $(RUSTC_OR_CLIPPY_QUIET) PL $@
 	$(if $(skip_clippy),$(RUSTC),$(RUSTC_OR_CLIPPY)) \
 		$(filter-out $(skip_flags),$(rust_common_flags) $(rustc_target_flags)) \
 		--emit=dep-info=$(depfile) --emit=link=$@ --crate-type rlib -O \
-		--out-dir $(objtree)/$(obj) -L$(objtree)/$(obj) \
+		--out-dir $(objtree)/$(obj)/host -\L$(objtree)/$(obj)/host \
 		--crate-name $(patsubst lib%.rlib,%,$(notdir $@)) $<
 
-$(obj)/libproc_macro2.rlib: private skip_clippy = 1
-$(obj)/libproc_macro2.rlib: private rustc_target_flags = $(proc_macro2-flags)
-$(obj)/libproc_macro2.rlib: $(src)/proc-macro2/lib.rs FORCE
+$(obj)/host/libproc_macro2.rlib: private skip_clippy = 1
+$(obj)/host/libproc_macro2.rlib: private rustc_target_flags = $(proc_macro2-flags)
+$(obj)/host/libproc_macro2.rlib: $(src)/proc-macro2/lib.rs FORCE
 	+$(call if_changed_dep,rustc_procmacrolibrary)
 
-$(obj)/libquote.rlib: private skip_clippy = 1
-$(obj)/libquote.rlib: private skip_flags = $(quote-skip_flags)
-$(obj)/libquote.rlib: private rustc_target_flags = $(quote-flags)
-$(obj)/libquote.rlib: $(src)/quote/lib.rs $(obj)/libproc_macro2.rlib FORCE
+$(obj)/host/libquote.rlib: private skip_clippy = 1
+$(obj)/host/libquote.rlib: private skip_flags = $(quote-skip_flags)
+$(obj)/host/libquote.rlib: private rustc_target_flags = $(quote-flags)
+$(obj)/host/libquote.rlib: $(src)/quote/lib.rs $(obj)/host/libproc_macro2.rlib FORCE
 	+$(call if_changed_dep,rustc_procmacrolibrary)
 
-$(obj)/libsyn.rlib: private skip_clippy = 1
-$(obj)/libsyn.rlib: private rustc_target_flags = $(syn-flags)
-$(obj)/libsyn.rlib: $(src)/syn/lib.rs $(obj)/libquote.rlib FORCE
+$(obj)/host/libsyn.rlib: private skip_clippy = 1
+$(obj)/host/libsyn.rlib: private rustc_target_flags = $(syn-flags)
+$(obj)/host/libsyn.rlib: $(src)/syn/lib.rs $(obj)/host/libquote.rlib FORCE
 	+$(call if_changed_dep,rustc_procmacrolibrary)
 
 quiet_cmd_rustc_procmacro = $(RUSTC_OR_CLIPPY_QUIET) P $@
@@ -553,20 +557,20 @@ quiet_cmd_rustc_procmacro = $(RUSTC_OR_CLIPPY_QUIET) P $@
 		-Clinker-flavor=gcc -Clinker=$(HOSTCC) \
 		-Clink-args='$(call escsq,$(KBUILD_PROCMACROLDFLAGS))' \
 		--emit=dep-info=$(depfile) --emit=link=$@ --extern proc_macro \
-		--crate-type proc-macro -L$(objtree)/$(obj) \
+		--crate-type proc-macro -L$(objtree)/$(obj)/host \
 		--crate-name $(patsubst lib%.$(libmacros_extension),%,$(notdir $@)) \
 		@$(objtree)/include/generated/rustc_cfg $<
 
 # Procedural macros can only be used with the `rustc` that compiled it.
 $(obj)/$(libmacros_name): private rustc_target_flags = \
     --extern proc_macro2 --extern quote --extern syn
-$(obj)/$(libmacros_name): $(src)/macros/lib.rs $(obj)/libproc_macro2.rlib \
-    $(obj)/libquote.rlib $(obj)/libsyn.rlib FORCE
+$(obj)/$(libmacros_name): $(src)/macros/lib.rs $(obj)/host/libproc_macro2.rlib \
+    $(obj)/host/libquote.rlib $(obj)/host/libsyn.rlib FORCE
 	+$(call if_changed_dep,rustc_procmacro)
 
 $(obj)/$(libpin_init_internal_name): private rustc_target_flags = $(pin_init_internal-flags)
 $(obj)/$(libpin_init_internal_name): $(src)/pin-init/internal/src/lib.rs \
-    $(obj)/libproc_macro2.rlib $(obj)/libquote.rlib $(obj)/libsyn.rlib FORCE
+    $(obj)/host/libproc_macro2.rlib $(obj)/host/libquote.rlib $(obj)/host/libsyn.rlib FORCE
 	+$(call if_changed_dep,rustc_procmacro)
 
 # `rustc` requires `-Zunstable-options` to use custom target specifications
Signature · 1 line
2.53.0
#2 lore raw

Re: [PATCH V11 1/4] rust: Fix "multiple candidates for rmeta dependency core" error

Hi Mukesh,

This patch doesn’t apply on top of mainline, which tree did you base it off?

Quoted 61 lines · Mukesh Kumar Chaurasiya (IBM)

When building Rust code for powerpc64le with LLVM=1 and -j1, rustc encounters an error: "multiple candidates for rmeta dependency core found", with two candidates:
1. The host's standard library from the rustup toolchain
2. The kernel's custom libcore.rmeta in the rust/ directory

This occurs because the build system uses -L$(objtree)/rust for host library builds (proc_macro2, quote, syn), which causes rustc to search the rust/ directory. During this search, rustc finds both the kernel's custom libcore.rmeta and gains access to the host's standard library, creating a conflict.

The solution is to separate host libraries into a dedicated rust/host/ subdirectory and use -L$(objtree)/rust/host for host builds instead of -L$(objtree)/rust. This ensures that:

1. Host library builds (proc_macro2, quote, syn) only search rust/host/ and never encounter the kernel's libcore.rmeta
2. Proc macro builds use -L$(objtree)/rust/host to find their dependencies

Special handling is added for rustdoc-pin_init, which is a host build (to access the alloc crate) but depends on proc macros from the main rust/ directory. It uses explicit --extern paths to reference the proc macros without adding -L$(objtree)/rust, which would reintroduce the conflict.

The rust/host/ directory is added to clean-files to ensure it's removed during make clean.

---
 rust/Makefile | 38 +++++++++++++++++++++-----------------
 1 file changed, 21 insertions(+), 17 deletions(-)
rust/Makefile +4 -1
index 9801af2e1e02..e234b8a39358 100644
@@ -3,6 +3,9 @@
 # Where to place rustdoc generated documentation
 rustdoc_output := $(objtree)/Documentation/output/rust/rustdoc
 
+# Clean generated host directory
+clean-files := host/
+
 obj-$(CONFIG_RUST) += core.o compiler_builtins.o ffi.o
 always-$(CONFIG_RUST) += exports_core_generated.h
 
@@ -27,7 +30,7 @@ endif
 
 obj-$(CONFIG_RUST) += exports.o
 
-always-$(CONFIG_RUST) += libproc_macro2.rlib libquote.rlib libsyn.rlib
+always-$(CONFIG_RUST) += host/libproc_macro2.rlib host/libquote.rlib host/libsyn.rlib
 
 always-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated.rs
 always-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated_kunit.c

rust/Makefile quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $< · line 155

Quoted 3 lines
rust/Makefile +0 -0
@@ -150,7 +153,7 @@ quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $<
 	OBJTREE=$(abspath $(objtree)) \
 	$(RUSTDOC) $(filter-out $(skip_flags) --remap-path-prefix=% --remap-path-scope=%, \
 			$(if $(rustdoc_host),$(rust_common_flags),$(rust_flags))) \

The issue is here ↑, --remap-path-prefix=% got removed and the two previous lines got merged into one.

rust/Makefile quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $< · line 159

Quoted 5 lines
rust/Makefile +1 -1
-		$(rustc_target_flags) -L$(objtree)/$(obj) \
+		$(rustc_target_flags) -L$(objtree)/$(obj)$(if $(rustdoc_host),/host) \
 		-Zunstable-options --generate-link-to-definition \
 		--output $(rustdoc_output) \
 		--crate-name $(subst rustdoc-,,$@) \

[…]

Thanks anyway for iterating on this series! I’ve started writing a DRM driver based off a previous version. :)

Signature · 1 line
Link Mauve
#3 lore raw

Re: [PATCH V11 1/4] rust: Fix "multiple candidates for rmeta dependency core" error

Quoted 5 lines · Link Mauve

Hi Mukesh,

This patch doesn’t apply on top of mainline, which tree did you base it off?

It was on mainline v7.0 tag.
On latest there is a confilict. I'll send out a rebased version.

Quoted 59 lines · Mukesh Kumar Chaurasiya (IBM)
Quoted 58 lines

When building Rust code for powerpc64le with LLVM=1 and -j1, rustc encounters an error: "multiple candidates for rmeta dependency core found", with two candidates:
1. The host's standard library from the rustup toolchain
2. The kernel's custom libcore.rmeta in the rust/ directory

This occurs because the build system uses -L$(objtree)/rust for host library builds (proc_macro2, quote, syn), which causes rustc to search the rust/ directory. During this search, rustc finds both the kernel's custom libcore.rmeta and gains access to the host's standard library, creating a conflict.

The solution is to separate host libraries into a dedicated rust/host/ subdirectory and use -L$(objtree)/rust/host for host builds instead of -L$(objtree)/rust. This ensures that:

1. Host library builds (proc_macro2, quote, syn) only search rust/host/ and never encounter the kernel's libcore.rmeta
2. Proc macro builds use -L$(objtree)/rust/host to find their dependencies

Special handling is added for rustdoc-pin_init, which is a host build (to access the alloc crate) but depends on proc macros from the main rust/ directory. It uses explicit --extern paths to reference the proc macros without adding -L$(objtree)/rust, which would reintroduce the conflict.

The rust/host/ directory is added to clean-files to ensure it's removed during make clean.

---
 rust/Makefile | 38 +++++++++++++++++++++-----------------
 1 file changed, 21 insertions(+), 17 deletions(-)
rust/Makefile +4 -1
index 9801af2e1e02..e234b8a39358 100644
@@ -3,6 +3,9 @@
 # Where to place rustdoc generated documentation
 rustdoc_output := $(objtree)/Documentation/output/rust/rustdoc
 
+# Clean generated host directory
+clean-files := host/
+
 obj-$(CONFIG_RUST) += core.o compiler_builtins.o ffi.o
 always-$(CONFIG_RUST) += exports_core_generated.h
 
@@ -27,7 +30,7 @@ endif
 
 obj-$(CONFIG_RUST) += exports.o
 
-always-$(CONFIG_RUST) += libproc_macro2.rlib libquote.rlib libsyn.rlib
+always-$(CONFIG_RUST) += host/libproc_macro2.rlib host/libquote.rlib host/libsyn.rlib
 
Quoted 10 lines

rust/Makefile quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $< · line 155

Quoted 6 lines
rust/Makefile +0 -0
 always-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated.rs
 always-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated_kunit.c
@@ -150,7 +153,7 @@ quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $<
 	OBJTREE=$(abspath $(objtree)) \
 	$(RUSTDOC) $(filter-out $(skip_flags) --remap-path-prefix=% --remap-path-scope=%, \
 			$(if $(rustdoc_host),$(rust_common_flags),$(rust_flags))) \

The issue is here ↑, --remap-path-prefix=% got removed and the two previous lines got merged into one.

Yeah will fix this.

Quoted 10 lines

rust/Makefile quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $< · line 159

Quoted 5 lines
rust/Makefile +1 -1
-		$(rustc_target_flags) -L$(objtree)/$(obj) \
+		$(rustc_target_flags) -L$(objtree)/$(obj)$(if $(rustdoc_host),/host) \
 		-Zunstable-options --generate-link-to-definition \
 		--output $(rustdoc_output) \
 		--crate-name $(subst rustdoc-,,$@) \

[…]

Thanks anyway for iterating on this series! I’ve started writing a DRM driver based off a previous version. :)

That's cool. Thanks.

Regards,
Mukesh

Quoted 3 lines
Signature · 1 line
Link Mauve
#4 lore raw

Re: [PATCH V11 1/4] rust: Fix "multiple candidates for rmeta dependency core" error

Quoted 7 lines · Mukesh Kumar Chaurasiya
Quoted 5 lines · Link Mauve

Hi Mukesh,

This patch doesn’t apply on top of mainline, which tree did you base it off?

It was on mainline v7.0 tag.

Great thanks, they do apply there!

I needed three more patches for the kernel to build on PPC32, I’ve attached them but they are absolutely not patches which could go into the kernel (except for the second, enabling asm_experimental_arch).

What do you think we should do about them?

Quoted 89 lines

On latest there is a confilict. I'll send out a rebased version.

Quoted 59 lines · Mukesh Kumar Chaurasiya (IBM)
Quoted 58 lines

When building Rust code for powerpc64le with LLVM=1 and -j1, rustc encounters an error: "multiple candidates for rmeta dependency core found", with two candidates:
1. The host's standard library from the rustup toolchain
2. The kernel's custom libcore.rmeta in the rust/ directory

This occurs because the build system uses -L$(objtree)/rust for host library builds (proc_macro2, quote, syn), which causes rustc to search the rust/ directory. During this search, rustc finds both the kernel's custom libcore.rmeta and gains access to the host's standard library, creating a conflict.

The solution is to separate host libraries into a dedicated rust/host/ subdirectory and use -L$(objtree)/rust/host for host builds instead of -L$(objtree)/rust. This ensures that:

1. Host library builds (proc_macro2, quote, syn) only search rust/host/ and never encounter the kernel's libcore.rmeta
2. Proc macro builds use -L$(objtree)/rust/host to find their dependencies

Special handling is added for rustdoc-pin_init, which is a host build (to access the alloc crate) but depends on proc macros from the main rust/ directory. It uses explicit --extern paths to reference the proc macros without adding -L$(objtree)/rust, which would reintroduce the conflict.

The rust/host/ directory is added to clean-files to ensure it's removed during make clean.

---
 rust/Makefile | 38 +++++++++++++++++++++-----------------
 1 file changed, 21 insertions(+), 17 deletions(-)
rust/Makefile +4 -1
index 9801af2e1e02..e234b8a39358 100644
@@ -3,6 +3,9 @@
 # Where to place rustdoc generated documentation
 rustdoc_output := $(objtree)/Documentation/output/rust/rustdoc
 
+# Clean generated host directory
+clean-files := host/
+
 obj-$(CONFIG_RUST) += core.o compiler_builtins.o ffi.o
 always-$(CONFIG_RUST) += exports_core_generated.h
 
@@ -27,7 +30,7 @@ endif
 
 obj-$(CONFIG_RUST) += exports.o
 
-always-$(CONFIG_RUST) += libproc_macro2.rlib libquote.rlib libsyn.rlib
+always-$(CONFIG_RUST) += host/libproc_macro2.rlib host/libquote.rlib host/libsyn.rlib
 
Quoted 10 lines

rust/Makefile quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $< · line 155

Quoted 6 lines
rust/Makefile +0 -0
 always-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated.rs
 always-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated_kunit.c
@@ -150,7 +153,7 @@ quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $<
 	OBJTREE=$(abspath $(objtree)) \
 	$(RUSTDOC) $(filter-out $(skip_flags) --remap-path-prefix=% --remap-path-scope=%, \
 			$(if $(rustdoc_host),$(rust_common_flags),$(rust_flags))) \

The issue is here ↑, --remap-path-prefix=% got removed and the two previous lines got merged into one.

Yeah will fix this.

Quoted 10 lines

rust/Makefile quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $< · line 159

Quoted 5 lines
rust/Makefile +1 -1
-		$(rustc_target_flags) -L$(objtree)/$(obj) \
+		$(rustc_target_flags) -L$(objtree)/$(obj)$(if $(rustdoc_host),/host) \
 		-Zunstable-options --generate-link-to-definition \
 		--output $(rustdoc_output) \
 		--crate-name $(subst rustdoc-,,$@) \

[…]

Thanks anyway for iterating on this series! I’ve started writing a DRM driver based off a previous version. :)

That's cool. Thanks.

Regards,
Mukesh

Quoted 3 lines
Signature · 1 line
Link Mauve
Signature · 1 line
Link Mauve

From 79b614dd7be16a1108e1f0176a7bc235fa163a4e Mon Sep 17 00:00:00 2001
From: Link Mauve <[email protected]>
Date: Wed, 8 Apr 2026 14:16:04 +0200
Subject: [PATCH 1/3] XXX: Workaround sstep.c

These variables are used only on CONFIG_PPC64, which causes compilation to fail on PPC32.

---
 arch/powerpc/lib/sstep.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
arch/powerpc/lib/sstep.c +4 -4
index ac3ee19531d8..dc129f0cb6a0 100644
@@ -1354,15 +1354,15 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
 #ifdef CONFIG_PPC64
 	unsigned int suffixopcode, prefixtype, prefix_r;
 #endif
-	unsigned int opcode, ra, rb, rc, rd, spr, u;
+	unsigned int opcode, ra, rb/*, rc*/, rd, spr, u;
 	unsigned long int imm;
 	unsigned long int val, val2;
 	unsigned int mb, me, sh;
-	unsigned int word, suffix;
+	unsigned int word/*, suffix*/;
 	long ival;
 
 	word = ppc_inst_val(instr);
-	suffix = ppc_inst_suffix(instr);
+	//suffix = ppc_inst_suffix(instr);
 
 	op->type = COMPUTE;
 
@@ -1480,7 +1480,7 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
 	rd = (word >> 21) & 0x1f;
 	ra = (word >> 16) & 0x1f;
 	rb = (word >> 11) & 0x1f;
-	rc = (word >> 6) & 0x1f;
+	//rc = (word >> 6) & 0x1f;
 
 	switch (opcode) {
 #ifdef __powerpc64__
Signature · 1 line
2.54.0

From d4e72fad43175bde99287b8efdece900e5b53444 Mon Sep 17 00:00:00 2001
From: Link Mauve <[email protected]>
Date: Fri, 10 Apr 2026 13:05:24 +0200
Subject: [PATCH 2/3] XXX: Enable asm_experimental_arch for PowerPC asm!()

This is needed to compile the kernel crate, otherwise this error happens:

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 2026-03-25; consider upgrading it if it is out of date

error: aborting due to 1 previous error

For more information about this error, try rustc --explain E0658.

---
 rust/kernel/lib.rs     | 3 +++
 scripts/Makefile.build | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)
rust/kernel/lib.rs +3 -0
index d93292d47420..92ccd47dc3ee 100644
@@ -47,6 +47,9 @@
 // To be determined.
 #![feature(used_with_arg)]
 //
+// Needed for PowerPC inline assembly.
+#![feature(asm_experimental_arch)]
+//
 // `feature(derive_coerce_pointee)` is expected to become stable. Before Rust
 // 1.84.0, it did not exist, so enable the predecessor features.
 #![cfg_attr(CONFIG_RUSTC_HAS_COERCE_POINTEE, feature(derive_coerce_pointee))]
scripts/Makefile.build +1 -1
index 3652b85be545..c7cc21994c5a 100644
@@ -321,7 +321,7 @@ $(obj)/%.lst: $(obj)/%.c FORCE
 #
 # Please see https://github.com/Rust-for-Linux/linux/issues/2 for details on
 # the unstable features in use.
-rust_allowed_features := asm_const,asm_goto,arbitrary_self_types,lint_reasons,offset_of_nested,raw_ref_op,slice_ptr_len,strict_provenance,used_with_arg
+rust_allowed_features := asm_const,asm_goto,asm_experimental_arch,arbitrary_self_types,lint_reasons,offset_of_nested,raw_ref_op,slice_ptr_len,strict_provenance,used_with_arg
 
 # `--out-dir` is required to avoid temporaries being created by `rustc` in the
 # current working directory, which may be not accessible in the out-of-tree
Signature · 1 line
2.54.0

From 2c0a3ec3da6fa1f0151225c05159f7a812317d32 Mon Sep 17 00:00:00 2001
From: Link Mauve <[email protected]>
Date: Fri, 10 Apr 2026 13:51:24 +0200
Subject: [PATCH 3/3] XXX: Workaround for __udivdi3() and __umoddi3()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The core crate currently depends on these two functions for i64/u64/ i128/u128/core::time::Duration formatting, but we shouldn’t use that in the kernel so let’s panic if they are ever called.

---
 rust/exports.c | 9 +++++++++
 1 file changed, 9 insertions(+)
rust/exports.c +9 -0
index 587f0e776aba..5f1cdf13882e 100644
@@ -12,6 +12,7 @@
  */
 
 #include <linux/export.h>
+#include <linux/panic.h>
 
 #define EXPORT_SYMBOL_RUST_GPL(sym) extern int sym; EXPORT_SYMBOL_GPL(sym)
 
@@ -20,6 +21,14 @@
 #include "exports_bindings_generated.h"
 #include "exports_kernel_generated.h"
 
+void __udivdi3(void) {
+	panic("__udivdi3() called but shouldn’t be made available on this architecture!\n");
+}
+
+void __umoddi3(void) {
+	panic("__umoddi3() called but shouldn’t be made available on this architecture!\n");
+}
+
 // For modules using `rust/build_error.rs`.
 #ifdef CONFIG_RUST_BUILD_ASSERT_ALLOW
 EXPORT_SYMBOL_RUST_GPL(rust_build_error);
Signature · 1 line
2.54.0
#5 lore raw

Re: [PATCH V11 1/4] rust: Fix "multiple candidates for rmeta dependency core" error

Quoted 9 lines · Link Mauve
Quoted 7 lines · Mukesh Kumar Chaurasiya
Quoted 5 lines · Link Mauve

Hi Mukesh,

This patch doesn’t apply on top of mainline, which tree did you base it off?

It was on mainline v7.0 tag.

Quoted 8 lines

Great thanks, they do apply there!

I needed three more patches for the kernel to build on PPC32, I’ve attached them but they are absolutely not patches which could go into the kernel (except for the second, enabling asm_experimental_arch).

What do you think we should do about them?

Regarding the 2nd patch you sent, As the support is experimental as of now, Let's wait till we get everything stablized, till then we'll use nightly build for all variants of powerpc. Once we mark it as maintained, then we can try to push that patch.

Maybe Miguel can comment better on this.

Regarding other patches, I am planning to work on ppc32 once ppc64le stabilizes.

Regards,
Mukesh

Quoted 242 lines
Quoted 89 lines

On latest there is a confilict. I'll send out a rebased version.

Quoted 59 lines · Mukesh Kumar Chaurasiya (IBM)
Quoted 58 lines

When building Rust code for powerpc64le with LLVM=1 and -j1, rustc encounters an error: "multiple candidates for rmeta dependency core found", with two candidates:
1. The host's standard library from the rustup toolchain
2. The kernel's custom libcore.rmeta in the rust/ directory

This occurs because the build system uses -L$(objtree)/rust for host library builds (proc_macro2, quote, syn), which causes rustc to search the rust/ directory. During this search, rustc finds both the kernel's custom libcore.rmeta and gains access to the host's standard library, creating a conflict.

The solution is to separate host libraries into a dedicated rust/host/ subdirectory and use -L$(objtree)/rust/host for host builds instead of -L$(objtree)/rust. This ensures that:

1. Host library builds (proc_macro2, quote, syn) only search rust/host/ and never encounter the kernel's libcore.rmeta
2. Proc macro builds use -L$(objtree)/rust/host to find their dependencies

Special handling is added for rustdoc-pin_init, which is a host build (to access the alloc crate) but depends on proc macros from the main rust/ directory. It uses explicit --extern paths to reference the proc macros without adding -L$(objtree)/rust, which would reintroduce the conflict.

The rust/host/ directory is added to clean-files to ensure it's removed during make clean.

---
 rust/Makefile | 38 +++++++++++++++++++++-----------------
 1 file changed, 21 insertions(+), 17 deletions(-)
rust/Makefile +4 -1
index 9801af2e1e02..e234b8a39358 100644
@@ -3,6 +3,9 @@
 # Where to place rustdoc generated documentation
 rustdoc_output := $(objtree)/Documentation/output/rust/rustdoc
 
+# Clean generated host directory
+clean-files := host/
+
 obj-$(CONFIG_RUST) += core.o compiler_builtins.o ffi.o
 always-$(CONFIG_RUST) += exports_core_generated.h
 
@@ -27,7 +30,7 @@ endif
 
 obj-$(CONFIG_RUST) += exports.o
 
-always-$(CONFIG_RUST) += libproc_macro2.rlib libquote.rlib libsyn.rlib
+always-$(CONFIG_RUST) += host/libproc_macro2.rlib host/libquote.rlib host/libsyn.rlib
 
Quoted 10 lines

rust/Makefile quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $< · line 155

Quoted 6 lines
rust/Makefile +0 -0
 always-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated.rs
 always-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated_kunit.c
@@ -150,7 +153,7 @@ quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $<
 	OBJTREE=$(abspath $(objtree)) \
 	$(RUSTDOC) $(filter-out $(skip_flags) --remap-path-prefix=% --remap-path-scope=%, \
 			$(if $(rustdoc_host),$(rust_common_flags),$(rust_flags))) \

The issue is here ↑, --remap-path-prefix=% got removed and the two previous lines got merged into one.

Yeah will fix this.

Quoted 10 lines

rust/Makefile quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $< · line 159

Quoted 5 lines
rust/Makefile +1 -1
-		$(rustc_target_flags) -L$(objtree)/$(obj) \
+		$(rustc_target_flags) -L$(objtree)/$(obj)$(if $(rustdoc_host),/host) \
 		-Zunstable-options --generate-link-to-definition \
 		--output $(rustdoc_output) \
 		--crate-name $(subst rustdoc-,,$@) \

[…]

Thanks anyway for iterating on this series! I’ve started writing a DRM driver based off a previous version. :)

That's cool. Thanks.

Regards,
Mukesh

Quoted 3 lines
Signature · 1 line
Link Mauve
Signature · 12 lines
Link Mauve

From 79b614dd7be16a1108e1f0176a7bc235fa163a4e Mon Sep 17 00:00:00 2001
From: Link Mauve <[email protected]>
Date: Wed, 8 Apr 2026 14:16:04 +0200
Subject: [PATCH 1/3] XXX: Workaround sstep.c

These variables are used only on CONFIG_PPC64, which causes compilation
to fail on PPC32.
---
 arch/powerpc/lib/sstep.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
arch/powerpc/lib/sstep.c +4 -4
index ac3ee19531d8..dc129f0cb6a0 100644
@@ -1354,15 +1354,15 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
 #ifdef CONFIG_PPC64
 	unsigned int suffixopcode, prefixtype, prefix_r;
 #endif
-	unsigned int opcode, ra, rb, rc, rd, spr, u;
+	unsigned int opcode, ra, rb/*, rc*/, rd, spr, u;
 	unsigned long int imm;
 	unsigned long int val, val2;
 	unsigned int mb, me, sh;
-	unsigned int word, suffix;
+	unsigned int word/*, suffix*/;
 	long ival;
 
 	word = ppc_inst_val(instr);
-	suffix = ppc_inst_suffix(instr);
+	//suffix = ppc_inst_suffix(instr);
 
 	op->type = COMPUTE;
 
@@ -1480,7 +1480,7 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
 	rd = (word >> 21) & 0x1f;
 	ra = (word >> 16) & 0x1f;
 	rb = (word >> 11) & 0x1f;
-	rc = (word >> 6) & 0x1f;
+	//rc = (word >> 6) & 0x1f;
 
 	switch (opcode) {
 #ifdef __powerpc64__
Signature · 28 lines
2.54.0


From d4e72fad43175bde99287b8efdece900e5b53444 Mon Sep 17 00:00:00 2001
From: Link Mauve <[email protected]>
Date: Fri, 10 Apr 2026 13:05:24 +0200
Subject: [PATCH 2/3] XXX: Enable asm_experimental_arch for PowerPC asm!()

This is needed to compile the kernel crate, otherwise this error
happens:

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 2026-03-25; consider upgrading it if it is out of date

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0658`.
---
 rust/kernel/lib.rs     | 3 +++
 scripts/Makefile.build | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)
rust/kernel/lib.rs +3 -0
index d93292d47420..92ccd47dc3ee 100644
@@ -47,6 +47,9 @@
 // To be determined.
 #![feature(used_with_arg)]
 //
+// Needed for PowerPC inline assembly.
+#![feature(asm_experimental_arch)]
+//
 // `feature(derive_coerce_pointee)` is expected to become stable. Before Rust
 // 1.84.0, it did not exist, so enable the predecessor features.
 #![cfg_attr(CONFIG_RUSTC_HAS_COERCE_POINTEE, feature(derive_coerce_pointee))]
scripts/Makefile.build +1 -1
index 3652b85be545..c7cc21994c5a 100644
@@ -321,7 +321,7 @@ $(obj)/%.lst: $(obj)/%.c FORCE
 #
 # Please see https://github.com/Rust-for-Linux/linux/issues/2 for details on
 # the unstable features in use.
-rust_allowed_features := asm_const,asm_goto,arbitrary_self_types,lint_reasons,offset_of_nested,raw_ref_op,slice_ptr_len,strict_provenance,used_with_arg
+rust_allowed_features := asm_const,asm_goto,asm_experimental_arch,arbitrary_self_types,lint_reasons,offset_of_nested,raw_ref_op,slice_ptr_len,strict_provenance,used_with_arg
 
 # `--out-dir` is required to avoid temporaries being created by `rustc` in the
 # current working directory, which may be not accessible in the out-of-tree
Signature · 17 lines
2.54.0


From 2c0a3ec3da6fa1f0151225c05159f7a812317d32 Mon Sep 17 00:00:00 2001
From: Link Mauve <[email protected]>
Date: Fri, 10 Apr 2026 13:51:24 +0200
Subject: [PATCH 3/3] XXX: Workaround for __udivdi3() and __umoddi3()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The core crate currently depends on these two functions for i64/u64/
i128/u128/core::time::Duration formatting, but we shouldn’t use that in
the kernel so let’s panic if they are ever called.
---
 rust/exports.c | 9 +++++++++
 1 file changed, 9 insertions(+)
rust/exports.c +9 -0
index 587f0e776aba..5f1cdf13882e 100644
@@ -12,6 +12,7 @@
  */
 
 #include <linux/export.h>
+#include <linux/panic.h>
 
 #define EXPORT_SYMBOL_RUST_GPL(sym) extern int sym; EXPORT_SYMBOL_GPL(sym)
 
@@ -20,6 +21,14 @@
 #include "exports_bindings_generated.h"
 #include "exports_kernel_generated.h"
 
+void __udivdi3(void) {
+	panic("__udivdi3() called but shouldn’t be made available on this architecture!\n");
+}
+
+void __umoddi3(void) {
+	panic("__umoddi3() called but shouldn’t be made available on this architecture!\n");
+}
+
 // For modules using `rust/build_error.rs`.
 #ifdef CONFIG_RUST_BUILD_ASSERT_ALLOW
 EXPORT_SYMBOL_RUST_GPL(rust_build_error);
Signature · 1 line
2.54.0
#6 lore raw

Re: [PATCH V11 1/4] rust: Fix "multiple candidates for rmeta dependency core" error

Quoted 16 lines · Mukesh Kumar Chaurasiya
Quoted 15 lines · Link Mauve
Quoted 7 lines · Mukesh Kumar Chaurasiya
Quoted 5 lines · Link Mauve

Hi Mukesh,

This patch doesn’t apply on top of mainline, which tree did you base it off?

It was on mainline v7.0 tag.

Great thanks, they do apply there!

I needed three more patches for the kernel to build on PPC32, I’ve attached them but they are absolutely not patches which could go into the kernel (except for the second, enabling asm_experimental_arch).

Quoted 6 lines
Quoted 2 lines

What do you think we should do about them?

Regarding the 2nd patch you sent, As the support is experimental as of now, Let's wait till we get everything stablized, till then we'll use nightly build for all variants of powerpc. Once we mark it as maintained, then we can try to push that patch.

Enabling the feature is mandatory even on nightly or with RUSTC_BOOTSTRAP=1, otherwise no asm!() macro can be called and so the kernel crate can’t be built.

Quoted 5 lines

Maybe Miguel can comment better on this.

Regarding other patches, I am planning to work on ppc32 once ppc64le stabilizes.

Thanks!

Quoted 248 lines

Regards,
Mukesh

Quoted 242 lines
Quoted 89 lines

On latest there is a confilict. I'll send out a rebased version.

Quoted 59 lines · Mukesh Kumar Chaurasiya (IBM)
Quoted 58 lines

When building Rust code for powerpc64le with LLVM=1 and -j1, rustc encounters an error: "multiple candidates for rmeta dependency core found", with two candidates:
1. The host's standard library from the rustup toolchain
2. The kernel's custom libcore.rmeta in the rust/ directory

This occurs because the build system uses -L$(objtree)/rust for host library builds (proc_macro2, quote, syn), which causes rustc to search the rust/ directory. During this search, rustc finds both the kernel's custom libcore.rmeta and gains access to the host's standard library, creating a conflict.

The solution is to separate host libraries into a dedicated rust/host/ subdirectory and use -L$(objtree)/rust/host for host builds instead of -L$(objtree)/rust. This ensures that:

1. Host library builds (proc_macro2, quote, syn) only search rust/host/ and never encounter the kernel's libcore.rmeta
2. Proc macro builds use -L$(objtree)/rust/host to find their dependencies

Special handling is added for rustdoc-pin_init, which is a host build (to access the alloc crate) but depends on proc macros from the main rust/ directory. It uses explicit --extern paths to reference the proc macros without adding -L$(objtree)/rust, which would reintroduce the conflict.

The rust/host/ directory is added to clean-files to ensure it's removed during make clean.

---
 rust/Makefile | 38 +++++++++++++++++++++-----------------
 1 file changed, 21 insertions(+), 17 deletions(-)
rust/Makefile +4 -1
index 9801af2e1e02..e234b8a39358 100644
@@ -3,6 +3,9 @@
 # Where to place rustdoc generated documentation
 rustdoc_output := $(objtree)/Documentation/output/rust/rustdoc
 
+# Clean generated host directory
+clean-files := host/
+
 obj-$(CONFIG_RUST) += core.o compiler_builtins.o ffi.o
 always-$(CONFIG_RUST) += exports_core_generated.h
 
@@ -27,7 +30,7 @@ endif
 
 obj-$(CONFIG_RUST) += exports.o
 
-always-$(CONFIG_RUST) += libproc_macro2.rlib libquote.rlib libsyn.rlib
+always-$(CONFIG_RUST) += host/libproc_macro2.rlib host/libquote.rlib host/libsyn.rlib
 
Quoted 10 lines

rust/Makefile quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $< · line 155

Quoted 6 lines
rust/Makefile +0 -0
 always-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated.rs
 always-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated_kunit.c
@@ -150,7 +153,7 @@ quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $<
 	OBJTREE=$(abspath $(objtree)) \
 	$(RUSTDOC) $(filter-out $(skip_flags) --remap-path-prefix=% --remap-path-scope=%, \
 			$(if $(rustdoc_host),$(rust_common_flags),$(rust_flags))) \

The issue is here ↑, --remap-path-prefix=% got removed and the two previous lines got merged into one.

Yeah will fix this.

Quoted 10 lines

rust/Makefile quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $< · line 159

Quoted 5 lines
rust/Makefile +1 -1
-		$(rustc_target_flags) -L$(objtree)/$(obj) \
+		$(rustc_target_flags) -L$(objtree)/$(obj)$(if $(rustdoc_host),/host) \
 		-Zunstable-options --generate-link-to-definition \
 		--output $(rustdoc_output) \
 		--crate-name $(subst rustdoc-,,$@) \

[…]

Thanks anyway for iterating on this series! I’ve started writing a DRM driver based off a previous version. :)

That's cool. Thanks.

Regards,
Mukesh

Quoted 3 lines
Signature · 1 line
Link Mauve
Signature · 12 lines
Link Mauve

From 79b614dd7be16a1108e1f0176a7bc235fa163a4e Mon Sep 17 00:00:00 2001
From: Link Mauve <[email protected]>
Date: Wed, 8 Apr 2026 14:16:04 +0200
Subject: [PATCH 1/3] XXX: Workaround sstep.c

These variables are used only on CONFIG_PPC64, which causes compilation
to fail on PPC32.
---
 arch/powerpc/lib/sstep.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
arch/powerpc/lib/sstep.c +4 -4
index ac3ee19531d8..dc129f0cb6a0 100644
@@ -1354,15 +1354,15 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
 #ifdef CONFIG_PPC64
 	unsigned int suffixopcode, prefixtype, prefix_r;
 #endif
-	unsigned int opcode, ra, rb, rc, rd, spr, u;
+	unsigned int opcode, ra, rb/*, rc*/, rd, spr, u;
 	unsigned long int imm;
 	unsigned long int val, val2;
 	unsigned int mb, me, sh;
-	unsigned int word, suffix;
+	unsigned int word/*, suffix*/;
 	long ival;
 
 	word = ppc_inst_val(instr);
-	suffix = ppc_inst_suffix(instr);
+	//suffix = ppc_inst_suffix(instr);
 
 	op->type = COMPUTE;
 
@@ -1480,7 +1480,7 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
 	rd = (word >> 21) & 0x1f;
 	ra = (word >> 16) & 0x1f;
 	rb = (word >> 11) & 0x1f;
-	rc = (word >> 6) & 0x1f;
+	//rc = (word >> 6) & 0x1f;
 
 	switch (opcode) {
 #ifdef __powerpc64__
Signature · 28 lines
2.54.0


From d4e72fad43175bde99287b8efdece900e5b53444 Mon Sep 17 00:00:00 2001
From: Link Mauve <[email protected]>
Date: Fri, 10 Apr 2026 13:05:24 +0200
Subject: [PATCH 2/3] XXX: Enable asm_experimental_arch for PowerPC asm!()

This is needed to compile the kernel crate, otherwise this error
happens:

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 2026-03-25; consider upgrading it if it is out of date

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0658`.
---
 rust/kernel/lib.rs     | 3 +++
 scripts/Makefile.build | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)
rust/kernel/lib.rs +3 -0
index d93292d47420..92ccd47dc3ee 100644
@@ -47,6 +47,9 @@
 // To be determined.
 #![feature(used_with_arg)]
 //
+// Needed for PowerPC inline assembly.
+#![feature(asm_experimental_arch)]
+//
 // `feature(derive_coerce_pointee)` is expected to become stable. Before Rust
 // 1.84.0, it did not exist, so enable the predecessor features.
 #![cfg_attr(CONFIG_RUSTC_HAS_COERCE_POINTEE, feature(derive_coerce_pointee))]
scripts/Makefile.build +1 -1
index 3652b85be545..c7cc21994c5a 100644
@@ -321,7 +321,7 @@ $(obj)/%.lst: $(obj)/%.c FORCE
 #
 # Please see https://github.com/Rust-for-Linux/linux/issues/2 for details on
 # the unstable features in use.
-rust_allowed_features := asm_const,asm_goto,arbitrary_self_types,lint_reasons,offset_of_nested,raw_ref_op,slice_ptr_len,strict_provenance,used_with_arg
+rust_allowed_features := asm_const,asm_goto,asm_experimental_arch,arbitrary_self_types,lint_reasons,offset_of_nested,raw_ref_op,slice_ptr_len,strict_provenance,used_with_arg
 
 # `--out-dir` is required to avoid temporaries being created by `rustc` in the
 # current working directory, which may be not accessible in the out-of-tree
Signature · 17 lines
2.54.0


From 2c0a3ec3da6fa1f0151225c05159f7a812317d32 Mon Sep 17 00:00:00 2001
From: Link Mauve <[email protected]>
Date: Fri, 10 Apr 2026 13:51:24 +0200
Subject: [PATCH 3/3] XXX: Workaround for __udivdi3() and __umoddi3()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The core crate currently depends on these two functions for i64/u64/
i128/u128/core::time::Duration formatting, but we shouldn’t use that in
the kernel so let’s panic if they are ever called.
---
 rust/exports.c | 9 +++++++++
 1 file changed, 9 insertions(+)
rust/exports.c +9 -0
index 587f0e776aba..5f1cdf13882e 100644
@@ -12,6 +12,7 @@
  */
 
 #include <linux/export.h>
+#include <linux/panic.h>
 
 #define EXPORT_SYMBOL_RUST_GPL(sym) extern int sym; EXPORT_SYMBOL_GPL(sym)
 
@@ -20,6 +21,14 @@
 #include "exports_bindings_generated.h"
 #include "exports_kernel_generated.h"
 
+void __udivdi3(void) {
+	panic("__udivdi3() called but shouldn’t be made available on this architecture!\n");
+}
+
+void __umoddi3(void) {
+	panic("__umoddi3() called but shouldn’t be made available on this architecture!\n");
+}
+
 // For modules using `rust/build_error.rs`.
 #ifdef CONFIG_RUST_BUILD_ASSERT_ALLOW
 EXPORT_SYMBOL_RUST_GPL(rust_build_error);
Signature · 1 line
2.54.0
Signature · 1 line
Link Mauve
#7 lore raw

Re: [PATCH V11 1/4] rust: Fix "multiple candidates for rmeta dependency core" error

Quoted 19 lines · Link Mauve
Quoted 18 lines · Mukesh Kumar Chaurasiya
Quoted 17 lines · Link Mauve
Quoted 7 lines · Mukesh Kumar Chaurasiya
Quoted 5 lines · Link Mauve

Hi Mukesh,

This patch doesn’t apply on top of mainline, which tree did you base it off?

It was on mainline v7.0 tag.

Great thanks, they do apply there!

I needed three more patches for the kernel to build on PPC32, I’ve attached them but they are absolutely not patches which could go into the kernel (except for the second, enabling asm_experimental_arch).

What do you think we should do about them?

Quoted 9 lines
Quoted 4 lines

Regarding the 2nd patch you sent, As the support is experimental as of now, Let's wait till we get everything stablized, till then we'll use nightly build for all variants of powerpc. Once we mark it as maintained, then we can try to push that patch.

Enabling the feature is mandatory even on nightly or with RUSTC_BOOTSTRAP=1, otherwise no asm!() macro can be called and so the kernel crate can’t be built.

The stable support is available on nightly. Refer https://github.com/rust-lang/rust/pull/147996

Regards,
Mukesh

Quoted 259 lines
Quoted 5 lines

Maybe Miguel can comment better on this.

Regarding other patches, I am planning to work on ppc32 once ppc64le stabilizes.

Thanks!

Quoted 248 lines

Regards,
Mukesh

Quoted 242 lines
Quoted 89 lines

On latest there is a confilict. I'll send out a rebased version.

Quoted 59 lines · Mukesh Kumar Chaurasiya (IBM)
Quoted 58 lines

When building Rust code for powerpc64le with LLVM=1 and -j1, rustc encounters an error: "multiple candidates for rmeta dependency core found", with two candidates:
1. The host's standard library from the rustup toolchain
2. The kernel's custom libcore.rmeta in the rust/ directory

This occurs because the build system uses -L$(objtree)/rust for host library builds (proc_macro2, quote, syn), which causes rustc to search the rust/ directory. During this search, rustc finds both the kernel's custom libcore.rmeta and gains access to the host's standard library, creating a conflict.

The solution is to separate host libraries into a dedicated rust/host/ subdirectory and use -L$(objtree)/rust/host for host builds instead of -L$(objtree)/rust. This ensures that:

1. Host library builds (proc_macro2, quote, syn) only search rust/host/ and never encounter the kernel's libcore.rmeta
2. Proc macro builds use -L$(objtree)/rust/host to find their dependencies

Special handling is added for rustdoc-pin_init, which is a host build (to access the alloc crate) but depends on proc macros from the main rust/ directory. It uses explicit --extern paths to reference the proc macros without adding -L$(objtree)/rust, which would reintroduce the conflict.

The rust/host/ directory is added to clean-files to ensure it's removed during make clean.

---
 rust/Makefile | 38 +++++++++++++++++++++-----------------
 1 file changed, 21 insertions(+), 17 deletions(-)
rust/Makefile +4 -1
index 9801af2e1e02..e234b8a39358 100644
@@ -3,6 +3,9 @@
 # Where to place rustdoc generated documentation
 rustdoc_output := $(objtree)/Documentation/output/rust/rustdoc
 
+# Clean generated host directory
+clean-files := host/
+
 obj-$(CONFIG_RUST) += core.o compiler_builtins.o ffi.o
 always-$(CONFIG_RUST) += exports_core_generated.h
 
@@ -27,7 +30,7 @@ endif
 
 obj-$(CONFIG_RUST) += exports.o
 
-always-$(CONFIG_RUST) += libproc_macro2.rlib libquote.rlib libsyn.rlib
+always-$(CONFIG_RUST) += host/libproc_macro2.rlib host/libquote.rlib host/libsyn.rlib
 
Quoted 10 lines

rust/Makefile quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $< · line 155

Quoted 6 lines
rust/Makefile +0 -0
 always-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated.rs
 always-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated_kunit.c
@@ -150,7 +153,7 @@ quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $<
 	OBJTREE=$(abspath $(objtree)) \
 	$(RUSTDOC) $(filter-out $(skip_flags) --remap-path-prefix=% --remap-path-scope=%, \
 			$(if $(rustdoc_host),$(rust_common_flags),$(rust_flags))) \

The issue is here ↑, --remap-path-prefix=% got removed and the two previous lines got merged into one.

Yeah will fix this.

Quoted 10 lines

rust/Makefile quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $< · line 159

Quoted 5 lines
rust/Makefile +1 -1
-		$(rustc_target_flags) -L$(objtree)/$(obj) \
+		$(rustc_target_flags) -L$(objtree)/$(obj)$(if $(rustdoc_host),/host) \
 		-Zunstable-options --generate-link-to-definition \
 		--output $(rustdoc_output) \
 		--crate-name $(subst rustdoc-,,$@) \

[…]

Thanks anyway for iterating on this series! I’ve started writing a DRM driver based off a previous version. :)

That's cool. Thanks.

Regards,
Mukesh

Quoted 3 lines
Signature · 1 line
Link Mauve
Signature · 12 lines
Link Mauve

From 79b614dd7be16a1108e1f0176a7bc235fa163a4e Mon Sep 17 00:00:00 2001
From: Link Mauve <[email protected]>
Date: Wed, 8 Apr 2026 14:16:04 +0200
Subject: [PATCH 1/3] XXX: Workaround sstep.c

These variables are used only on CONFIG_PPC64, which causes compilation
to fail on PPC32.
---
 arch/powerpc/lib/sstep.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
arch/powerpc/lib/sstep.c +4 -4
index ac3ee19531d8..dc129f0cb6a0 100644
@@ -1354,15 +1354,15 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
 #ifdef CONFIG_PPC64
 	unsigned int suffixopcode, prefixtype, prefix_r;
 #endif
-	unsigned int opcode, ra, rb, rc, rd, spr, u;
+	unsigned int opcode, ra, rb/*, rc*/, rd, spr, u;
 	unsigned long int imm;
 	unsigned long int val, val2;
 	unsigned int mb, me, sh;
-	unsigned int word, suffix;
+	unsigned int word/*, suffix*/;
 	long ival;
 
 	word = ppc_inst_val(instr);
-	suffix = ppc_inst_suffix(instr);
+	//suffix = ppc_inst_suffix(instr);
 
 	op->type = COMPUTE;
 
@@ -1480,7 +1480,7 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
 	rd = (word >> 21) & 0x1f;
 	ra = (word >> 16) & 0x1f;
 	rb = (word >> 11) & 0x1f;
-	rc = (word >> 6) & 0x1f;
+	//rc = (word >> 6) & 0x1f;
 
 	switch (opcode) {
 #ifdef __powerpc64__
Signature · 28 lines
2.54.0


From d4e72fad43175bde99287b8efdece900e5b53444 Mon Sep 17 00:00:00 2001
From: Link Mauve <[email protected]>
Date: Fri, 10 Apr 2026 13:05:24 +0200
Subject: [PATCH 2/3] XXX: Enable asm_experimental_arch for PowerPC asm!()

This is needed to compile the kernel crate, otherwise this error
happens:

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 2026-03-25; consider upgrading it if it is out of date

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0658`.
---
 rust/kernel/lib.rs     | 3 +++
 scripts/Makefile.build | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)
rust/kernel/lib.rs +3 -0
index d93292d47420..92ccd47dc3ee 100644
@@ -47,6 +47,9 @@
 // To be determined.
 #![feature(used_with_arg)]
 //
+// Needed for PowerPC inline assembly.
+#![feature(asm_experimental_arch)]
+//
 // `feature(derive_coerce_pointee)` is expected to become stable. Before Rust
 // 1.84.0, it did not exist, so enable the predecessor features.
 #![cfg_attr(CONFIG_RUSTC_HAS_COERCE_POINTEE, feature(derive_coerce_pointee))]
scripts/Makefile.build +1 -1
index 3652b85be545..c7cc21994c5a 100644
@@ -321,7 +321,7 @@ $(obj)/%.lst: $(obj)/%.c FORCE
 #
 # Please see https://github.com/Rust-for-Linux/linux/issues/2 for details on
 # the unstable features in use.
-rust_allowed_features := asm_const,asm_goto,arbitrary_self_types,lint_reasons,offset_of_nested,raw_ref_op,slice_ptr_len,strict_provenance,used_with_arg
+rust_allowed_features := asm_const,asm_goto,asm_experimental_arch,arbitrary_self_types,lint_reasons,offset_of_nested,raw_ref_op,slice_ptr_len,strict_provenance,used_with_arg
 
 # `--out-dir` is required to avoid temporaries being created by `rustc` in the
 # current working directory, which may be not accessible in the out-of-tree
Signature · 17 lines
2.54.0


From 2c0a3ec3da6fa1f0151225c05159f7a812317d32 Mon Sep 17 00:00:00 2001
From: Link Mauve <[email protected]>
Date: Fri, 10 Apr 2026 13:51:24 +0200
Subject: [PATCH 3/3] XXX: Workaround for __udivdi3() and __umoddi3()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The core crate currently depends on these two functions for i64/u64/
i128/u128/core::time::Duration formatting, but we shouldn’t use that in
the kernel so let’s panic if they are ever called.
---
 rust/exports.c | 9 +++++++++
 1 file changed, 9 insertions(+)
rust/exports.c +9 -0
index 587f0e776aba..5f1cdf13882e 100644
@@ -12,6 +12,7 @@
  */
 
 #include <linux/export.h>
+#include <linux/panic.h>
 
 #define EXPORT_SYMBOL_RUST_GPL(sym) extern int sym; EXPORT_SYMBOL_GPL(sym)
 
@@ -20,6 +21,14 @@
 #include "exports_bindings_generated.h"
 #include "exports_kernel_generated.h"
 
+void __udivdi3(void) {
+	panic("__udivdi3() called but shouldn’t be made available on this architecture!\n");
+}
+
+void __umoddi3(void) {
+	panic("__umoddi3() called but shouldn’t be made available on this architecture!\n");
+}
+
 // For modules using `rust/build_error.rs`.
 #ifdef CONFIG_RUST_BUILD_ASSERT_ALLOW
 EXPORT_SYMBOL_RUST_GPL(rust_build_error);
Signature · 1 line
2.54.0
Signature · 1 line
Link Mauve
reviewer
#8 lore raw

Re: [PATCH V11 1/4] rust: Fix "multiple candidates for rmeta dependency core" error

Quoted 25 lines · Mukesh Kumar Chaurasiya
Quoted 24 lines · Link Mauve
Quoted 22 lines · Mukesh Kumar Chaurasiya
Quoted 9 lines · Link Mauve
Quoted 7 lines · Mukesh Kumar Chaurasiya
Quoted 5 lines · Link Mauve

Hi Mukesh,

This patch doesn’t apply on top of mainline, which tree did you base it off?

It was on mainline v7.0 tag.

Quoted 8 lines

Great thanks, they do apply there!

I needed three more patches for the kernel to build on PPC32, I’ve attached them but they are absolutely not patches which could go into the kernel (except for the second, enabling asm_experimental_arch).

What do you think we should do about them?

Regarding the 2nd patch you sent, As the support is experimental as of now, Let's wait till we get everything stablized, till then we'll use nightly build for all variants of powerpc. Once we mark it as maintained, then we can try to push that patch.

Quoted 6 lines
Quoted 4 lines

Enabling the feature is mandatory even on nightly or with RUSTC_BOOTSTRAP=1, otherwise no asm!() macro can be called and so the kernel crate can’t be built.

The stable support is available on nightly. Refer https://github.com/rust-lang/rust/pull/147996

In that case you should add the feature with a comment that it's needed for PPC only and is stable in 1.95.

Best,
Gary

Quoted 8 lines

Regards,
Mukesh

Quoted 5 lines
Quoted 5 lines

Maybe Miguel can comment better on this.

Regarding other patches, I am planning to work on ppc32 once ppc64le stabilizes.

#9 lore raw

Re: [PATCH V11 1/4] rust: Fix "multiple candidates for rmeta dependency core" error

Quoted 30 lines · Gary Guo
Quoted 29 lines · Mukesh Kumar Chaurasiya
Quoted 28 lines · Link Mauve
Quoted 16 lines · Mukesh Kumar Chaurasiya
Quoted 15 lines · Link Mauve
Quoted 7 lines · Mukesh Kumar Chaurasiya
Quoted 5 lines · Link Mauve

Hi Mukesh,

This patch doesn’t apply on top of mainline, which tree did you base it off?

It was on mainline v7.0 tag.

Great thanks, they do apply there!

I needed three more patches for the kernel to build on PPC32, I’ve attached them but they are absolutely not patches which could go into the kernel (except for the second, enabling asm_experimental_arch).

Quoted 6 lines
Quoted 2 lines

What do you think we should do about them?

Regarding the 2nd patch you sent, As the support is experimental as of now, Let's wait till we get everything stablized, till then we'll use nightly build for all variants of powerpc. Once we mark it as maintained, then we can try to push that patch.

Enabling the feature is mandatory even on nightly or with RUSTC_BOOTSTRAP=1, otherwise no asm!() macro can be called and so the kernel crate can’t be built.

Quoted 9 lines
Quoted 2 lines

The stable support is available on nightly. Refer https://github.com/rust-lang/rust/pull/147996

In that case you should add the feature with a comment that it's needed for PPC only and is stable in 1.95.

Best,
Gary

There are some other build errors apart from this on 1.85. So few months back in the meeting with LLVM team we concluded that for sometime powerpc will be ahead of other archs at 1.95 till others catch up.

Regards,
Mukesh

Quoted 9 lines
Quoted 8 lines

Regards,
Mukesh

Quoted 5 lines
Quoted 5 lines

Maybe Miguel can comment better on this.

Regarding other patches, I am planning to work on ppc32 once ppc64le stabilizes.

reviewer
#10 lore raw

Re: [PATCH V11 1/4] rust: Fix "multiple candidates for rmeta dependency core" error

Quoted 37 lines · Mukesh Kumar Chaurasiya
Quoted 36 lines · Gary Guo
Quoted 25 lines · Mukesh Kumar Chaurasiya
Quoted 24 lines · Link Mauve
Quoted 22 lines · Mukesh Kumar Chaurasiya
Quoted 9 lines · Link Mauve
Quoted 7 lines · Mukesh Kumar Chaurasiya
Quoted 5 lines · Link Mauve

Hi Mukesh,

This patch doesn’t apply on top of mainline, which tree did you base it off?

It was on mainline v7.0 tag.

Quoted 8 lines

Great thanks, they do apply there!

I needed three more patches for the kernel to build on PPC32, I’ve attached them but they are absolutely not patches which could go into the kernel (except for the second, enabling asm_experimental_arch).

What do you think we should do about them?

Regarding the 2nd patch you sent, As the support is experimental as of now, Let's wait till we get everything stablized, till then we'll use nightly build for all variants of powerpc. Once we mark it as maintained, then we can try to push that patch.

Quoted 6 lines
Quoted 4 lines

Enabling the feature is mandatory even on nightly or with RUSTC_BOOTSTRAP=1, otherwise no asm!() macro can be called and so the kernel crate can’t be built.

The stable support is available on nightly. Refer https://github.com/rust-lang/rust/pull/147996

In that case you should add the feature with a comment that it's needed for PPC only and is stable in 1.95.

Quoted 7 lines
Quoted 3 lines

Best,
Gary

There are some other build errors apart from this on 1.85. So few months back in the meeting with LLVM team we concluded that for sometime powerpc will be ahead of other archs at 1.95 till others catch up.

Is that LLVM 22 being relied on?

If that's the case, you should also gate PPC with CONFIG_RUSTC_LLVM_VERSION. It's possible to build a Rust with older LLVM versions.

Best,
Gary

#11 lore raw

Re: [PATCH V11 1/4] rust: Fix "multiple candidates for rmeta dependency core" error

In reply to Mukesh Kumar Chaurasiya
Quoted 4 lines · Mukesh Kumar Chaurasiya

There are some other build errors apart from this on 1.85. So few months back in the meeting with LLVM team we concluded that for sometime powerpc will be ahead of other archs at 1.95 till others catch up.

In that case you may want to modify scripts/min-tool-version.sh in this series too.

I hope that helps!

Cheers,
Miguel

#12 lore raw

Re: [PATCH V11 1/4] rust: Fix "multiple candidates for rmeta dependency core" error

Quoted 12 lines · Miguel Ojeda
Quoted 4 lines · Mukesh Kumar Chaurasiya

There are some other build errors apart from this on 1.85. So few months back in the meeting with LLVM team we concluded that for sometime powerpc will be ahead of other archs at 1.95 till others catch up.

In that case you may want to modify scripts/min-tool-version.sh in this series too.

I hope that helps!

Yeah this helps, Thanks :)

Will post out a new series soon.

Regards,
Mukesh

Quoted 2 lines

Cheers,
Miguel

#13 lore raw

Re: [PATCH V11 1/4] rust: Fix "multiple candidates for rmeta dependency core" error

Quoted 8 lines · Mukesh Kumar Chaurasiya
Quoted 7 lines · Miguel Ojeda
Quoted 4 lines · Mukesh Kumar Chaurasiya

There are some other build errors apart from this on 1.85. So few months back in the meeting with LLVM team we concluded that for sometime powerpc will be ahead of other archs at 1.95 till others catch up.

Quoted 8 lines
Quoted 5 lines

In that case you may want to modify scripts/min-tool-version.sh in this series too.

I hope that helps!

Yeah this helps, Thanks :)

Will post out a new series soon.

Great thanks!

For your new series you might want to incorporate the attached patch, which makes the core crate build on PowerPC.

Quoted 5 lines

Regards,
Mukesh

Quoted 2 lines

Cheers,
Miguel

Signature · 1 line
Link Mauve

From 120e1283d1e49d73df483496ffc669328511657c Mon Sep 17 00:00:00 2001
From: Link Mauve <[email protected]>
Date: Fri, 10 Apr 2026 13:51:24 +0200
Subject: [PATCH] rust: Make __udivdi3() and __umoddi3() panic
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The core crate currently depends on these two functions for i64/u64/ i128/u128/core::time::Duration formatting, but we shouldn’t use that in the kernel so let’s panic if they are ever called.

This doesn’t yet fix drm_panic_qr.rs, which also uses __udivdi3 when CONFIG_CC_OPTIMIZE_FOR_SIZE=y, but at least makes the rest of the kernel build on PPC32.

---
 rust/Makefile             | 4 ++++
 rust/compiler_builtins.rs | 6 ++++++
 2 files changed, 10 insertions(+)
rust/Makefile +4 -0
index 99537c2c55ee..568f241a21a7 100644
@@ -626,6 +626,10 @@ ifneq ($(or $(CONFIG_ARM64),$(and $(CONFIG_RISCV),$(CONFIG_64BIT))),)
 		__ashrti3 \
 		__ashlti3 __lshrti3
 endif
+ifdef CONFIG_PPC32
+	redirect-intrinsics += \
+		__udivdi3 __umoddi3
+endif
 
 ifdef CONFIG_MODVERSIONS
 cmd_gendwarfksyms = $(if $(skip_gendwarfksyms),, \
rust/compiler_builtins.rs +6 -0
index dd16c1dc899c..fc6b54636dd5 100644
@@ -97,5 +97,11 @@ pub extern "C" fn $ident() {
     __aeabi_uldivmod,
 });
 
+#[cfg(target_arch = "powerpc")]
+define_panicking_intrinsics!("`u64` division/modulo should not be used", {
+    __udivdi3,
+    __umoddi3,
+});
+
 // NOTE: if you are adding a new intrinsic here, you should also add it to
 // `redirect-intrinsics` in `rust/Makefile`.
Signature · 1 line
2.54.0
#15 lore raw

Re: [PATCH V11 1/4] rust: Fix "multiple candidates for rmeta dependency core" error

Quoted 6 lines · Miguel Ojeda
Quoted 3 lines · Mukesh Kumar Chaurasiya

The stable support is available on nightly. Refer https://github.com/rust-lang/rust/pull/147996

Quoted 7 lines

That PR was merged for 1.95.0, so it is already available in the latest release, no? Or do you mean something else?

Thanks!

Cheers,
Miguel

Hey Miguel,

Yeah that's what i mean. It's available in 1.95.

Regards,
Mukesh

reviewer
#16 lore raw

Re: [PATCH V11 1/4] rust: Fix "multiple candidates for rmeta dependency core" error

In reply to Link Mauve
Quoted 29 lines · Link Mauve

From 2c0a3ec3da6fa1f0151225c05159f7a812317d32 Mon Sep 17 00:00:00 2001
From: Link Mauve <[email protected]>
Date: Fri, 10 Apr 2026 13:51:24 +0200
Subject: [PATCH 3/3] XXX: Workaround for __udivdi3() and __umoddi3()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The core crate currently depends on these two functions for i64/u64/ i128/u128/core::time::Duration formatting, but we shouldn’t use that in the kernel so let’s panic if they are ever called.

---
 rust/exports.c | 9 +++++++++
 1 file changed, 9 insertions(+)
rust/exports.c +1 -0
index 587f0e776aba..5f1cdf13882e 100644
@@ -12,6 +12,7 @@
  */
 
 #include <linux/export.h>
+#include <linux/panic.h>
 
 #define EXPORT_SYMBOL_RUST_GPL(sym) extern int sym; EXPORT_SYMBOL_GPL(sym)
 
@@ -20,6 +21,14 @@
 #include "exports_bindings_generated.h"

rust/exports.c line 31

Quoted 10 lines
rust/exports.c +8 -0
 #include "exports_kernel_generated.h"
 
+void __udivdi3(void) {
+	panic("__udivdi3() called but shouldn’t be made available on this architecture!\n");
+}
+
+void __umoddi3(void) {
+	panic("__umoddi3() called but shouldn’t be made available on this architecture!\n");
+}
+

This should be added to compiler_builtins.rs and gated for PPC32.

Best,
Gary

Quoted 3 lines
rust/exports.c +0 -0
 // For modules using `rust/build_error.rs`.
 #ifdef CONFIG_RUST_BUILD_ASSERT_ALLOW
 EXPORT_SYMBOL_RUST_GPL(rust_build_error);
#17 lore raw

Re: [PATCH V11 1/4] rust: Fix "multiple candidates for rmeta dependency core" error

Hi,

Quoted 32 lines · Gary Guo
Quoted 31 lines · Link Mauve

From 2c0a3ec3da6fa1f0151225c05159f7a812317d32 Mon Sep 17 00:00:00 2001
From: Link Mauve <[email protected]>
Date: Fri, 10 Apr 2026 13:51:24 +0200
Subject: [PATCH 3/3] XXX: Workaround for __udivdi3() and __umoddi3()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The core crate currently depends on these two functions for i64/u64/ i128/u128/core::time::Duration formatting, but we shouldn’t use that in the kernel so let’s panic if they are ever called.

---
 rust/exports.c | 9 +++++++++
 1 file changed, 9 insertions(+)
rust/exports.c +1 -0
index 587f0e776aba..5f1cdf13882e 100644
@@ -12,6 +12,7 @@
  */
 
 #include <linux/export.h>
+#include <linux/panic.h>
 
 #define EXPORT_SYMBOL_RUST_GPL(sym) extern int sym; EXPORT_SYMBOL_GPL(sym)
 
@@ -20,6 +21,14 @@
 #include "exports_bindings_generated.h"
 #include "exports_kernel_generated.h"
 
Quoted 10 lines

rust/exports.c line 31

Quoted 8 lines
rust/exports.c +8 -0
+void __udivdi3(void) {
+	panic("__udivdi3() called but shouldn’t be made available on this architecture!\n");
+}
+
+void __umoddi3(void) {
+	panic("__umoddi3() called but shouldn’t be made available on this architecture!\n");
+}
+

This should be added to compiler_builtins.rs and gated for PPC32.

Thanks for the suggestion, this already seems like a much better location for that!

This works fine for the core crate, but now panic_qr also gets the same issue, here it is with V=1:

```
+ powerpc-linux-musl-ld -EB -m elf32ppc -z noexecstack --no-warn-rwx-segments -Bstatic --build-id=sha1 --orphan-handling=warn --script=./arch/powerpc/kernel/vmlinux.lds --strip-debug -o .tmp_vmlinux1 --whole-archive vmlinux.a .vmlinux.export.o init/version-timestamp.o --no-whole-archive --start-group --end-group .tmp_vmlinux0.kallsyms.o
powerpc-linux-musl-ld: drivers/gpu/drm/drm_panic_qr.o: in function `<drm_panic_qr::SegmentIterator as core::iter::traits::iterator::Iterator>::next':
drm_panic_qr.f39a15fa3c72e9fe-cgu.0:(.text+0x200c): undefined reference to `__udivdi3'
```

From a cursory look at the SegmentIterator::next() function I don’t understand where the division could come up, but it’s actually nice to get an error when operations which shouldn’t happen happen anyway, it makes it more likely to get them fixed.

Quoted 8 lines

Best,
Gary

Quoted 3 lines
rust/exports.c +0 -0
 // For modules using `rust/build_error.rs`.
 #ifdef CONFIG_RUST_BUILD_ASSERT_ALLOW
 EXPORT_SYMBOL_RUST_GPL(rust_build_error);
Signature · 1 line
Link Mauve

From c938984c5974ba636699ce0e2cfabeb45a8d861d Mon Sep 17 00:00:00 2001
From: Link Mauve <[email protected]>
Date: Fri, 10 Apr 2026 13:51:24 +0200
Subject: [PATCH] rust: Make __udivdi3() and __umoddi3() panic
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The core crate currently depends on these two functions for i64/u64/ i128/u128/core::time::Duration formatting, but we shouldn’t use that in the kernel so let’s panic if they are ever called.

---
 rust/Makefile             | 4 ++++
 rust/compiler_builtins.rs | 6 ++++++
 2 files changed, 10 insertions(+)
rust/Makefile +4 -0
index 99537c2c55ee..568f241a21a7 100644
@@ -626,6 +626,10 @@ ifneq ($(or $(CONFIG_ARM64),$(and $(CONFIG_RISCV),$(CONFIG_64BIT))),)
 		__ashrti3 \
 		__ashlti3 __lshrti3
 endif
+ifdef CONFIG_PPC32
+	redirect-intrinsics += \
+		__udivdi3 __umoddi3
+endif
 
 ifdef CONFIG_MODVERSIONS
 cmd_gendwarfksyms = $(if $(skip_gendwarfksyms),, \
rust/compiler_builtins.rs +6 -0
index dd16c1dc899c..fc6b54636dd5 100644
@@ -97,5 +97,11 @@ pub extern "C" fn $ident() {
     __aeabi_uldivmod,
 });
 
+#[cfg(target_arch = "powerpc")]
+define_panicking_intrinsics!("`u64` division/modulo should not be used", {
+    __udivdi3,
+    __umoddi3,
+});
+
 // NOTE: if you are adding a new intrinsic here, you should also add it to
 // `redirect-intrinsics` in `rust/Makefile`.
Signature · 1 line
2.54.0
reviewer
#18 lore raw

Re: [PATCH V11 1/4] rust: Fix "multiple candidates for rmeta dependency core" error

Quoted 8 lines · Link Mauve

This works fine for the core crate, but now panic_qr also gets the same issue, here it is with V=1:

```
+ powerpc-linux-musl-ld -EB -m elf32ppc -z noexecstack --no-warn-rwx-segments -Bstatic --build-id=sha1 --orphan-handling=warn --script=./arch/powerpc/kernel/vmlinux.lds --strip-debug -o .tmp_vmlinux1 --whole-archive vmlinux.a .vmlinux.export.o init/version-timestamp.o --no-whole-archive --start-group --end-group .tmp_vmlinux0.kallsyms.o
powerpc-linux-musl-ld: drivers/gpu/drm/drm_panic_qr.o: in function `<drm_panic_qr::SegmentIterator as core::iter::traits::iterator::Iterator>::next':
drm_panic_qr.f39a15fa3c72e9fe-cgu.0:(.text+0x200c): undefined reference to `__udivdi3'
```
Quoted 4 lines

From a cursory look at the SegmentIterator::next() function I don’t understand where the division could come up, but it’s actually nice to get an error when operations which shouldn’t happen happen anyway, it makes it more likely to get them fixed.

There is divide / modular by 10 code. Although, this shouldn't really cause __udivdi3 to be generated for constant divisor, unless -C opt-level=s is used. Do you happen to use that opt-level?

Best,
Gary

#19 lore raw

Re: [PATCH V11 1/4] rust: Fix "multiple candidates for rmeta dependency core" error

Quoted 10 lines · Gary Guo
Quoted 8 lines · Link Mauve

This works fine for the core crate, but now panic_qr also gets the same issue, here it is with V=1:

```
+ powerpc-linux-musl-ld -EB -m elf32ppc -z noexecstack --no-warn-rwx-segments -Bstatic --build-id=sha1 --orphan-handling=warn --script=./arch/powerpc/kernel/vmlinux.lds --strip-debug -o .tmp_vmlinux1 --whole-archive vmlinux.a .vmlinux.export.o init/version-timestamp.o --no-whole-archive --start-group --end-group .tmp_vmlinux0.kallsyms.o
powerpc-linux-musl-ld: drivers/gpu/drm/drm_panic_qr.o: in function `<drm_panic_qr::SegmentIterator as core::iter::traits::iterator::Iterator>::next':
drm_panic_qr.f39a15fa3c72e9fe-cgu.0:(.text+0x200c): undefined reference to `__udivdi3'
```
Quoted 8 lines
Quoted 4 lines

From a cursory look at the SegmentIterator::next() function I don’t understand where the division could come up, but it’s actually nice to get an error when operations which shouldn’t happen happen anyway, it makes it more likely to get them fixed.

There is divide / modular by 10 code. Although, this shouldn't really cause __udivdi3 to be generated for constant divisor, unless -C opt-level=s is used. Do you happen to use that opt-level?

Indeed that was it!

With CONFIG_CC_OPTIMIZE_FOR_SIZE=y the kernel is 4 MiB large, and with CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE=y it is 4.9 MiB large, but CONFIG_DRM_PANIC_SCREEN_QR_CODE=y works.

As I target the Wii which has only 88 MiB of RAM, a difference of 920 KiB is actually quite important, and someone[1] is even making it work on the GameCube and its 24 MiB of RAM where it becomes critical.

Quoted 4 lines

Best,
Gary

[1] https://github.com/Wii-Linux/wii-linux-ngx/pull/13#issuecomment-4233447365

Signature · 1 line
Link Mauve
#20 lore raw

Re: [PATCH V11 1/4] rust: Fix "multiple candidates for rmeta dependency core" error

Quoted 22 lines · Link Mauve
Quoted 10 lines · Gary Guo
Quoted 8 lines · Link Mauve

This works fine for the core crate, but now panic_qr also gets the same issue, here it is with V=1:

```
+ powerpc-linux-musl-ld -EB -m elf32ppc -z noexecstack --no-warn-rwx-segments -Bstatic --build-id=sha1 --orphan-handling=warn --script=./arch/powerpc/kernel/vmlinux.lds --strip-debug -o .tmp_vmlinux1 --whole-archive vmlinux.a .vmlinux.export.o init/version-timestamp.o --no-whole-archive --start-group --end-group .tmp_vmlinux0.kallsyms.o
powerpc-linux-musl-ld: drivers/gpu/drm/drm_panic_qr.o: in function `<drm_panic_qr::SegmentIterator as core::iter::traits::iterator::Iterator>::next':
drm_panic_qr.f39a15fa3c72e9fe-cgu.0:(.text+0x200c): undefined reference to `__udivdi3'
```
Quoted 8 lines
Quoted 4 lines

From a cursory look at the SegmentIterator::next() function I don’t understand where the division could come up, but it’s actually nice to get an error when operations which shouldn’t happen happen anyway, it makes it more likely to get them fixed.

There is divide / modular by 10 code. Although, this shouldn't really cause __udivdi3 to be generated for constant divisor, unless -C opt-level=s is used. Do you happen to use that opt-level?

Indeed that was it!

Quoted 7 lines

With CONFIG_CC_OPTIMIZE_FOR_SIZE=y the kernel is 4 MiB large, and with CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE=y it is 4.9 MiB large, but CONFIG_DRM_PANIC_SCREEN_QR_CODE=y works.

As I target the Wii which has only 88 MiB of RAM, a difference of 920 KiB is actually quite important, and someone[1] is even making it work on the GameCube and its 24 MiB of RAM where it becomes critical.

At runtime it’s even worse, the dtbImage.wii is only 920 KiB bigger, but the kernel code in memory goes from 5660 KiB to 7856 KiB, or 2.2 MiB bigger.

Quoted 10 lines
Quoted 5 lines

Best,
Gary

[1] https://github.com/Wii-Linux/wii-linux-ngx/pull/13#issuecomment-4233447365

Signature · 1 line
Link Mauve
Signature · 1 line
Link Mauve
#21 lore raw

PATCH v11 2/4 powerpc/jump_label: adjust inline asm to be consistent

In reply to 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")'

---
 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..3016e9c8d6bc 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.53.0
#22 lore raw

PATCH v11 3/4 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.

---
 arch/powerpc/Kconfig  | 1 +
 arch/powerpc/Makefile | 2 ++
 rust/Makefile         | 4 +++-
 3 files changed, 6 insertions(+), 1 deletion(-)
arch/powerpc/Kconfig +1 -0
index 10240cb80904..1246b3add8ff 100644
@@ -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
arch/powerpc/Makefile +2 -0
index a58b1029592c..589613eaa5dc 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 e234b8a39358..af0c8ab2e5b6 100644
@@ -406,13 +406,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.53.0
reviewer Acked-by on v11 3/4
#23 lore raw

Re: [PATCH V11 3/4] rust: Add PowerPC support

Quoted 13 lines · 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.

Quoted 4 lines
Quoted 5 lines
---
 arch/powerpc/Kconfig  | 1 +
 arch/powerpc/Makefile | 2 ++
 rust/Makefile         | 4 +++-
 3 files changed, 6 insertions(+), 1 deletion(-)
#24 lore raw

PATCH v11 4/4 powerpc: Enable Rust for ppc64le

In reply to Mukesh Kumar Chaurasiya (IBM)

Enabling rust support for ppc64le.

Tested on pseries Power11:

╰─❯ dmesg | grep rust
[    0.225728] Initialise system trusted keyrings
[    0.270961] rust_minimal: Rust minimal sample (init)
[    0.270968] rust_minimal: Am I built-in? true
[    0.270974] rust_minimal: test_parameter: 1
[    0.270983] rust_misc_device: Initialising Rust Misc Device Sample
[    0.271012] rust_print: Rust printing macros sample (init)
[    0.271019] rust_print: Emergency message (level 0) without args
[    0.271023] rust_print: Alert message (level 1) without args
[    0.271026] rust_print: Critical message (level 2) without args
[    0.271030] rust_print: Error message (level 3) without args
[    0.271033] rust_print: Warning message (level 4) without args
[    0.271037] rust_print: Notice message (level 5) without args
[    0.271040] rust_print: Info message (level 6) without args
[    0.271043] rust_print: A line that is continued without args
[    0.271054] rust_print: Emergency message (level 0) with args
[    0.271064] rust_print: Alert message (level 1) with args
[    0.271072] rust_print: Critical message (level 2) with args
[    0.271077] rust_print: Error message (level 3) with args
[    0.271083] rust_print: Warning message (level 4) with args
[    0.271091] rust_print: Notice message (level 5) with args
[    0.271097] rust_print: Info message (level 6) with args
[    0.271102] rust_print: A line that is continued with args
[    0.271110] rust_print: 1
[    0.271113] rust_print: "hello, world"
[    0.271121] rust_print: [samples/rust/rust_print_main.rs:35:5] c = "hello, world"
[    0.271129] rust_print: Arc<dyn Display> says 42
[    0.271130] rust_print: Arc<dyn Display> says hello, world
[    0.271136] rust_print: "hello, world"
[    0.271198] usbcore: registered new interface driver rust_driver_usb
[    0.271207] rust_faux_driver: Initialising Rust Faux Device Sample
[    0.271227] faux_driver rust-faux-sample-device: Hello from faux device!
[    0.271297] rust_configfs: Rust configfs sample (init)
---
 arch/powerpc/Kconfig  | 1 +
 arch/powerpc/Makefile | 7 ++++++-
 rust/Makefile         | 6 ++++++
 3 files changed, 13 insertions(+), 1 deletion(-)
arch/powerpc/Kconfig +1 -0
index 1246b3add8ff..a5f50434daf3 100644
@@ -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
arch/powerpc/Makefile +6 -1
index 589613eaa5dc..9385db478c59 100644
@@ -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
rust/Makefile +6 -0
index af0c8ab2e5b6..99537c2c55ee 100644
@@ -414,7 +414,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))
 
Signature · 1 line
2.53.0
reviewer Acked-by on v11 4/4
#25 lore raw

Re: [PATCH V11 4/4] powerpc: Enable Rust for ppc64le

Quoted 37 lines · Mukesh Kumar Chaurasiya (IBM)

Enabling rust support for ppc64le.

Tested on pseries Power11:

╰─❯ dmesg | grep rust
[    0.225728] Initialise system trusted keyrings
[    0.270961] rust_minimal: Rust minimal sample (init)
[    0.270968] rust_minimal: Am I built-in? true
[    0.270974] rust_minimal: test_parameter: 1
[    0.270983] rust_misc_device: Initialising Rust Misc Device Sample
[    0.271012] rust_print: Rust printing macros sample (init)
[    0.271019] rust_print: Emergency message (level 0) without args
[    0.271023] rust_print: Alert message (level 1) without args
[    0.271026] rust_print: Critical message (level 2) without args
[    0.271030] rust_print: Error message (level 3) without args
[    0.271033] rust_print: Warning message (level 4) without args
[    0.271037] rust_print: Notice message (level 5) without args
[    0.271040] rust_print: Info message (level 6) without args
[    0.271043] rust_print: A line that is continued without args
[    0.271054] rust_print: Emergency message (level 0) with args
[    0.271064] rust_print: Alert message (level 1) with args
[    0.271072] rust_print: Critical message (level 2) with args
[    0.271077] rust_print: Error message (level 3) with args
[    0.271083] rust_print: Warning message (level 4) with args
[    0.271091] rust_print: Notice message (level 5) with args
[    0.271097] rust_print: Info message (level 6) with args
[    0.271102] rust_print: A line that is continued with args
[    0.271110] rust_print: 1
[    0.271113] rust_print: "hello, world"
[    0.271121] rust_print: [samples/rust/rust_print_main.rs:35:5] c = "hello, world"
[    0.271129] rust_print: Arc<dyn Display> says 42
[    0.271130] rust_print: Arc<dyn Display> says hello, world
[    0.271136] rust_print: "hello, world"
[    0.271198] usbcore: registered new interface driver rust_driver_usb
[    0.271207] rust_faux_driver: Initialising Rust Faux Device Sample
[    0.271227] faux_driver rust-faux-sample-device: Hello from faux device!
[    0.271297] rust_configfs: Rust configfs sample (init)
Quoted 7 lines
Quoted 5 lines
---
 arch/powerpc/Kconfig  | 1 +
 arch/powerpc/Makefile | 7 ++++++-
 rust/Makefile         | 6 ++++++
 3 files changed, 13 insertions(+), 1 deletion(-)