From nobody Tue Dec 2 01:06:12 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 65B2631355A; Mon, 24 Nov 2025 15:19:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763997599; cv=none; b=EdHw5R48CZhElzCGueimKrgowRSxcNlnUsFSQJRE0dYTVviWNJ3OEQnAq5wtFNq5txPOaDg8ccokorQRMfdRWZ/xuhGR7OrArvJkVh7DxY31lia7jkxuIq+D6YG7f2FobOUTS9+FaF06LqF2NxOR41fmAvQ+9DLkXGVIdPu/ufk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763997599; c=relaxed/simple; bh=9o7Mk4OPTg3U83R+FC8FwjwEWbG4Bl7tPSgERthXmXs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MWtBTxZCY8Wjj9H89hMOj0Br8KE4em/C5wVtoVfUZqrpbEWMOPW3JBl+Wti1r+wyjPOHw2HGVim5HtUiOv9/z+ED58IufAgE4Avw1h26/6Po5/2v8C3faU3TFXY7GgJI3hBY6tie9zE47Lb0FpwpGNCz6rE4v/WFSpSYk+DAA3M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=auZhmb4K; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="auZhmb4K" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8C070C116C6; Mon, 24 Nov 2025 15:19:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763997599; bh=9o7Mk4OPTg3U83R+FC8FwjwEWbG4Bl7tPSgERthXmXs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=auZhmb4KiLqbM2mUSC9CZ3NcG7BhP/vedqZelOKVJbXLxlNpoTtLvh8DZ701Rlf5z BVdc66orhQW06k3g/zoNaBp0yBuH7iLYOwP3FiO9ZVZ7/3jGwUL9cFtYfcziv2o8cn GHSQE55h9pBfKGWyzBOmN8nju5migXE5gT4yjc4G8E0WOZ07MmZdXq3MCDQl07Say3 awfjOZO88Np6EX3xoY7u5rWRyuOINCeBAIjPTTYBWEMyH4oxhkvp0S3q3yN3IGeZjC Gpkhiq13up02uaDL5dBTgNpr249JEBXbZJujBmCd+4LldVYGDhpup3FMI9XdImIv7U /I4IfKs6C0D6Q== From: Miguel Ojeda To: Miguel Ojeda , Alex Gaynor , Nathan Chancellor , Nicolas Schier Cc: Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , rust-for-linux@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Jesung Yang Subject: [PATCH v2 14/20] rust: quote: enable support in kbuild Date: Mon, 24 Nov 2025 16:18:26 +0100 Message-ID: <20251124151837.2184382-15-ojeda@kernel.org> In-Reply-To: <20251124151837.2184382-1-ojeda@kernel.org> References: <20251124151837.2184382-1-ojeda@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" With all the new files in place and ready from the new crate, enable the support for it in the build system. Reviewed-by: Alice Ryhl Reviewed-by: Gary Guo Tested-by: Gary Guo Tested-by: Jesung Yang Signed-off-by: Miguel Ojeda --- Makefile | 1 + rust/Makefile | 38 ++++++++++++++++++++++++++++--- scripts/generate_rust_analyzer.py | 7 ++++++ 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 589bcfe3bf75..85da055e4f00 100644 --- a/Makefile +++ b/Makefile @@ -1834,6 +1834,7 @@ rustfmt: $(Q)find $(srctree) $(RCS_FIND_IGNORE) \ \( \ -path $(srctree)/rust/proc-macro2 \ + -o -path $(srctree)/rust/quote \ \) -prune -o \ -type f -a -name '*.rs' -a ! -name '*generated*' -print \ | xargs $(RUSTFMT) $(rustfmt_flags) diff --git a/rust/Makefile b/rust/Makefile index 7dd1261ad98f..4f4a00594142 100644 --- a/rust/Makefile +++ b/rust/Makefile @@ -27,7 +27,7 @@ endif =20 obj-$(CONFIG_RUST) +=3D exports.o =20 -always-$(CONFIG_RUST) +=3D libproc_macro2.rlib +always-$(CONFIG_RUST) +=3D libproc_macro2.rlib libquote.rlib =20 always-$(CONFIG_RUST_KERNEL_DOCTESTS) +=3D doctests_kernel_generated.rs always-$(CONFIG_RUST_KERNEL_DOCTESTS) +=3D doctests_kernel_generated_kunit= .c @@ -89,6 +89,18 @@ proc_macro2-flags :=3D \ -Zcrate-attr=3D'feature(proc_macro_byte_character,proc_macro_c_str_lit= erals)' \ $(call cfgs-to-flags,$(proc_macro2-cfgs)) =20 +quote-cfgs :=3D \ + feature=3D"proc-macro" + +quote-skip_flags :=3D \ + --edition=3D2021 + +quote-flags :=3D \ + --edition=3D2018 \ + --cap-lints=3Dallow \ + --extern proc_macro2 \ + $(call cfgs-to-flags,$(quote-cfgs)) + # `rustdoc` did not save the target modifiers, thus workaround for # the time being (https://github.com/rust-lang/rust/issues/144521). rustdoc_modifiers_workaround :=3D $(if $(call rustc-min-version,108800),-C= unsafe-allow-abi-mismatch=3Dfixed-x18) @@ -143,10 +155,17 @@ rustdoc-proc_macro2: private rustc_target_flags =3D $= (proc_macro2-flags) rustdoc-proc_macro2: $(src)/proc-macro2/lib.rs rustdoc-clean FORCE +$(call if_changed,rustdoc) =20 +rustdoc-quote: private rustdoc_host =3D yes +rustdoc-quote: private rustc_target_flags =3D $(quote-flags) +rustdoc-quote: private skip_flags =3D $(quote-skip_flags) +rustdoc-quote: $(src)/quote/lib.rs rustdoc-clean rustdoc-proc_macro2 FORCE + +$(call if_changed,rustdoc) + rustdoc-macros: private rustdoc_host =3D yes rustdoc-macros: private rustc_target_flags =3D --crate-type proc-macro \ --extern proc_macro -rustdoc-macros: $(src)/macros/lib.rs rustdoc-clean rustdoc-proc_macro2 FOR= CE +rustdoc-macros: $(src)/macros/lib.rs rustdoc-clean rustdoc-proc_macro2 \ + rustdoc-quote FORCE +$(call if_changed,rustdoc) =20 # Starting with Rust 1.82.0, skipping `-Wrustdoc::unescaped_backticks` sho= uld @@ -207,6 +226,11 @@ rusttestlib-proc_macro2: private rustc_target_flags = =3D $(proc_macro2-flags) rusttestlib-proc_macro2: $(src)/proc-macro2/lib.rs FORCE +$(call if_changed,rustc_test_library) =20 +rusttestlib-quote: private skip_flags =3D $(quote-skip_flags) +rusttestlib-quote: private rustc_target_flags =3D $(quote-flags) +rusttestlib-quote: $(src)/quote/lib.rs rusttestlib-proc_macro2 FORCE + +$(call if_changed,rustc_test_library) + rusttestlib-macros: private rustc_target_flags =3D --extern proc_macro rusttestlib-macros: private rustc_test_library_proc =3D yes rusttestlib-macros: $(src)/macros/lib.rs FORCE @@ -458,6 +482,12 @@ $(obj)/libproc_macro2.rlib: private rustc_target_flags= =3D $(proc_macro2-flags) $(obj)/libproc_macro2.rlib: $(src)/proc-macro2/lib.rs FORCE +$(call if_changed_dep,rustc_procmacrolibrary) =20 +$(obj)/libquote.rlib: private skip_clippy =3D 1 +$(obj)/libquote.rlib: private skip_flags =3D $(quote-skip_flags) +$(obj)/libquote.rlib: private rustc_target_flags =3D $(quote-flags) +$(obj)/libquote.rlib: $(src)/quote/lib.rs $(obj)/libproc_macro2.rlib FORCE + +$(call if_changed_dep,rustc_procmacrolibrary) + quiet_cmd_rustc_procmacro =3D $(RUSTC_OR_CLIPPY_QUIET) P $@ cmd_rustc_procmacro =3D \ $(RUSTC_OR_CLIPPY) $(rust_common_flags) $(rustc_target_flags) \ @@ -469,7 +499,8 @@ quiet_cmd_rustc_procmacro =3D $(RUSTC_OR_CLIPPY_QUIET) = P $@ @$(objtree)/include/generated/rustc_cfg $< =20 # Procedural macros can only be used with the `rustc` that compiled it. -$(obj)/$(libmacros_name): $(src)/macros/lib.rs $(obj)/libproc_macro2.rlib = FORCE +$(obj)/$(libmacros_name): $(src)/macros/lib.rs $(obj)/libproc_macro2.rlib \ + $(obj)/libquote.rlib FORCE +$(call if_changed_dep,rustc_procmacro) =20 $(obj)/$(libpin_init_internal_name): private rustc_target_flags =3D --cfg = kernel @@ -493,6 +524,7 @@ rust-analyzer: $(Q)MAKEFLAGS=3D $(srctree)/scripts/generate_rust_analyzer.py \ --cfgs=3D'core=3D$(core-cfgs)' $(core-edition) \ --cfgs=3D'proc_macro2=3D$(proc_macro2-cfgs)' \ + --cfgs=3D'quote=3D$(quote-cfgs)' \ $(realpath $(srctree)) $(realpath $(objtree)) \ $(rustc_sysroot) $(RUST_LIB_SRC) $(if $(KBUILD_EXTMOD),$(srcroot)) \ > rust-project.json diff --git a/scripts/generate_rust_analyzer.py b/scripts/generate_rust_anal= yzer.py index 00c6b7cc94b7..4faf153ed2ee 100755 --- a/scripts/generate_rust_analyzer.py +++ b/scripts/generate_rust_analyzer.py @@ -93,6 +93,13 @@ def generate_crates(srctree, objtree, sysroot_src, exter= nal_src, cfgs, core_edit cfg=3Dcrates_cfgs["proc_macro2"], ) =20 + append_crate( + "quote", + srctree / "rust" / "quote" / "lib.rs", + ["alloc", "proc_macro", "proc_macro2"], + cfg=3Dcrates_cfgs["quote"], + ) + append_crate( "macros", srctree / "rust" / "macros" / "lib.rs", --=20 2.52.0