Skip to content

rust: upgrade to Rust 1.66.0 - #947

Closed
ojeda wants to merge 3 commits into
Rust-for-Linux:rustfrom
ojeda:1.66.0
Closed

ojeda wants to merge 3 commits into
Rust-for-Linux:rustfrom
ojeda:1.66.0

Conversation

@ojeda

@ojeda ojeda commented Dec 25, 2022 •

Copy link
Copy Markdown
Member

Required changes:

I will have to reword the first commit for upstreaming and possibly split it somehow to make it easier to read. For the moment, this should unblock those waiting for 1.66.0 and start testing it on our side.

As a triple-check, I redid the functions by hand and spotted a doc sentence missed from an old upgrade. Nothing important, but I included it here as the third commit too.

Signed-off-by: Miguel Ojeda ojeda@kernel.org

@Conan-Kudo

ghost commented Dec 26, 2022

Copy link
Copy Markdown

cc: @marcan @davide125

@aliceinwire

ghost commented Dec 26, 2022

Copy link
Copy Markdown

Few of this problem are referenced in the following PR:

Comment thread rust/macros/module.rs
}
}

#[allow(clippy::type_complexity)]

ghost Dec 26, 2022 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Referenced in PR #898

ghost Dec 26, 2022

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Alice!

Comment thread rust/kernel/driver.rs
/// - [`RawDeviceId::ZERO`] is actually a zeroed-out version of the raw device id.
/// - [`RawDeviceId::to_rawid`] stores `offset` in the context/data field of the raw device id so
/// that buses can recover the pointer to the data.
#[const_trait]

ghost Dec 26, 2022

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did something break without this?

ghost Dec 26, 2022

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was due to (added it to OP):

error: ~const can only be applied to `#[const_trait]` traits
   --> rust/kernel/driver.rs:156:19
    |
156 |         T: ~const RawDeviceId + Copy,
    |                   ^^^^^^^^^^^

error: const `impl` for trait `RawDeviceId` which is not marked with `#[const_trait]`
   --> rust/kernel/of.rs:40:19
    |
40  | unsafe impl const driver::RawDeviceId for DeviceId {
    |                   ^^^^^^^^^^^^^^^^^^^
    |
   ::: rust/kernel/driver.rs:122:1
    |
122 | pub unsafe trait RawDeviceId {
    | - help: mark `RawDeviceId` as const: `#[const_trait]`
    |
    = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
    = note: adding a non-const method body in the future would be a breaking change

error: aborting due to 2 previous errors

@alex

ghost commented Dec 26, 2022

Copy link
Copy Markdown
Member

Only did a limited review, but LGTM.

@YakoYakoYokuYoku

ghost commented Dec 26, 2022

Copy link
Copy Markdown

Builds without warnings, LGTM

Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
Tested-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>

@Conan-Kudo

ghost commented Dec 26, 2022

Copy link
Copy Markdown

cc: @AsahiLina

@ojeda

ghost commented Dec 26, 2022

Copy link
Copy Markdown
Member Author

Thanks everyone! That was awesome.

@nbdd0121 @vincenzopalazzo @bjorn3 I am transforming your GH approvals into Reviewed-bys -- let me know if you didn't intend that (in which case I will remove it when I submit it for upstream).

@ojeda

ghost commented Dec 26, 2022

Copy link
Copy Markdown
Member Author

v2: no changes, just collected the tags.

@aliceinwire

ghost commented Dec 26, 2022

Copy link
Copy Markdown
Reviewed-by: Alice Ferrazzi <alice.ferrazzi@miraclelinux.com>
Tested-by: Alice Ferrazzi <alice.ferrazzi@miraclelinux.com>

@Conan-Kudo

ghost commented Dec 26, 2022

Copy link
Copy Markdown

ghost left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So my build is fixed, but the result seems to cause Xorg to crash. This probably means that @AsahiLina needs to adapt her code to Rust 1.66.

Otherwise, this looks reasonable.

Reviewed-by: Neal Gompa <neal@gompa.dev>
Tested-by: Neal Gompa <neal@gompa.dev>

@Conan-Kudo

ghost commented Dec 26, 2022

Copy link
Copy Markdown

Also, it probably makes sense to add Reported-by: Neal Gompa <neal@gompa.dev> here, since this was triggered by my post in the Zulip.

ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, we apparently tested the wrong kernel build. The correct kernel build works, so I give this a total 👍🏾

Reported-by: Neal Gompa <neal@gompa.dev>
Reviewed-by: Neal Gompa <neal@gompa.dev>
Tested-by: Neal Gompa <neal@gompa.dev>

@Conan-Kudo

ghost commented Dec 27, 2022

Copy link
Copy Markdown

I also needed a minor tweak from @ericcurtin to get bindgen working too: https://gitlab.com/fedora-asahi/kernel-asahi/-/commit/7407fdf7716f3233da56a5fb4e2e28fffb775fa5

Miguel Ojeda added 3 commits January 11, 2023 00:18
Upgrade the Rust version from 1.62.0 to 1.66.0.

The overwhelming majority of the commit is about upgrading our `alloc`
fork to the new version from upstream [1]. License has not changed [2][3]
(there were changes in the `COPYRIGHT` file, but unrelated to `alloc`).

As in the previous version upgrades (done out of tree so far), upgrading
`alloc` requires checking that our small additions (`try_*`) still match
their original (non`-try_*`) versions.

With this version upgrade, the following unstable Rust features were
stabilized: `bench_black_box` (1.66.0), `const_ptr_offset_from` (1.65.0),
`core_ffi_c` (1.64.0) and `generic_associated_types` (1.65.0). Thus
remove them.

This also implies that only two unstable features remain allowed for
non-`rust/` code: `allocator_api` and `const_refs_to_cell`.

There are some new Clippy warnings that we are triggering (i.e.
introduced since 1.62.0), as well as a few others that were not
triggered before, thus allow them in this commit and clean up or
remove them as needed later on:

  - `borrow_deref_ref` (new in 1.63.0).
  - `explicit_auto_deref` (new in 1.64.0).
  - `bool_to_int_with_if` (new in 1.65.0).
  - `needless_borrow`.
  - `type_complexity`.
  - `unnecessary_cast` (allowed only on `CONFIG_ARM`).

Furthermore, `rustdoc` lint `broken_intra_doc_links` is triggering on
links pointing to `macro_export` `macro_rules` defined in the same
module (i.e. appearing in the crate root).

However, even if the warning appears, the link still gets generated
like in previous versions, thus it is a bit confusing. An issue has
been opened upstream [4], and it appears that the link still being
generated was a compatibility measure, thus we will need to adapt
to the new behavior (done in the next patch).

In addition, there is an added `#[const_trait]` attribute in
`RawDeviceId`, due to 1.66.0's PR "Require `#[const_trait]` on `Trait`
for `impl const Trait`") [5].

Finally, the `-Aunused-imports` was added for compiling `core`. This was
fixed upstream for 1.67.0 in PR "Fix warning when libcore is compiled
with no_fp_fmt_parse" [6], and prevented for the future for that `cfg`
in PR "core: ensure `no_fp_fmt_parse builds` are warning-free" [7].

Reviewed-by: Björn Roy Baron <bjorn3_gh@protonmail.com>
Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
Tested-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
Reviewed-by: Alice Ferrazzi <alice.ferrazzi@miraclelinux.com>
Tested-by: Alice Ferrazzi <alice.ferrazzi@miraclelinux.com>
Reviewed-by: Neal Gompa <neal@gompa.dev>
Tested-by: Neal Gompa <neal@gompa.dev>
Link: Rust-for-Linux#947
Link: https://github.com/rust-lang/rust/tree/1.66.0/library/alloc/src [1]
Link: https://github.com/rust-lang/rust/blob/1.66.0/library/alloc/Cargo.toml#L4 [2]
Link: https://github.com/rust-lang/rust/blob/1.66.0/COPYRIGHT [3]
Link: rust-lang/rust#106142 [4]
Link: rust-lang/rust#100982 [5]
Link: rust-lang/rust#105434 [6]
Link: rust-lang/rust#105811 [7]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
…nings

Since Rust 1.63.0, `rustdoc` complains with `broken_intra_doc_links`
about intra-doc links pointing to exported `macro_rules`, e.g.:

    error: unresolved link to `dev_info`
       --> rust/kernel/device.rs:135:43
        |
    135 |     /// More details are available from [`dev_info`].
        |                                           ^^^^^^^^ no item named `dev_info` in scope
        |
        = note: `macro_rules` named `dev_info` exists in this crate, but it is not in scope at this link's location
        = note: `-D rustdoc::broken-intra-doc-links` implied by `-D warnings`

    error: aborting due to previous error

The text is confusing, because the link still gets generated, and previous versions
(<= 1.62) did not warn and also generated the link. This was reported
upstream at [1], and it turns out that the link still being generated was
a compatibility measure for docs.rs, which may get removed soon. Thus
the intended behavior is that the user specifies the proper path.

Therefore, clean up the `allow()`s introduced earlier to satisfy `rustdoc`
and the new behavior.

Link: rust-lang/rust#106142 [1]
Reviewed-by: Björn Roy Baron <bjorn3_gh@protonmail.com>
Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
Tested-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
Reviewed-by: Alice Ferrazzi <alice.ferrazzi@miraclelinux.com>
Tested-by: Alice Ferrazzi <alice.ferrazzi@miraclelinux.com>
Reviewed-by: Neal Gompa <neal@gompa.dev>
Tested-by: Neal Gompa <neal@gompa.dev>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
An update missing from Rust 1.57.0. The comment was added in upstream
commit e8e7f6e05cf6 ("Add truncate note to Vec::resize") to `resize`,
but not to our fallible version `try_resize`.

Fixes: 7aaec26 ("rust: alloc: upgrade to 1.57.0")
Reviewed-by: Björn Roy Baron <bjorn3_gh@protonmail.com>
Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
Tested-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
Reviewed-by: Alice Ferrazzi <alice.ferrazzi@miraclelinux.com>
Tested-by: Alice Ferrazzi <alice.ferrazzi@miraclelinux.com>
Reviewed-by: Neal Gompa <neal@gompa.dev>
Tested-by: Neal Gompa <neal@gompa.dev>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
@ojeda

ghost commented Jan 11, 2023

Copy link
Copy Markdown
Member Author

Thanks a lot for the extra reviews & tests, @aliceinwire and @Conan-Kudo, very much appreciated.

v3: tags collected for the forthcoming merge and added a proper commit message for the first patch.

Also, it probably makes sense to add Reported-by: Neal Gompa neal@gompa.dev here, since this was triggered by my post in the Zulip.

Reported-by is meant for bugs only according to the docs. In any case, version upgrades will keep happening until we reach a stable release, and others (e.g. @bjorn3 if I recall correctly) suggested/discussed the 1.66 upgrade in the past. For non-routine version upgrades, we could perhaps do Suggested-bys, but really they make sense only after we are in a stable situation.

@ojeda

ghost commented Jan 11, 2023 •

Copy link
Copy Markdown
Member Author

Via the button (we don't push on this branch). I have been experiencing GitHub timeouts very often in the last few days, too (e.g. some minutes ago when clicking the "Compare" button above for v2..v3).

@ojeda ojeda closed this Jan 11, 2023
@ojeda
ojeda deleted the 1.66.0 branch January 11, 2023 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

8 participants