Skip to content

Commit 217e0d3

Browse files
mkchaurasmaddy-kerneldev
authored andcommitted
powerpc: Enable Rust for ppc64le
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> Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com> Link: https://patch.msgid.link/20260210090023.2587534-4-mkchauras@gmail.com
1 parent b964fb2 commit 217e0d3

4 files changed

Lines changed: 14 additions & 2 deletions

File tree

Documentation/rust/arch-support.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Architecture Level of support Constraints
1818
``arm`` Maintained ARMv7 Little Endian only.
1919
``arm64`` Maintained Little Endian only.
2020
``loongarch`` Maintained \-
21-
``powerpc`` Maintained 32-bit Big Endian only.
21+
``powerpc`` Maintained 64-bit Little Endian. 32-bit Big Endian.
2222
``riscv`` Maintained ``riscv64`` and LLVM/Clang only.
2323
``um`` Maintained \-
2424
``x86`` Maintained ``x86_64`` only.

arch/powerpc/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ config PPC
285285
select HAVE_RELIABLE_STACKTRACE
286286
select HAVE_RSEQ
287287
select HAVE_RUST if PPC32
288+
select HAVE_RUST if PPC64 && CPU_LITTLE_ENDIAN
288289
select HAVE_SAMPLE_FTRACE_DIRECT if HAVE_DYNAMIC_FTRACE_WITH_DIRECT_CALLS
289290
select HAVE_SAMPLE_FTRACE_DIRECT_MULTI if HAVE_DYNAMIC_FTRACE_WITH_DIRECT_CALLS
290291
select HAVE_SETUP_PER_CPU_AREA if PPC64

arch/powerpc/Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,12 @@ else
6161
KBUILD_LDFLAGS_MODULE += $(objtree)/arch/powerpc/lib/crtsavres.o
6262
endif
6363

64-
KBUILD_RUSTFLAGS += --target=powerpc-unknown-linux-gnu
64+
ifdef CONFIG_PPC64
65+
KBUILD_RUSTFLAGS += --target=powerpc64le-unknown-linux-gnu
66+
KBUILD_RUSTFLAGS += -Ctarget-feature=-mma,-vsx,-hard-float,-altivec
67+
else
68+
KBUILD_RUSTFLAGS += --target=powerpc-unknown-linux-gnu
69+
endif
6570

6671
ifdef CONFIG_CPU_LITTLE_ENDIAN
6772
KBUILD_CPPFLAGS += -mlittle-endian

rust/Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,13 @@ BINDGEN_TARGET_x86 := x86_64-linux-gnu
410410
BINDGEN_TARGET_arm64 := aarch64-linux-gnu
411411
BINDGEN_TARGET_arm := arm-linux-gnueabi
412412
BINDGEN_TARGET_loongarch := loongarch64-linux-gnusf
413+
414+
ifdef CONFIG_PPC64
415+
BINDGEN_TARGET_powerpc := powerpc64le-linux-gnu
416+
else
413417
BINDGEN_TARGET_powerpc := powerpc-linux-gnu
418+
endif
419+
414420
BINDGEN_TARGET_um := $(BINDGEN_TARGET_$(SUBARCH))
415421
BINDGEN_TARGET := $(BINDGEN_TARGET_$(SRCARCH))
416422

0 commit comments

Comments
 (0)