From: Alice Ryhl <aliceryhl@google.com>
To: Miguel Ojeda <ojeda@kernel.org>
Cc: "Wedson Almeida Filho" <wedsonaf@gmail.com>,
"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@samsung.com>,
rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
patches@lists.linux.dev
Subject: Re: [PATCH 3/3] rust: upgrade to Rust 1.78.0
Date: Thu, 4 Apr 2024 14:41:12 +0200 [thread overview]
Message-ID: <CAH5fLgiLCraafBG5+n_TLZ_hRHM7Yj49QDd=TudHJVkomXyLqw@mail.gmail.com> (raw)
In-Reply-To: <20240401212303.537355-4-ojeda@kernel.org>
On Mon, Apr 1, 2024 at 11:23 PM Miguel Ojeda <ojeda@kernel.org> wrote:
>
> This is the next upgrade to the Rust toolchain, from 1.77.1 to 1.78.0
> (i.e. the latest) [1].
>
> See the upgrade policy [2] and the comments on the first upgrade in
> commit 3ed03f4da06e ("rust: upgrade to Rust 1.68.2").
>
> # Unstable features
>
> There have been no changes to the set of unstable features used in
> our own code. Therefore, the only unstable features allowed to be used
> outside the `kernel` crate is still `new_uninit`.
>
> However, since we are finally dropping our `alloc` fork [3], all the
> unstable features used by `alloc` (~30 language ones, ~60 library ones)
> are not a concern anymore. This reduces the maintenance burden, increases
> the chances of new compiler versions working without changes and gets
> us closer to the goal of supporting several compiler versions.
>
> It also means that, ignoring non-language/library features, we are
> currently left with just the few language features needed to implement the
> kernel `Arc`, the `new_uninit` library feature, the `compiler_builtins`
> marker and the few `no_*` `cfg`s we pass when compiling `core`/`alloc`.
>
> Please see [4] for details.
>
> # Required changes
>
> ## LLVM's data layout
>
> Rust 1.77.0 (i.e. the previous upgrade) introduced a check for matching
> LLVM data layouts [5]. Then, Rust 1.78.0 upgraded LLVM's bundled major
> version from 17 to 18 [6], which changed the data layout in x86 [7]. Thus
> update the data layout in our custom target specification for x86 so
> that the compiler does not complain about the mismatch:
>
> error: data-layout for target `target-5559158138856098584`,
> `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`
>
> In the future, the goal is to drop the custom target specifications.
> Meanwhile, if we want to support other LLVM versions used in `rustc`
> (e.g. for LTO), we will need to add some extra logic (e.g. conditional on
> LLVM's version, or extracting the data layout from an existing built-in
> target specification).
>
> ## `unused_imports`
>
> Rust's `unused_imports` lint covers both unused and redundant imports.
> Now, in 1.78.0, the lint detects more cases of redundant imports [8].
> Thus one of the previous patches cleaned them up.
>
> ## Clippy's `new_without_default`
>
> Clippy now suggests to implement `Default` even when `new()` is `const`,
> since `Default::default()` may call `const` functions even if it is not
> `const` itself [9]. Thus one of the previous patches implemented it.
>
> # Other changes in Rust
>
> Rust 1.78.0 introduced `feature(asm_goto)` [10] [11]. This feature was
> discussed in the past [12].
>
> Rust 1.78.0 introduced support for mutable pointers to Rust statics,
> including a test case for the Linux kernel's `VTABLE` use case [13].
>
> Rust 1.78.0 with debug assertions enabled (i.e. `-Cdebug-assertions=y`,
> kernel's `CONFIG_RUST_DEBUG_ASSERTIONS=y`) now always checks all unsafe
> preconditions, without a way to opt-out for particular cases [14].
>
> Rust 1.78.0 also improved a couple issues we reported when giving feedback
> for the new `--check-cfg` feature [15] [16].
>
> # `alloc` upgrade and reviewing
>
> As mentioned above, compiler upgrades will not update `alloc` anymore,
> since we are dropping our `alloc` fork [3].
>
> Link: https://github.com/rust-lang/rust/blob/stable/RELEASES.md#version-1780-2024-05-02 [1]
> Link: https://rust-for-linux.com/rust-version-policy [2]
> Link: https://lore.kernel.org/rust-for-linux/20240328013603.206764-1-wedsonaf@gmail.com/ [3]
> Link: https://github.com/Rust-for-Linux/linux/issues/2 [4]
> Link: https://github.com/rust-lang/rust/pull/120062 [5]
> Link: https://github.com/rust-lang/rust/pull/120055 [6]
> Link: https://reviews.llvm.org/D86310 [7]
> Link: https://github.com/rust-lang/rust/pull/117772 [8]
> Link: https://github.com/rust-lang/rust-clippy/pull/10903 [9]
> Link: https://github.com/rust-lang/rust/pull/119365 [10]
> Link: https://github.com/rust-lang/rust/issues/119364 [11]
> Link: https://lore.kernel.org/rust-for-linux/ZWipTZysC2YL7qsq@Boquns-Mac-mini.home/ [12]
> Link: https://github.com/rust-lang/rust/pull/120932 [13]
> Link: https://github.com/rust-lang/rust/issues/120969 [14]
> Link: https://github.com/rust-lang/rust/pull/121202 [15]
> Link: https://github.com/rust-lang/rust/pull/121237 [16]
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
next prev parent reply other threads:[~2024-04-04 12:41 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-01 21:23 [PATCH 0/3] Rust 1.78.0 upgrade Miguel Ojeda
2024-04-01 21:23 ` [PATCH 1/3] rust: sync: implement `Default` for `LockClassKey` Miguel Ojeda
2024-04-01 22:26 ` Boqun Feng
2024-04-02 9:46 ` Alice Ryhl
2024-04-02 23:12 ` Benno Lossin
2024-04-01 21:23 ` [PATCH 2/3] rust: kernel: remove redundant imports Miguel Ojeda
2024-04-02 9:48 ` Alice Ryhl
2024-04-01 21:23 ` [PATCH 3/3] rust: upgrade to Rust 1.78.0 Miguel Ojeda
2024-04-01 21:52 ` Miguel Ojeda
2024-04-04 12:41 ` Alice Ryhl [this message]
2024-05-05 22:33 ` [PATCH 0/3] Rust 1.78.0 upgrade Miguel Ojeda
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='CAH5fLgiLCraafBG5+n_TLZ_hRHM7Yj49QDd=TudHJVkomXyLqw@mail.gmail.com' \
--to=aliceryhl@google.com \
--cc=a.hindborg@samsung.com \
--cc=alex.gaynor@gmail.com \
--cc=benno.lossin@proton.me \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=gary@garyguo.net \
--cc=linux-kernel@vger.kernel.org \
--cc=ojeda@kernel.org \
--cc=patches@lists.linux.dev \
--cc=rust-for-linux@vger.kernel.org \
--cc=wedsonaf@gmail.com \
/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).