From nobody Tue Dec 2 01:06:14 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 1D10A31355A; Mon, 24 Nov 2025 15:19:08 +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=1763997549; cv=none; b=dEyOprfmCQhDoA65IDHlI8RuXlo2UzMg03PoLoqvKuqqX8ACpS7TFslklvDf+0Oo1M3EBrbYoNNbTnyAwj7dYT5kU6tz3a4CG5/S5vEXycqW8rUkovYaFsn/SyewCG8BqMAmZkpaLMyOGsw6vkqtKqy56u6fLwySXkJbA+4E/fs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763997549; c=relaxed/simple; bh=ftNkFtBoYt7uNDdSMESD1jcmUrVtwSeg8Bd6lydF1ds=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=K1z23rRLN3KnM20h+Fl+RKsOTpaupaUSePDKHdKnll/QHSHw+7qu7jyhGaz6TCKgQIA8tIB1NLTW6lnhdIq43Ap5o8tan19lKvUy9XK66bU4MompAgCGMevwDnxzsF72Fv5SgPP8zcJI+M7bZaLHB8xyv/nhU8Zek7hveEMBwWE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=APY0OstT; 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="APY0OstT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7330C4CEF1; Mon, 24 Nov 2025 15:19:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763997548; bh=ftNkFtBoYt7uNDdSMESD1jcmUrVtwSeg8Bd6lydF1ds=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=APY0OstTrkQon/azznA2KlNMW/ctRvIvIf1vJmirfS44ypiwyPGKH653mBMkLi1td YS84hnR6zdShcUxZXRuCu7vFwrwc7pIYx8Cs/r/QCWV9sA2u5s9oTSua/R5bi1Z8hD itLt5GUaturVVE8plBxWFSETC+Uikr7M20YUXb0OyMKS5Q2NgelsT33AMnwXmGCiEV dDNM697RuQ/MBjCny/OsBE8I4w+nEAhBh/B5nxel3W3UnCUircaa8FkkqOZBuq4jlX ftkdVfERhIQttHsLf0XHNkbpSduQCIv/jH5dEV3L2bJHvCIk6gXtWkzEZY5jfgn2v9 QoWaf5kwW7YLQ== 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 02/20] rust: kbuild: simplify `--cfg` handling Date: Mon, 24 Nov 2025 16:18:14 +0100 Message-ID: <20251124151837.2184382-3-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" We need to handle `cfg`s in both `rustc` and `rust-analyzer`, and in future commits some of those contain double quotes, which complicates things further. Thus, instead of removing the `--cfg ` part in the rust-analyzer generation script, have the `*-cfgs` variables contain just the actual `cfg`, and use that to generate the actual flags in `*-flags`. Reviewed-by: Alice Ryhl Reviewed-by: Gary Guo Tested-by: Gary Guo Tested-by: Jesung Yang Signed-off-by: Miguel Ojeda --- rust/Makefile | 6 ++++-- scripts/generate_rust_analyzer.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/rust/Makefile b/rust/Makefile index ce1853a09d3d..9967f3457d44 100644 --- a/rust/Makefile +++ b/rust/Makefile @@ -60,8 +60,10 @@ rustdoc_test_quiet=3D--test-args -q rustdoc_test_kernel_quiet=3D>/dev/null endif =20 +cfgs-to-flags =3D $(patsubst %,--cfg=3D'%',$1) + core-cfgs :=3D \ - --cfg no_fp_fmt_parse + no_fp_fmt_parse =20 core-edition :=3D $(if $(call rustc-min-version,108700),2024,2021) =20 @@ -72,7 +74,7 @@ core-skip_flags :=3D \ =20 core-flags :=3D \ --edition=3D$(core-edition) \ - $(core-cfgs) + $(call cfgs-to-flags,$(core-cfgs)) =20 # `rustdoc` did not save the target modifiers, thus workaround for # the time being (https://github.com/rust-lang/rust/issues/144521). diff --git a/scripts/generate_rust_analyzer.py b/scripts/generate_rust_anal= yzer.py index fc27f0cca752..dedca470adc1 100755 --- a/scripts/generate_rust_analyzer.py +++ b/scripts/generate_rust_analyzer.py @@ -15,7 +15,7 @@ def args_crates_cfgs(cfgs): crates_cfgs =3D {} for cfg in cfgs: crate, vals =3D cfg.split("=3D", 1) - crates_cfgs[crate] =3D vals.replace("--cfg", "").split() + crates_cfgs[crate] =3D vals.split() =20 return crates_cfgs =20 --=20 2.52.0