[PATCH 0/4] Rust for Linux for ppc64le

From: Michael Ellerman
Date: Mon Mar 22 2021 - 23:27:38 EST


Hi all,

Here's a first attempt at getting the kernel Rust support building on powerpc.

It's powerpc64le only for now, as that's what I can easily test given the
distros I have installed. Though powerpc and powerpc64 are also Tier 2 platforms
so in theory should work. Supporting those would require something more
complicated than just pointing rustc at arch/$(ARCH)/rust/target.json.

This is based on 832575d934a2 from the Rust-for-Linux tree. Anything newer gives
me errors about symbol name lengths. I figured I'd send this anyway, as it seems
like those errors are probably not powerpc specific.

I'm not sure that all the values in target.json are correct, or required (or if
any are missing), but what I have there seems to work. Would be happy for
someone to scrutinise it though.

Example output:

# uname -r
5.12.0-rc3-47689-ge4e12dd7cb75
# uname -m
ppc64le
# modprobe rust_example
Rust Example (init)
Am I built-in? false
Parameters:
my_bool: true
my_i32: 42
my_str: default str val
my_usize: 42
my_array: [0, 1]
Value: 10
Value: 10
Large array has length: 514
modprobe (1589) used greatest stack depth: 6800 bytes left
# modprobe rust_example_2
[2] Rust Example (init)
[2] Am I built-in? false
[2] Parameters:
[2] my_bool: true
[2] my_i32: 42
[2] my_str: default str val
[2] my_usize: 42
[2] my_array: [0, 1]
Large array has length: 1028
modprobe (1593) used greatest stack depth: 3680 bytes left
# modprobe rust_example_3
[3] Rust Example (init)
[3] Am I built-in? false
[3] Parameters:
[3] my_bool: true
[3] my_i32: 42
[3] my_str: default str val
[3] my_usize: 42
[3] my_array: [0, 1]
Large array has length: 1028
# modprobe rust_example_4
[4] Rust Example (init)
[4] Am I built-in? false
[4] Parameters:
[4] my_bool: true
[4] my_i32: 42
[4] my_str: default str val
[4] my_usize: 42
[4] my_array: [0, 1]
Large array has length: 1028

cheers


Michael Ellerman (4):
rust: Export symbols in initialized data section
rust: Add powerpc64 as a 64-bit target_arch in c_types.rs
powerpc/rust: Add target.json for ppc64le
rust: Enable for ppc64le

arch/powerpc/rust/target.json | 30 ++++++++++++++++++++++++++++++
init/Kconfig | 2 +-
rust/Makefile | 2 +-
rust/kernel/c_types.rs | 2 +-
4 files changed, 33 insertions(+), 3 deletions(-)
create mode 100644 arch/powerpc/rust/target.json


base-commit: 832575d934a2bc5e2fd0aa881d8e6b64bf062fd2
--
2.25.1