rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/13] Support several Rust toolchain versions
@ 2024-07-01 18:36 Miguel Ojeda
  2024-07-02  6:25 ` Benno Lossin
  0 siblings, 1 reply; 6+ messages in thread
From: Miguel Ojeda @ 2024-07-01 18:36 UTC (permalink / raw)
  To: Miguel Ojeda, Wedson Almeida Filho, Alex Gaynor
  Cc: Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Alice Ryhl, rust-for-linux, linux-kernel,
	patches

Hi all,

It is time to start supporting several Rust toolchain versions and thus
establish a minimum Rust compiler and `bindgen` version.

For the Rust compiler, we will start with a window of two stable
releases, and widen it over time. This series keeps the minimum where
it is (1.78.0), but adds support for the recently released 1.79.0.

This should already be enough for kernel developers in distributions that
provide recent Rust compiler versions routinely, such as Arch Linux,
Debian Unstable (outside the freeze period), Fedora Linux, Gentoo
Linux (especially the testing channel), Nix (unstable) and openSUSE
Tumbleweed. A documentation adds the instructions for each of them.

In addition, Rust for Linux is now being built-tested in Rust's
pre-merge CI. That is, every change that is attempting to land into the
Rust compiler is tested against the kernel, and it is merged only if it
passes -- thanks to the Rust project for that!

Thus, with the pre-merge CI in place, both projects hope to avoid
unintentional changes to Rust that break the kernel. This means that,
in general, apart from intentional changes on their side (that we will
need to workaround conditionally on our side), the upcoming Rust compiler
versions should generally work.

For instance, currently, the beta (1.80.0) and nightly (1.81.0) branches
work as well.

Similarly, we kept the minimum as it is for `bindgen`. `bindgen` is also
adding the kernel to its CI -- thanks!

Cheers,
Miguel


Miguel Ojeda (13):
  rust: macros: indent list item in `paste!`'s docs
  rust: init: simplify from `map_err` to `inspect_err`
  rust: allow `dead_code` for never constructed bindings
  rust: relax most deny-level lints to warnings
  rust: simplify Clippy warning flags set
  rust: start supporting several compiler versions
  rust: warn about `bindgen` versions 0.66.0 and 0.66.1
  rust: work around `bindgen` 0.69.0 issue
  rust: avoid assuming a particular `bindgen` build
  rust: start supporting several `bindgen` versions
  kbuild: rust: add `rustc-version` support
  rust: support the new `-Zub-checks` flag
  docs: rust: quick-start: add section on Linux distributions

 Documentation/process/changes.rst  |   9 +--
 Documentation/rust/quick-start.rst | 118 +++++++++++++++++++++++------
 Makefile                           |  29 +++----
 init/Kconfig                       |  11 ++-
 lib/Kconfig.debug                  |  18 +++++
 rust/Makefile                      |   4 +-
 rust/bindings/lib.rs               |   1 +
 rust/kernel/init.rs                |  12 +--
 rust/macros/lib.rs                 |   2 +-
 rust/uapi/lib.rs                   |   1 +
 scripts/Kconfig.include            |   6 ++
 scripts/Makefile.compiler          |   4 +
 scripts/rust_is_available.sh       |  20 ++---
 scripts/rust_is_available_test.py  |  40 +++++-----
 scripts/rustc-version.sh           |  52 +++++++++++++
 15 files changed, 238 insertions(+), 89 deletions(-)
 create mode 100755 scripts/rustc-version.sh


base-commit: f2661062f16b2de5d7b6a5c42a9a5c96326b8454
-- 
2.45.2


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 00/13] Support several Rust toolchain versions
  2024-07-01 18:36 Miguel Ojeda
@ 2024-07-02  6:25 ` Benno Lossin
  2024-07-02  9:41   ` Miguel Ojeda
  0 siblings, 1 reply; 6+ messages in thread
From: Benno Lossin @ 2024-07-02  6:25 UTC (permalink / raw)
  To: Miguel Ojeda, Wedson Almeida Filho, Alex Gaynor
  Cc: Boqun Feng, Gary Guo, Björn Roy Baron, Andreas Hindborg,
	Alice Ryhl, rust-for-linux, linux-kernel, patches

On 01.07.24 20:36, Miguel Ojeda wrote:
> Hi all,
> 
> It is time to start supporting several Rust toolchain versions and thus
> establish a minimum Rust compiler and `bindgen` version.
> 
> For the Rust compiler, we will start with a window of two stable
> releases, and widen it over time. This series keeps the minimum where
> it is (1.78.0), but adds support for the recently released 1.79.0.
> 
> This should already be enough for kernel developers in distributions that
> provide recent Rust compiler versions routinely, such as Arch Linux,
> Debian Unstable (outside the freeze period), Fedora Linux, Gentoo
> Linux (especially the testing channel), Nix (unstable) and openSUSE
> Tumbleweed. A documentation adds the instructions for each of them.
> 
> In addition, Rust for Linux is now being built-tested in Rust's
> pre-merge CI. That is, every change that is attempting to land into the
> Rust compiler is tested against the kernel, and it is merged only if it
> passes -- thanks to the Rust project for that!
> 
> Thus, with the pre-merge CI in place, both projects hope to avoid
> unintentional changes to Rust that break the kernel. This means that,
> in general, apart from intentional changes on their side (that we will
> need to workaround conditionally on our side), the upcoming Rust compiler
> versions should generally work.
> 
> For instance, currently, the beta (1.80.0) and nightly (1.81.0) branches
> work as well.
> 
> Similarly, we kept the minimum as it is for `bindgen`. `bindgen` is also
> adding the kernel to its CI -- thanks!
> 
> Cheers,
> Miguel
> 
> 
> Miguel Ojeda (13):
>   rust: macros: indent list item in `paste!`'s docs
>   rust: init: simplify from `map_err` to `inspect_err`
>   rust: allow `dead_code` for never constructed bindings
>   rust: relax most deny-level lints to warnings
>   rust: simplify Clippy warning flags set
>   rust: start supporting several compiler versions
>   rust: warn about `bindgen` versions 0.66.0 and 0.66.1
>   rust: work around `bindgen` 0.69.0 issue
>   rust: avoid assuming a particular `bindgen` build
>   rust: start supporting several `bindgen` versions
>   kbuild: rust: add `rustc-version` support
>   rust: support the new `-Zub-checks` flag
>   docs: rust: quick-start: add section on Linux distributions
> 
>  Documentation/process/changes.rst  |   9 +--
>  Documentation/rust/quick-start.rst | 118 +++++++++++++++++++++++------
>  Makefile                           |  29 +++----
>  init/Kconfig                       |  11 ++-
>  lib/Kconfig.debug                  |  18 +++++
>  rust/Makefile                      |   4 +-
>  rust/bindings/lib.rs               |   1 +
>  rust/kernel/init.rs                |  12 +--
>  rust/macros/lib.rs                 |   2 +-
>  rust/uapi/lib.rs                   |   1 +
>  scripts/Kconfig.include            |   6 ++
>  scripts/Makefile.compiler          |   4 +
>  scripts/rust_is_available.sh       |  20 ++---
>  scripts/rust_is_available_test.py  |  40 +++++-----
>  scripts/rustc-version.sh           |  52 +++++++++++++
>  15 files changed, 238 insertions(+), 89 deletions(-)
>  create mode 100755 scripts/rustc-version.sh
> 
> 
> base-commit: f2661062f16b2de5d7b6a5c42a9a5c96326b8454
> --
> 2.45.2

I applied the series and successfully ran the kunit tests on nixos.
I tried the following rust versions via fenix:
- rustc 1.78.0 (9b00956e5 2024-04-29)
- rustc 1.79.0 (129f3b996 2024-06-10)
- 1.80.0-beta.4 (64a1fe671 2024-06-21)
- 1.81.0-nightly (6868c831a 2024-06-30)

My bindgen version is 0.69.4.

Everything worked as expected :)

Tested-by: Benno Lossin <benno.lossin@proton.me>

---
Cheers,
Benno


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 00/13] Support several Rust toolchain versions
  2024-07-02  6:25 ` Benno Lossin
@ 2024-07-02  9:41   ` Miguel Ojeda
  0 siblings, 0 replies; 6+ messages in thread
From: Miguel Ojeda @ 2024-07-02  9:41 UTC (permalink / raw)
  To: Benno Lossin
  Cc: Miguel Ojeda, Wedson Almeida Filho, Alex Gaynor, Boqun Feng,
	Gary Guo, Björn Roy Baron, Andreas Hindborg, Alice Ryhl,
	rust-for-linux, linux-kernel, patches

On Tue, Jul 2, 2024 at 8:25 AM Benno Lossin <benno.lossin@proton.me> wrote:
>
> I applied the series and successfully ran the kunit tests on nixos.
> I tried the following rust versions via fenix:
> - rustc 1.78.0 (9b00956e5 2024-04-29)
> - rustc 1.79.0 (129f3b996 2024-06-10)
> - 1.80.0-beta.4 (64a1fe671 2024-06-21)
> - 1.81.0-nightly (6868c831a 2024-06-30)
>
> My bindgen version is 0.69.4.
>
> Everything worked as expected :)

Thanks Benno! I tried nixpkgs' toolchain for the examples in the docs
patch, but not fenix's ones, so it's good to know those work as well. :)

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 00/13] Support several Rust toolchain versions
@ 2024-07-03 17:35 Andreas Hindborg
  2024-07-03 17:40 ` Miguel Ojeda
  0 siblings, 1 reply; 6+ messages in thread
From: Andreas Hindborg @ 2024-07-03 17:35 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Wedson Almeida Filho, Alex Gaynor, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	rust-for-linux, linux-kernel, patches


Hi Miguel,

Miguel Ojeda <ojeda@kernel.org> writes:

> Hi all,
>
> It is time to start supporting several Rust toolchain versions and thus
> establish a minimum Rust compiler and `bindgen` version.
>
> For the Rust compiler, we will start with a window of two stable
> releases, and widen it over time. This series keeps the minimum where
> it is (1.78.0), but adds support for the recently released 1.79.0.
>
> This should already be enough for kernel developers in distributions that
> provide recent Rust compiler versions routinely, such as Arch Linux,
> Debian Unstable (outside the freeze period), Fedora Linux, Gentoo
> Linux (especially the testing channel), Nix (unstable) and openSUSE
> Tumbleweed. A documentation adds the instructions for each of them.
>
> In addition, Rust for Linux is now being built-tested in Rust's
> pre-merge CI. That is, every change that is attempting to land into the
> Rust compiler is tested against the kernel, and it is merged only if it
> passes -- thanks to the Rust project for that!
>
> Thus, with the pre-merge CI in place, both projects hope to avoid
> unintentional changes to Rust that break the kernel. This means that,
> in general, apart from intentional changes on their side (that we will
> need to workaround conditionally on our side), the upcoming Rust compiler
> versions should generally work.
>
> For instance, currently, the beta (1.80.0) and nightly (1.81.0) branches
> work as well.
>
> Similarly, we kept the minimum as it is for `bindgen`. `bindgen` is also
> adding the kernel to its CI -- thanks!
>
> Cheers,
> Miguel
>

Applied the series to [1], based on v6.9:

rustup override set --path ../rnull-v6.9-build 1.76.0
make O=../rnull-v6.9-build LLVM=1

Builds fine.

rustup override set --path ../rnull-v6.9-build 1.79.0
make O=../rnull-v6.9-build LLVM=1

make[1]: Entering directory '/home/aeh/src/linux-rust/rnull-v6.9-build'
  GEN     Makefile
mkdir -p /home/aeh/src/linux-rust/rnull-v6.9-build/tools/objtool && make O=/home/aeh/src/linux-rust/rnull-v6.9-build subdir=tools/objtool --no-print-directory -C objtool
  CALL    /home/aeh/src/linux-rust/rnull-v6.9/scripts/checksyscalls.sh
  INSTALL libsubcmd_headers
  RUSTC L rust/core.o
error: data-layout for target `target-12379853866016577623`, `e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128`, differs from LLVM target's `x86_64-linux-gnu` default layout, `e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128`

error: aborting due to 1 previous error

make[3]: *** [/home/aeh/src/linux-rust/rnull-v6.9/rust/Makefile:461: rust/core.o] Error 1
make[2]: *** [/home/aeh/src/linux-rust/rnull-v6.9/Makefile:1206: prepare] Error 2
make[1]: *** [/home/aeh/src/linux-rust/rnull-v6.9/Makefile:240: __sub-make] Error 2
make[1]: Leaving directory '/home/aeh/src/linux-rust/rnull-v6.9-build'
make: *** [Makefile:240: __sub-make] Error 2
error: Recipe `lo` failed with exit code 2


rm ../rnull-v6.9-build/rust
make O=../rnull-v6.9-build LLVM=1

same result.

rm ../rnull-v6.9-build/rust
<configure>
make O=../rnull-v6.9-build LLVM=1

same result.

Maybe because I am on v6.9?


Best regards,
Andreas


[1] https://github.com/metaspace/linux/tree/rnull-v6.9


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 00/13] Support several Rust toolchain versions
  2024-07-03 17:35 [PATCH 00/13] Support several Rust toolchain versions Andreas Hindborg
@ 2024-07-03 17:40 ` Miguel Ojeda
  2024-07-03 18:29   ` Andreas Hindborg
  0 siblings, 1 reply; 6+ messages in thread
From: Miguel Ojeda @ 2024-07-03 17:40 UTC (permalink / raw)
  To: Andreas Hindborg
  Cc: Miguel Ojeda, Wedson Almeida Filho, Alex Gaynor, Boqun Feng,
	Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Alice Ryhl, rust-for-linux, linux-kernel, patches

On Wed, Jul 3, 2024 at 7:35 PM Andreas Hindborg <nmi@metaspace.dk> wrote:
>
> Maybe because I am on v6.9?

Yeah, you need https://lore.kernel.org/rust-for-linux/20240401212303.537355-4-ojeda@kernel.org/
-- please see the "## LLVM's data layout" section in the commit
message.

Thanks for giving it a try!

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 00/13] Support several Rust toolchain versions
  2024-07-03 17:40 ` Miguel Ojeda
@ 2024-07-03 18:29   ` Andreas Hindborg
  0 siblings, 0 replies; 6+ messages in thread
From: Andreas Hindborg @ 2024-07-03 18:29 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Miguel Ojeda, Wedson Almeida Filho, Alex Gaynor, Boqun Feng,
	Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Alice Ryhl, rust-for-linux, linux-kernel, patches

"Miguel Ojeda" <miguel.ojeda.sandonis@gmail.com> writes:

> On Wed, Jul 3, 2024 at 7:35 PM Andreas Hindborg <nmi@metaspace.dk> wrote:
>>
>> Maybe because I am on v6.9?
>
> Yeah, you need https://lore.kernel.org/rust-for-linux/20240401212303.537355-4-ojeda@kernel.org/
> -- please see the "## LLVM's data layout" section in the commit
> message.

I applied it to the rnull tree based on v6.10-rc3 [1] and ran some tests
with rustc 1.78.0 and 1.79.0 without encountering any problems.


Tested-by: Andreas Hindborg <a.hindborg@samsung.com>


Best regards,
Andreas


[1] https://github.com/metaspace/linux/tree/rnull-v6.10-rc3


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-07-03 18:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-03 17:35 [PATCH 00/13] Support several Rust toolchain versions Andreas Hindborg
2024-07-03 17:40 ` Miguel Ojeda
2024-07-03 18:29   ` Andreas Hindborg
  -- strict thread matches above, loose matches on Subject: below --
2024-07-01 18:36 Miguel Ojeda
2024-07-02  6:25 ` Benno Lossin
2024-07-02  9:41   ` Miguel Ojeda

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).