Skip to content

conditional passing of edition for core #1163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
est31 opened this issue May 16, 2025 · 4 comments
Closed

conditional passing of edition for core #1163

est31 opened this issue May 16, 2025 · 4 comments
Labels
• kbuild Related to building the kernel, `make`, `Kbuild`, `Kconfig` options...

Comments

@est31
Copy link

est31 commented May 16, 2025

Since PR rust-lang/rust#138162, the Rust std library and core libraries use edition 2024. The Linux makefile hardcodes edition 2021 however.

Right now, core compiles fine on editions 2021 and 2024, but my PR rust-lang/rust#140966 encountered a build failure of the rust-for-linux CI.

Talked to @nbdd0121 about this. According to them, it should be possible to add conditional compilation dependent on the rust compiler used to compile the kernel. This matches the expectations of the core library the most I'd say: on releases before 1.87.0, the compiler used edition 2021, and on 1.87.0 and later, it uses 2024.

cc @ehuss

nbdd0121 added a commit to nbdd0121/linux that referenced this issue May 17, 2025
Rust 1.87 (released on 2025-05-15) compiles core library with edition
2024 instead of 2021 [1]. Ensure that the edition matches libcore's
expectation to avoid potential breakage.

Cc: [email protected] # Needed in 6.12.y and later (Rust is pinned in older LTSs).
Link: rust-lang/rust#138162 [1]
Closes: Rust-for-Linux#1163
Signed-off-by: Gary Guo <[email protected]>
@ojeda ojeda added the • kbuild Related to building the kernel, `make`, `Kbuild`, `Kconfig` options... label May 18, 2025
@ojeda
Copy link
Member

ojeda commented May 18, 2025

According to them, it should be possible to add conditional compilation dependent on the rust compiler used to compile the kernel.

Yeah, that shouldn't be a problem -- it is the way we handle this sort of thing (Gary asked me while at RustWeek).

Thanks for filling the issue!

@nbdd0121
Copy link
Member

@tgross35
Copy link
Collaborator

@est31 did you leave a comment somewhere about something special needed for rustdoc? I thought it was on 21e9042, but I can't find it anywhere now.

@est31
Copy link
Author

est31 commented May 18, 2025

@est31 did you leave a comment somewhere about something special needed for rustdoc?

Yeah you remember correctly. I've deleted that comment after @nbdd0121 pointed out to me that there is a skip_flags. The patch looks fine to me, but still need try rustc with the patch.

ojeda pushed a commit to ojeda/linux that referenced this issue May 21, 2025
Rust 1.87 (released on 2025-05-15) compiles core library with edition
2024 instead of 2021 [1]. Ensure that the edition matches libcore's
expectation to avoid potential breakage.

Cc: [email protected] # Needed in 6.12.y and later (Rust is pinned in older LTSs).
Link: rust-lang/rust#138162 [1]
Closes: Rust-for-Linux#1163
Signed-off-by: Gary Guo <[email protected]>
Reported-by: est31 <[email protected]>
Reviewed-by: Alice Ryhl <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Miguel Ojeda <[email protected]>
@ojeda ojeda closed this as completed in 7d666f4 May 23, 2025
ojeda pushed a commit that referenced this issue May 24, 2025
Rust 1.87 (released on 2025-05-15) compiles core library with edition
2024 instead of 2021 [1]. Ensure that the edition matches libcore's
expectation to avoid potential breakage.

Cc: [email protected] # Needed in 6.12.y and later (Rust is pinned in older LTSs).
Link: rust-lang/rust#138162 [1]
Closes: #1163
Signed-off-by: Gary Guo <[email protected]>
Reported-by: est31 <[email protected]>
Reviewed-by: Alice Ryhl <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Miguel Ojeda <[email protected]>
bors added a commit to rust-lang/rust that referenced this issue May 24, 2025
Remove #![feature(let_chains)] from libcore

PR #132833 has stabilized the let_chains feature. This PR removes the last occurrence from the library.

Split out of #140966 as it caused breakage. Now we have a patch to the linux tree that fixes the build, so we update the linux tree to it.

cc Rust-for-Linux/linux#1163
cc #140722
github-actions bot pushed a commit to rust-lang/miri that referenced this issue May 25, 2025
Remove #![feature(let_chains)] from libcore

PR rust-lang/rust#132833 has stabilized the let_chains feature. This PR removes the last occurrence from the library.

Split out of #140966 as it caused breakage. Now we have a patch to the linux tree that fixes the build, so we update the linux tree to it.

cc Rust-for-Linux/linux#1163
cc rust-lang/rust#140722
ojeda pushed a commit that referenced this issue May 25, 2025
Rust 1.87 (released on 2025-05-15) compiles core library with edition
2024 instead of 2021 [1]. Ensure that the edition matches libcore's
expectation to avoid potential breakage.

[ J3m3 reported in Zulip [2] that the `rust-analyzer` target was
  broken after this patch -- indeed, we need to avoid `core-cfgs`
  since those are passed to the `rust-analyzer` target.

  So, instead, I tweaked the patch to create a new `core-edition`
  variable and explicitly mention the `--edition` flag instead of
  reusing `core-cfg`s.

  In addition, pass a new argument using this new variable to
  `generate_rust_analyzer.py` so that we set the right edition there.

  By the way, for future reference: the `filter-out` change is needed
  for Rust < 1.87, since otherwise we would skip the `--edition=2021`
  we just added, ending up with no edition flag, and thus the compiler
  would default to the 2015 one.

  [2] https://rust-for-linux.zulipchat.com/#narrow/channel/291565/topic/x/near/520206547

    - Miguel ]

Cc: [email protected] # Needed in 6.12.y and later (Rust is pinned in older LTSs).
Link: rust-lang/rust#138162 [1]
Reported-by: est31 <[email protected]>
Closes: #1163
Signed-off-by: Gary Guo <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Miguel Ojeda <[email protected]>
github-actions bot pushed a commit to model-checking/verify-rust-std that referenced this issue May 26, 2025
Remove #![feature(let_chains)] from libcore

PR rust-lang#132833 has stabilized the let_chains feature. This PR removes the last occurrence from the library.

Split out of rust-lang#140966 as it caused breakage. Now we have a patch to the linux tree that fixes the build, so we update the linux tree to it.

cc Rust-for-Linux/linux#1163
cc rust-lang#140722
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
• kbuild Related to building the kernel, `make`, `Kbuild`, `Kconfig` options...
Development

No branches or pull requests

4 participants