Skip to content

Rust for ppc64le#154

Merged
ojeda merged 5 commits intoRust-for-Linux:rustfrom
mpe:rust
Mar 31, 2021
Merged

Rust for ppc64le#154
ojeda merged 5 commits intoRust-for-Linux:rustfrom
mpe:rust

Conversation

@mpe
Copy link
Copy Markdown

@mpe mpe commented Mar 31, 2021

Here's a pull request with the ppc64le support. Now with CI wired up too.

mpe added 5 commits March 31, 2021 16:57
On powerpc some symbols end up in the initialized data section, which
means they aren't detected by the logic in cmd_export, leading to errors
such as:

  ERROR: modpost: "_RNvNtCsbDqzXfLQacH_6kernel12module_param15PARAM_OPS_USIZE" [drivers/char/rust_example_4.ko] undefined!

nm represents the "initialized data section" with "D", so also look for
that when exporting symbols.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
powerpc kernel code uses int-ll64.h.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Based on the x86 and arm64 versions, as well as output from:

  $ rustc +nightly -Z unstable-options --target=powerpc64le-unknown-linux-gnu --print target-spec-json

Notably disables altivec, vsx and hard-float.

The very cryptic data-layout:

  "data-layout": "e-m:e-i64:64-n32:64-S128",

Has the following meaning:

  e:     little endian
  m:e    ELF name mangling
  i64:64 64-bit integers 64-bit aligned
  n32:64 Native integer widths, 32-bit and 64-bit.
  S128   16-byte stack alignment

Those all come from the rustc output, with the exception of the stack
alignment. We obviously do have 8-bit & 16-bit integer types, but I'm
not sure if there's any need to specify that.

ppc64le only for now. We'll eventually need to come up with some way to
change the target.json that's used based on more than just $(ARCH).

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
All the pieces are in place now for us to enable building rust support
on ppc64le.

Only works with clang for now.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
For now only using clang.

Adds -vga none to the qemu command for all targets. But AFAICS that's
safe as both x86 and arm use serial consoles already.

Uses RUST_OPT_LEVEL_SIMILAR_AS_CHOSEN_FOR_C, not RUST_OPT_LEVEL_0 like
other configs. In order to avoid crashes like:

  Rust Example (init)
  Am I built-in? true
  Parameters:
    my_bool:    true
    my_i32:     123321
    my_str:     🦀mod
    my_usize:   42
    my_array:   [0, 1]
  Value: 10
  Value: 10
  Large array has length: 514
  Kernel panic - not syncing: corrupted stack end detected inside scheduler
  CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.12.0-rc3+ #1

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
@ojeda
Copy link
Copy Markdown
Member

ojeda commented Mar 31, 2021

Oh, I was working on this in parallel on top of your patches. Let me try to compare...

@ojeda
Copy link
Copy Markdown
Member

ojeda commented Mar 31, 2021

Uses RUST_OPT_LEVEL_SIMILAR_AS_CHOSEN_FOR_C, not RUST_OPT_LEVEL_0 like

I quickly tested, and level 1 also fails.

@ojeda
Copy link
Copy Markdown
Member

ojeda commented Mar 31, 2021

Since you took the time to send the PR with added CI, let's merge it and I can send my bits on top! :-)

@ojeda ojeda merged commit 5b225b7 into Rust-for-Linux:rust Mar 31, 2021
@mpe
Copy link
Copy Markdown
Author

mpe commented Apr 1, 2021

Oh, I was working on this in parallel on top of your patches. Let me try to compare...

Oops sorry, I figured you were busy with other things. Thanks for merging it 👍

@ojeda
Copy link
Copy Markdown
Member

ojeda commented Apr 1, 2021

No, thanks to you for the work! :-)

In case GitHub does not notify you on mentions: my bits are in #156, can you please take a look? Thanks in advance!

@ojeda ojeda mentioned this pull request Mar 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants