[PATCH 1/3] arm64: rust: Enable Rust support for AArch64

Björn Roy Baron bjorn3_gh at protonmail.com
Tue Jan 31 08:49:47 PST 2023


On Tuesday, January 31st, 2023 at 17:19, Will Deacon <will at kernel.org> wrote:

> On Thu, Jan 26, 2023 at 06:56:01PM +0100, Miguel Ojeda wrote:
> 
> > On Thu, Jan 26, 2023 at 5:35 PM Will Deacon will at kernel.org wrote:
> > 
> > > Why do we need to specify this stuff here? LLVM already knows about AArch64
> > > and can compute the data-layout string in computeDataLayout(). Can we have
> > > the tools figure this out for us instead, please?
> > 
> > I agree -- the reason we have this for the moment is to provide full
> > control of the target spec, in particular for cases where `rustc` may
> > not provide enough flags to customize exiting builtin target specs
> > and/or may emit warnings for unknown target features etc.
> > 
> > If it is already enough for arm64 to use e.g. the
> > `aarch64-unknown-none` target spec plus flags on top, then we should
> > go for that, because that is the end goal: these target spec files are
> > unstable in the Rust compiler (and not intended to become stable).
> 
> 
> Please confirm that this is the case, but I really think we should be
> aiming for that rather than starting off my specifying this stuff manually.
> 
> > For context, upstream Rust so far has been willing to merge support
> > for flags and target features that we needed, which is great.
> 
> 
> One thing I ran into while playing around is that 128-bit types aren't
> supported with ffi unless '-A improper-ctypes' is passed. Given that we
> use '__uint128_t' to represent the fpsimd state, I think this is probably
> something which will crop up as an issue.

This lint exists because u/i128 are indeed not compatible with their C counterpart on many targets including x86_64 with the SysV ABI. As it turns out however, it is compatible on AArch64. A little under a year ago 128bit int type aliases were added to the libc crate on AArch64 (except on Windows) which are equal to u/i128 [1]. In addition it has const assertions for the correct size and alignment. As such if rustc every regresses on non-Windows AArch64, this will show up in a crater run and almost definitively be fixed. Because of this I don't think there will be any problem with assuming __uint128_t and u128 are compatible when compiling for AArch64.

> 
> Will

Cheers,
Bjorn

[1]: https://github.com/rust-lang/libc/pull/2719/files



More information about the linux-arm-kernel mailing list