Skip to content

Commit 21e9042

Browse files
committed
rust: compile libcore with edition 2024 for 1.87+
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]>
1 parent b443265 commit 21e9042

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

rust/Makefile

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ endif
6060
core-cfgs = \
6161
--cfg no_fp_fmt_parse
6262

63+
ifeq ($(call rustc-min-version,108700),y)
64+
core-cfgs += --edition=2024
65+
else
66+
core-cfgs += --edition=2021
67+
endif
68+
6369
# `rustc` recognizes `--remap-path-prefix` since 1.26.0, but `rustdoc` only
6470
# since Rust 1.81.0. Moreover, `rustdoc` ICEs on out-of-tree builds since Rust
6571
# 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
106112

107113
# Starting with Rust 1.82.0, skipping `-Wrustdoc::unescaped_backticks` should
108114
# not be needed -- see https://github.com/rust-lang/rust/pull/128307.
109-
rustdoc-core: private skip_flags = -Wrustdoc::unescaped_backticks
115+
rustdoc-core: private skip_flags = -Wrustdoc::unescaped_backticks --edition=2021
110116
rustdoc-core: private rustc_target_flags = $(core-cfgs)
111117
rustdoc-core: $(RUST_LIB_SRC)/core/src/lib.rs FORCE
112118
+$(call if_changed,rustdoc)
@@ -416,7 +422,7 @@ quiet_cmd_rustc_library = $(if $(skip_clippy),RUSTC,$(RUSTC_OR_CLIPPY_QUIET)) L
416422
cmd_rustc_library = \
417423
OBJTREE=$(abspath $(objtree)) \
418424
$(if $(skip_clippy),$(RUSTC),$(RUSTC_OR_CLIPPY)) \
419-
$(filter-out $(skip_flags),$(rust_flags) $(rustc_target_flags)) \
425+
$(filter-out $(skip_flags),$(rust_flags)) $(rustc_target_flags) \
420426
--emit=dep-info=$(depfile) --emit=obj=$@ \
421427
--emit=metadata=$(dir $@)$(patsubst %.o,lib%.rmeta,$(notdir $@)) \
422428
--crate-type rlib -L$(objtree)/$(obj) \
@@ -483,7 +489,7 @@ $(obj)/helpers/helpers.o: $(src)/helpers/helpers.c $(recordmcount_source) FORCE
483489
$(obj)/exports.o: private skip_gendwarfksyms = 1
484490

485491
$(obj)/core.o: private skip_clippy = 1
486-
$(obj)/core.o: private skip_flags = -Wunreachable_pub
492+
$(obj)/core.o: private skip_flags = -Wunreachable_pub --edition=2021
487493
$(obj)/core.o: private rustc_objcopy = $(foreach sym,$(redirect-intrinsics),--redefine-sym $(sym)=__rust$(sym))
488494
$(obj)/core.o: private rustc_target_flags = $(core-cfgs)
489495
$(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs \

0 commit comments

Comments
 (0)