Skip to content

Commit 46e58a9

Browse files
committed
rust: kbuild: introduce core-flags and core-skip_flags
In the next commits we are introducing `*-{cfgs,skip_flags,flags}` variables for other crates. Thus do so here for `core`, which simplifies a bit the `Makefile` (including the next commit) and makes it more consistent. This means we stop passing `-Wrustdoc::unescaped_backticks` to `rustc` and `-Wunreachable_pub` to `rustdoc`, i.e. we skip more, which is fine since it shouldn't have an effect. In addition, use `:=` for `core-cfgs` to make it consistent with the upcoming additions. Reviewed-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Gary Guo <gary@garyguo.net> Tested-by: Gary Guo <gary@garyguo.net> Tested-by: Jesung Yang <y.j3ms.n@gmail.com> Link: https://patch.msgid.link/20251124151837.2184382-2-ojeda@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
1 parent 7a0eae4 commit 46e58a9

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

rust/Makefile

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,20 @@ rustdoc_test_quiet=--test-args -q
6060
rustdoc_test_kernel_quiet=>/dev/null
6161
endif
6262

63-
core-cfgs = \
63+
core-cfgs := \
6464
--cfg no_fp_fmt_parse
6565

6666
core-edition := $(if $(call rustc-min-version,108700),2024,2021)
6767

68+
core-skip_flags := \
69+
--edition=2021 \
70+
-Wunreachable_pub \
71+
-Wrustdoc::unescaped_backticks
72+
73+
core-flags := \
74+
--edition=$(core-edition) \
75+
$(core-cfgs)
76+
6877
# `rustdoc` did not save the target modifiers, thus workaround for
6978
# the time being (https://github.com/rust-lang/rust/issues/144521).
7079
rustdoc_modifiers_workaround := $(if $(call rustc-min-version,108800),-Cunsafe-allow-abi-mismatch=fixed-x18)
@@ -122,8 +131,8 @@ rustdoc-macros: $(src)/macros/lib.rs rustdoc-clean FORCE
122131

123132
# Starting with Rust 1.82.0, skipping `-Wrustdoc::unescaped_backticks` should
124133
# not be needed -- see https://github.com/rust-lang/rust/pull/128307.
125-
rustdoc-core: private skip_flags = --edition=2021 -Wrustdoc::unescaped_backticks
126-
rustdoc-core: private rustc_target_flags = --edition=$(core-edition) $(core-cfgs)
134+
rustdoc-core: private skip_flags = $(core-skip_flags)
135+
rustdoc-core: private rustc_target_flags = $(core-flags)
127136
rustdoc-core: $(RUST_LIB_SRC)/core/src/lib.rs rustdoc-clean FORCE
128137
+$(call if_changed,rustdoc)
129138

@@ -499,9 +508,9 @@ $(obj)/helpers/helpers.o: $(src)/helpers/helpers.c $(recordmcount_source) FORCE
499508
$(obj)/exports.o: private skip_gendwarfksyms = 1
500509

501510
$(obj)/core.o: private skip_clippy = 1
502-
$(obj)/core.o: private skip_flags = --edition=2021 -Wunreachable_pub
511+
$(obj)/core.o: private skip_flags = $(core-skip_flags)
503512
$(obj)/core.o: private rustc_objcopy = $(foreach sym,$(redirect-intrinsics),--redefine-sym $(sym)=__rust$(sym))
504-
$(obj)/core.o: private rustc_target_flags = --edition=$(core-edition) $(core-cfgs)
513+
$(obj)/core.o: private rustc_target_flags = $(core-flags)
505514
$(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs \
506515
$(wildcard $(objtree)/include/config/RUSTC_VERSION_TEXT) FORCE
507516
+$(call if_changed_rule,rustc_library)

0 commit comments

Comments
 (0)