[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aRHOnGyLx-bEVqcY@google.com>
Date: Mon, 10 Nov 2025 11:38:04 +0000
From: Alice Ryhl <aliceryhl@...gle.com>
To: Miguel Ojeda <ojeda@...nel.org>
Cc: Alex Gaynor <alex.gaynor@...il.com>, Nathan Chancellor <nathan@...nel.org>,
Nicolas Schier <nicolas@...sle.eu>, Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
"Björn Roy Baron" <bjorn3_gh@...tonmail.com>, Benno Lossin <lossin@...nel.org>,
Andreas Hindborg <a.hindborg@...nel.org>, Trevor Gross <tmgross@...ch.edu>,
Danilo Krummrich <dakr@...nel.org>, rust-for-linux@...r.kernel.org,
linux-kbuild@...r.kernel.org, linux-kernel@...r.kernel.org,
patches@...ts.linux.dev
Subject: Re: [PATCH 09/18] rust: proc-macro2: enable support in kbuild
On Mon, Nov 10, 2025 at 10:50:14AM +0100, Miguel Ojeda wrote:
> With all the new files in place and ready from the new crate, enable
> the support for it in the build system.
>
> `proc_macro_byte_character` and `proc_macro_c_str_literals` were
> stabilized in Rust 1.79.0 [1] and were implemented earlier than our
> minimum Rust version (1.78) [2][3]. Thus just enable them instead of using
> the `cfg` that `proc-macro2` uses to emulate them in older compilers.
>
> Link: https://github.com/rust-lang/rust/pull/123431 [1]
> Link: https://github.com/rust-lang/rust/pull/112711 [2]
> Link: https://github.com/rust-lang/rust/pull/119651 [3]
> Signed-off-by: Miguel Ojeda <ojeda@...nel.org>
> ---
> Makefile | 3 +++
> rust/Makefile | 32 +++++++++++++++++++++++++++++--
> scripts/generate_rust_analyzer.py | 7 +++++++
> 3 files changed, 40 insertions(+), 2 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index fb4389aa5d5f..6ff887523eee 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1830,6 +1830,9 @@ PHONY += rustfmt rustfmtcheck
>
> rustfmt:
> $(Q)find $(srctree) $(RCS_FIND_IGNORE) \
> + \( \
> + -path $(srctree)/rust/proc-macro2 \
> + \) -prune -o \
> -type f -a -name '*.rs' -a ! -name '*generated*' -print \
> | xargs $(RUSTFMT) $(rustfmt_flags)
>
> diff --git a/rust/Makefile b/rust/Makefile
> index 9eea6563ef35..a614a23023cb 100644
> --- a/rust/Makefile
> +++ b/rust/Makefile
> @@ -27,6 +27,8 @@ endif
>
> obj-$(CONFIG_RUST) += exports.o
>
> +always-$(CONFIG_RUST) += libproc_macro2.rlib
> +
> always-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated.rs
> always-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated_kunit.c
>
> @@ -76,6 +78,17 @@ core-flags := \
> --edition=$(core-edition) \
> $(call cfgs-to-flags,$(core-cfgs))
>
> +proc_macro2-cfgs := \
> + feature="proc-macro" \
> + wrap_proc_macro \
> + $(if $(call rustc-min-version,108800),proc_macro_span_file proc_macro_span_location)
> +
> +# Stable since Rust 1.79.0: `feature(proc_macro_byte_character,proc_macro_c_str_literals)`.
> +proc_macro2-flags := \
> + --cap-lints=allow \
> + -Zcrate-attr='feature(proc_macro_byte_character,proc_macro_c_str_literals)' \
> + $(call cfgs-to-flags,$(proc_macro2-cfgs))
> +
I don't understand this. We enable the features even on 1.79, but we
only pass the proc_macro_span_file, proc_macro_span_location cfgs on
1.88 and above?
We add the appropriate feature(_) invocations on older compilers, so
should we not support those things on those compilers?
Alice
Powered by blists - more mailing lists