* [PATCH] rust: compile libcore with edition 2024 for 1.87+
@ 2025-05-17 8:55 Gary Guo
2025-05-19 17:02 ` Miguel Ojeda
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Gary Guo @ 2025-05-17 8:55 UTC (permalink / raw)
To: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Danilo Krummrich
Cc: stable, rust-for-linux, linux-kernel
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: stable@vger.kernel.org # Needed in 6.12.y and later (Rust is pinned in older LTSs).
Link: https://github.com/rust-lang/rust/pull/138162 [1]
Closes: https://github.com/Rust-for-Linux/linux/issues/1163
Signed-off-by: Gary Guo <gary@garyguo.net>
---
rust/Makefile | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/rust/Makefile b/rust/Makefile
index 3aca903a7d08..9e7f1ec06181 100644
--- a/rust/Makefile
+++ b/rust/Makefile
@@ -60,6 +60,12 @@ endif
core-cfgs = \
--cfg no_fp_fmt_parse
+ifeq ($(call rustc-min-version,108700),y)
+core-cfgs += --edition=2024
+else
+core-cfgs += --edition=2021
+endif
+
# `rustc` recognizes `--remap-path-prefix` since 1.26.0, but `rustdoc` only
# since Rust 1.81.0. Moreover, `rustdoc` ICEs on out-of-tree builds since Rust
# 1.82.0 (https://github.com/rust-lang/rust/issues/138520). Thus workaround both
@@ -106,7 +112,7 @@ rustdoc-macros: $(src)/macros/lib.rs FORCE
# Starting with Rust 1.82.0, skipping `-Wrustdoc::unescaped_backticks` should
# not be needed -- see https://github.com/rust-lang/rust/pull/128307.
-rustdoc-core: private skip_flags = -Wrustdoc::unescaped_backticks
+rustdoc-core: private skip_flags = -Wrustdoc::unescaped_backticks --edition=2021
rustdoc-core: private rustc_target_flags = $(core-cfgs)
rustdoc-core: $(RUST_LIB_SRC)/core/src/lib.rs FORCE
+$(call if_changed,rustdoc)
@@ -416,7 +422,7 @@ quiet_cmd_rustc_library = $(if $(skip_clippy),RUSTC,$(RUSTC_OR_CLIPPY_QUIET)) L
cmd_rustc_library = \
OBJTREE=$(abspath $(objtree)) \
$(if $(skip_clippy),$(RUSTC),$(RUSTC_OR_CLIPPY)) \
- $(filter-out $(skip_flags),$(rust_flags) $(rustc_target_flags)) \
+ $(filter-out $(skip_flags),$(rust_flags)) $(rustc_target_flags) \
--emit=dep-info=$(depfile) --emit=obj=$@ \
--emit=metadata=$(dir $@)$(patsubst %.o,lib%.rmeta,$(notdir $@)) \
--crate-type rlib -L$(objtree)/$(obj) \
@@ -483,7 +489,7 @@ $(obj)/helpers/helpers.o: $(src)/helpers/helpers.c $(recordmcount_source) FORCE
$(obj)/exports.o: private skip_gendwarfksyms = 1
$(obj)/core.o: private skip_clippy = 1
-$(obj)/core.o: private skip_flags = -Wunreachable_pub
+$(obj)/core.o: private skip_flags = -Wunreachable_pub --edition=2021
$(obj)/core.o: private rustc_objcopy = $(foreach sym,$(redirect-intrinsics),--redefine-sym $(sym)=__rust$(sym))
$(obj)/core.o: private rustc_target_flags = $(core-cfgs)
$(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs \
base-commit: 172a9d94339cea832d89630b89d314e41d622bd8
--
2.47.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] rust: compile libcore with edition 2024 for 1.87+
2025-05-17 8:55 [PATCH] rust: compile libcore with edition 2024 for 1.87+ Gary Guo
@ 2025-05-19 17:02 ` Miguel Ojeda
2025-05-19 18:01 ` Alice Ryhl
2025-05-25 21:23 ` Miguel Ojeda
2 siblings, 0 replies; 4+ messages in thread
From: Miguel Ojeda @ 2025-05-19 17:02 UTC (permalink / raw)
To: Gary Guo
Cc: Miguel Ojeda, Alex Gaynor, Boqun Feng, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
Danilo Krummrich, stable, rust-for-linux, linux-kernel, est31
On Sat, May 17, 2025 at 10:56 AM Gary Guo <gary@garyguo.net> wrote:
>
> 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: stable@vger.kernel.org # Needed in 6.12.y and later (Rust is pinned in older LTSs).
> Link: https://github.com/rust-lang/rust/pull/138162 [1]
> Closes: https://github.com/Rust-for-Linux/linux/issues/1163
> Signed-off-by: Gary Guo <gary@garyguo.net>
Cc'ing est31 -- I will add:
Reported-by: est31 <est31@protonmail.com>
Thanks!
Cheers,
Miguel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] rust: compile libcore with edition 2024 for 1.87+
2025-05-17 8:55 [PATCH] rust: compile libcore with edition 2024 for 1.87+ Gary Guo
2025-05-19 17:02 ` Miguel Ojeda
@ 2025-05-19 18:01 ` Alice Ryhl
2025-05-25 21:23 ` Miguel Ojeda
2 siblings, 0 replies; 4+ messages in thread
From: Alice Ryhl @ 2025-05-19 18:01 UTC (permalink / raw)
To: Gary Guo
Cc: Miguel Ojeda, Alex Gaynor, Boqun Feng, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Trevor Gross, Danilo Krummrich,
stable, rust-for-linux, linux-kernel
On Sat, May 17, 2025 at 09:55:59AM +0100, Gary Guo wrote:
> 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: stable@vger.kernel.org # Needed in 6.12.y and later (Rust is pinned in older LTSs).
> Link: https://github.com/rust-lang/rust/pull/138162 [1]
> Closes: https://github.com/Rust-for-Linux/linux/issues/1163
> Signed-off-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] rust: compile libcore with edition 2024 for 1.87+
2025-05-17 8:55 [PATCH] rust: compile libcore with edition 2024 for 1.87+ Gary Guo
2025-05-19 17:02 ` Miguel Ojeda
2025-05-19 18:01 ` Alice Ryhl
@ 2025-05-25 21:23 ` Miguel Ojeda
2 siblings, 0 replies; 4+ messages in thread
From: Miguel Ojeda @ 2025-05-25 21:23 UTC (permalink / raw)
To: Gary Guo
Cc: Miguel Ojeda, Alex Gaynor, Boqun Feng, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
Danilo Krummrich, stable, rust-for-linux, linux-kernel, est31
On Sat, May 17, 2025 at 10:56 AM Gary Guo <gary@garyguo.net> wrote:
>
> 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: stable@vger.kernel.org # Needed in 6.12.y and later (Rust is pinned in older LTSs).
> Link: https://github.com/rust-lang/rust/pull/138162 [1]
> Closes: https://github.com/Rust-for-Linux/linux/issues/1163
> Signed-off-by: Gary Guo <gary@garyguo.net>
Applied to `rust-next` -- thanks everyone!
(I actually applied a couple days ago in advance of Monday's -next,
which explains the following report)
[ 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 ]
I also added:
Reported-by: est31 <est31@protonmail.com>
since est31 told Gary in RustWeek, and we discussed the patch there.
@Gary: I hope the changes are OK with you (I can put the
`generate_rust_analyzer` ones in a different commit if you prefer).
Thanks!
Cheers,
Miguel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-05-25 21:24 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-17 8:55 [PATCH] rust: compile libcore with edition 2024 for 1.87+ Gary Guo
2025-05-19 17:02 ` Miguel Ojeda
2025-05-19 18:01 ` Alice Ryhl
2025-05-25 21:23 ` 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).