On Wed, Mar 12, 2025 at 4:07 PM Tamir Duberstein <tamird@xxxxxxxxx> wrote: > > On Wed, Mar 12, 2025 at 3:43 PM Benno Lossin <benno.lossin@xxxxxxxxx> wrote: > > > > On Wed Mar 12, 2025 at 8:19 PM CET, Tamir Duberstein wrote: > > > I tried using the strict provenance lints locally and I think we can't > > > until we properly bump MSRV due to `clippy::incompatible_msrv`: > > > > > > warning: current MSRV (Minimum Supported Rust Version) is `1.78.0` but > > > this item is stable since `1.84.0` > > > --> ../rust/kernel/str.rs:696:22 > > > | > > > 696 | pos: pos.expose_provenance(), > > > | ^^^^^^^^^^^^^^^^^^^ > > > | > > > = help: for further information visit > > > https://rust-lang.github.io/rust-clippy/master/index.html#incompatible_msrv > > > > Oh this is annoying... > > > > > This is with `#![feature(strict_provenance)]`. I can file the issue > > > but I think it's blocked on MSRV >= 1.84.0. But maybe you know of a > > > path forward :) > > > > I think we should be able to just `allow(clippy::incompatible_msrv)`, > > since Miguel & other maintainers will test with 1.78 (or at least are > > supposed to :). > > Alright, you've sniped me. This is coming in v3. I just realized I only covered the kernel crate. In order to cover all Rust code, I need to move the lints and the features out to the root Makefile. I tried something like this: > diff --git a/Makefile b/Makefile > index 2af40bfed9ce..10af1e44370b 100644 > --- a/Makefile > +++ b/Makefile > @@ -466,13 +466,21 @@ KBUILD_USERHOSTCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes \ > KBUILD_USERCFLAGS := $(KBUILD_USERHOSTCFLAGS) $(USERCFLAGS) > KBUILD_USERLDFLAGS := $(USERLDFLAGS) > > +# Lints were moved to `strict_provenance_lints` when `strict_provenance` was stabilized. > +# > +# See https://github.com/rust-lang/rust/commit/56ee492a6e7a917b2b3f888e33dd52a13d3ecb64. > +KBUILD_RUST_STRICT_PROVENANCE_FEATURE = $(if $(CONFIG_RUSTC_HAS_STABLE_STRICT_PROVENANCE),strict_provenance_lints,strict_provenance) > + > # These flags apply to all Rust code in the tree, including the kernel and > # host programs. > export rust_common_flags := --edition=2021 \ > -Zbinary_dep_depinfo=y \ > + -Zcrate-attr="feature($(KBUILD_RUST_STRICT_PROVENANCE_FEATURE))" \ > -Astable_features \ > -Dnon_ascii_idents \ > -Dunsafe_op_in_unsafe_fn \ > + -Wfuzzy_provenance_casts \ > + -Wlossy_provenance_casts \ > -Wmissing_docs \ > -Wrust_2018_idioms \ > -Wunreachable_pub \ > diff --git a/rust/Makefile b/rust/Makefile > index ea3849eb78f6..d7d5be741245 100644 > --- a/rust/Makefile > +++ b/rust/Makefile > @@ -435,8 +435,10 @@ $(obj)/helpers/helpers.o: $(src)/helpers/helpers.c $(recordmcount_source) FORCE > # symbol versions generated from Rust objects. > $(obj)/exports.o: private skip_gendwarfksyms = 1 > > +KBUILD_RUST_STRICT_PROVENANCE_FEATURE := $(if $(CONFIG_RUSTC_HAS_STABLE_STRICT_PROVENANCE),strict_provenance_lints,strict_provenance) > + > $(obj)/core.o: private skip_clippy = 1 > -$(obj)/core.o: private skip_flags = -Wunreachable_pub > +$(obj)/core.o: private skip_flags = -Zcrate-attr="feature($(KBUILD_RUST_STRICT_PROVENANCE_FEATURE))" -Wunreachable_pub -Wfuzzy_provenance_casts -Wlossy_provenance_casts > $(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 \ but this doesn't work because `CONFIG_RUSTC_HAS_STABLE_STRICT_PROVENANCE` is not yet defined when I read it in the root Makefile. I can read it lower down and then append the feature flag to `KBUILD_RUSTFLAGS` but by then the rustdoc flags have been copied from `rust_common_flags` and so rustdoc doesn't get the feature flag, resulting in unknown lint warnings in rustdoc and kunit tests. Any ideas?