Re: [PATCH v6 6/6] s390: Enable Rust support

From: Jan Polensky

Date: Mon Jun 08 2026 - 15:49:26 EST


On Mon, Jun 08, 2026 at 07:25:06PM +0100, Gary Guo wrote:
> On Mon Jun 8, 2026 at 7:14 PM BST, Jan Polensky wrote:
> > Enable building Rust code on s390 by wiring the architecture into the
> > kernel Rust infrastructure.
> >
> > Add s390 to the Rust arch support documentation, provide the s390 Rust
> > target and required compiler flags, and set the bindgen target for
> > arch/s390. Adjust the Rust target generation and minimum rustc version
> > gating so the s390 setup is handled explicitly.
> >
> > The Rust toolchain uses the "s390x" triple naming for the 64 bit target.
> >
> > Rust support is currently incompatible with CONFIG_EXPOLINE, which
> > relies on compiler support for the -mindirect-branch= and
> > -mfunction_return= options. Therefore, select HAVE_RUST only when
> > EXPOLINE is disabled.
>
> Does `-Zretpoline-external-thunk`/`-Zretpoline` not work for s390? Rust will
> throw a warning saying that it doesn't recognize this for the target, but it
> looks like it does generate target features
> +retpoline-external-thunk,+retpoline-indirect-branches,+retpoline-indirect-calls
> in LLVM IR.
>
> Best,
> Gary
>

Hi Gary,

thanks. The warning by itself does not prove the flags are ignored,
since rustc may still forward unknown target features to the backend.

That said, s390 currently has no Rust/LLVM support for the EXPOLINE
compiler support we rely on in C, and the kernel-side Rust retpoline
handling is only wired up for x86/x86_64 today.

Backend support is planned, but has not been implemented yet. Until then,
keeping Rust support gated behind !CONFIG_EXPOLINE is the intentional and
conservative choice for this series.

Best,
Jan