From: Christian Schrefl <chrisi.schrefl@gmail.com>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: "Miguel Ojeda" <ojeda@kernel.org>,
"Alex Gaynor" <alex.gaynor@gmail.com>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <benno.lossin@proton.me>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Jonathan Corbet" <corbet@lwn.net>,
"Russell King" <linux@armlinux.org.uk>,
"Rudraksha Gupta" <guptarud@gmail.com>,
"Ard Biesheuvel" <ardb@kernel.org>,
"Geert Stappers" <stappers@stappers.nl>,
"Andrew Lunn" <andrew@lunn.ch>,
"Jamie Cunliffe" <Jamie.Cunliffe@arm.com>,
"Sven Van Asbroeck" <thesven73@gmail.com>,
rust-for-linux@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v3] arm: rust: Enable Rust support for ARMv7
Date: Sun, 13 Apr 2025 23:10:41 +0200 [thread overview]
Message-ID: <b13d37bd-ec68-4713-94e5-e9ed4d6a6354@gmail.com> (raw)
In-Reply-To: <CACRpkdYF0sVB2-qgy=GzETSR3+2sagVQPGdunDQDJrn8KqJorA@mail.gmail.com>
On 21.03.25 8:24 AM, Linus Walleij wrote:
> Hi Christian,
>
> thanks for your patch!
>
> Sorry for being late to the show. I missed this very nice patch
> that was actually on my personal TODO but I have to much
> to do and also I'm not smart with Rust, but I'm a big supporter.
>
> On Thu, Jan 23, 2025 at 11:40 PM Christian Schrefl
> <chrisi.schrefl@gmail.com> wrote:
>
>> + select HAVE_RUST if CPU_LITTLE_ENDIAN && CPU_32v7
>
> Nothing in the patch series really explains this restriction, so it
> should be in the commit message. Arnd mentions some atomics
> etc, but we really need to know exactly why this is in the patch.
>
> I'm a bit surprised by this since the rustc LLVM backend nowadays
> support all old ARM ISAs. I would have expected:
>
> select HAVE_RUST if AEABI
>
> Ideally this should work on any ARM core, but it's fair to require
> EABI.
>
> The big reason: I think we want to be able to use Rust in kernel
> core components sooner than ARMv5 goes away from the kernel.
>
> If testing is the only issue, I can provide testing on ARMv4, v5,
> ARMv5 BE etc, just tell me how to test. (But I guess it's more than
> that...)
I've done a quick test on armv5 with the `armv5te-none-eabi` rust
target and it needs some atomics (`AtomicU64` type and for
`AtomicBool` the `compare_exchange` and `compare_exchange`
functions) to build:
```
RUSTC L rust/kernel.o
error[E0432]: unresolved import `core::sync::atomic::AtomicU64`
--> rust/kernel/block/mq/operations.rs:15:33
|
15 | use core::{marker::PhantomData, sync::atomic::AtomicU64, sync::atomic::Ordering};
| ^^^^^^^^^^^^^^---------
| | |
| | help: a similar name exists in the module: `AtomicU8`
| no `AtomicU64` in `sync::atomic`
error[E0432]: unresolved import `core::sync::atomic::AtomicU64`
--> rust/kernel/block/mq/request.rs:16:20
|
16 | sync::atomic::{AtomicU64, Ordering},
| ^^^^^^^^^
| |
| no `AtomicU64` in `sync::atomic`
| help: a similar name exists in the module: `AtomicU8`
error[E0599]: no method named `compare_exchange` found for struct `AtomicBool` in the current scope
--> rust/kernel/list/arc.rs:518:14
|
517 | / self.inner
518 | | .compare_exchange(false, true, Ordering::Acquire, Ordering::Relaxed)
| | -^^^^^^^^^^^^^^^^ method not found in `AtomicBool`
| |_____________|
|
error[E0599]: no method named `swap` found for struct `AtomicBool` in the current scope
--> rust/kernel/revocable.rs:130:30
|
130 | if self.is_available.swap(false, Ordering::Relaxed) {
| ^^^^ method not found in `AtomicBool`
error: aborting due to 4 previous errors
Some errors have detailed explanations: E0432, E0599.
For more information about an error, try `rustc --explain E0432`.
```
When gating all the modules that need these linking fails because
of missing __eabi__* intrinsics:
```
ld.lld: error: undefined symbol: __aeabi_memcpy
>>> referenced by kernel.2bb770ae1dba3d33-cgu.0
>>> rust/kernel.o:(<kernel::str::RawFormatter as core::fmt::Write>::write_char) in archive vmlinux.a
>>> referenced by kernel.2bb770ae1dba3d33-cgu.0
>>> rust/kernel.o:(<kernel::str::Formatter as core::fmt::Write>::write_char) in archive vmlinux.a
>>> referenced by kernel.2bb770ae1dba3d33-cgu.0
>>> rust/kernel.o:(<kernel::page::Page>::read_raw) in archive vmlinux.a
>>> referenced 29 more times
ld.lld: error: undefined symbol: __aeabi_memclr8
>>> referenced by bindings.4cab29b7397d35cb-cgu.0
>>> rust/bindings.o:(<bindings::bindings_raw::module as core::default::Default>::default) in archive vmlinux.a
>>> referenced by uapi.fe46408b8870a0f6-cgu.0
>>> rust/uapi.o:(<uapi::module as core::default::Default>::default) in archive vmlinux.a
>>> referenced by uapi.fe46408b8870a0f6-cgu.0
>>> rust/uapi.o:(<uapi::thread_info as core::default::Default>::default) in archive vmlinux.a
>>> referenced 86 more times
ld.lld: error: undefined symbol: __aeabi_memclr4
>>> referenced by bindings.4cab29b7397d35cb-cgu.0
>>> rust/bindings.o:(<bindings::bindings_raw::fp_hard_struct as core::default::Default>::default) in archive vmlinux.a
>>> referenced by bindings.4cab29b7397d35cb-cgu.0
>>> rust/bindings.o:(<bindings::bindings_raw::iwmmxt_struct as core::default::Default>::default) in archive vmlinux.a
>>> referenced by uapi.fe46408b8870a0f6-cgu.0
>>> rust/uapi.o:(<uapi::fp_soft_struct as core::default::Default>::default) in archive vmlinux.a
>>> referenced 95 more times
ld.lld: error: undefined symbol: __aeabi_memset
>>> referenced by core.64aa0a46a0f8f964-cgu.0
>>> rust/core.o:(<core::num::fmt::Part>::write) in archive vmlinux.a
>>> referenced by core.64aa0a46a0f8f964-cgu.0
>>> rust/core.o:(core::fmt::num::fmt_u128) in archive vmlinux.a
ld.lld: error: undefined symbol: __aeabi_memcpy4
>>> referenced by kernel.2bb770ae1dba3d33-cgu.0
>>> rust/kernel.o:(<kernel::of::DeviceId>::new) in archive vmlinux.a
>>> referenced by core.64aa0a46a0f8f964-cgu.0
>>> rust/core.o:(<core::char::ToLowercase as core::fmt::Display>::fmt) in archive vmlinux.a
ld.lld: error: undefined symbol: __aeabi_memclr
>>> referenced by kernel.2bb770ae1dba3d33-cgu.0
>>> rust/kernel.o:(<kernel::page::Page>::fill_zero_raw) in archive vmlinux.a
>>> referenced by uapi.fe46408b8870a0f6-cgu.0
>>> rust/uapi.o:(<uapi::__kernel_sockaddr_storage__bindgen_ty_1__bindgen_ty_1 as core::default::Default>::default) in archive vmlinux.a
>>> referenced by uapi.fe46408b8870a0f6-cgu.0
>>> rust/uapi.o:(<uapi::sockaddr__bindgen_ty_1 as core::default::Default>::default) in archive vmlinux.a
>>> referenced 16 more times
ld.lld: error: undefined symbol: __aeabi_memset4
>>> referenced by core.64aa0a46a0f8f964-cgu.0
>>> rust/core.o:(core::fmt::num::fmt_u128) in archive vmlinux.a
make[2]: *** [scripts/Makefile.vmlinux:91: vmlinux] Error 1
make[1]: *** [/home/chrisi/Documents/code/rust-arm32/Makefile:1242: vmlinux] Error 2
make: *** [Makefile:248: __sub-make] Error 2
```
With define_panicking_intrinsics! for these an empty sample works
(not yet tested as module), but even printing a non formatted
string (with `pr_info!("Hi rust\n");`) fails because rust tries
to use __adddf3:
``
Hardware name: ARM-Versatile (Device Tree Support)
PC is at __rust__adddf3+0x0/0x4
LR is at _RNvXsg_NtCs3KHxpmQFgFb_6kernel3strNtB5_12RawFormatterNtNtCs8DPF7ip8WBQ_4core3fmt5Write9write_str+0x34/0x40
pc : [<c028950c>] lr : [<c028b5ec>] psr: 20000193
sp : c8811a78 ip : c8811ae8 fp : c058e44e
r10: 00000000 r9 : c058e450 r8 : c07ac118
r7 : 00000000 r6 : 00000000 r5 : c07ac120 r4 : c8811adc
r3 : c07ac120 r2 : 00000008 r1 : c0667f60 r0 : c07ac118
Flags: nzCv IRQs off FIQs on Mode SVC_32 ISA ARM Segment none
```
I'm not sure how to proceed from here and I most likely won't
find time to continue working on this anytime soon.
My very hacky changes are available on Github at:
https://github.com/onestacked/linux/commit/edddb388267ab1afe5255bea4d84f96cbdb37978
Cheers,
Christian
next prev parent reply other threads:[~2025-04-13 21:22 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-23 22:40 [PATCH v3] arm: rust: Enable Rust support for ARMv7 Christian Schrefl
2025-01-30 23:10 ` Christian Schrefl
2025-01-31 7:40 ` Arnd Bergmann
2025-01-31 15:34 ` Christian Schrefl
2025-01-31 16:05 ` Andrew Lunn
2025-01-31 18:58 ` Christian Schrefl
2025-01-31 19:37 ` Arnd Bergmann
2025-01-31 23:42 ` Christian Schrefl
2025-02-01 0:58 ` Christian Schrefl
2025-02-02 16:57 ` Christian Schrefl
2025-02-01 0:03 ` Christian Schrefl
2025-02-05 13:12 ` Miguel Ojeda
2025-02-05 13:14 ` Alice Ryhl
2025-04-06 14:59 ` Miguel Ojeda
2025-01-31 19:18 ` Arnd Bergmann
2025-03-21 7:24 ` Linus Walleij
2025-04-05 20:05 ` Christian Schrefl
2025-04-06 14:08 ` Manish Shakya
2025-04-06 14:57 ` Miguel Ojeda
2025-04-06 21:17 ` Benno Lossin
2025-04-06 21:31 ` Miguel Ojeda
2025-04-13 21:10 ` Christian Schrefl [this message]
2025-04-13 21:31 ` Christian Schrefl
2025-04-06 21:48 ` Manish Shakya
[not found] <D90J8JOGEBWI.4P0BAZG2R4G7@proton.me>
2025-04-07 17:35 ` Miguel Ojeda
2025-04-07 23:03 ` Manish Shakya
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b13d37bd-ec68-4713-94e5-e9ed4d6a6354@gmail.com \
--to=chrisi.schrefl@gmail.com \
--cc=Jamie.Cunliffe@arm.com \
--cc=a.hindborg@kernel.org \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=andrew@lunn.ch \
--cc=ardb@kernel.org \
--cc=benno.lossin@proton.me \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=corbet@lwn.net \
--cc=gary@garyguo.net \
--cc=guptarud@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=stappers@stappers.nl \
--cc=thesven73@gmail.com \
--cc=tmgross@umich.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).