From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5D5B42D061B for ; Wed, 21 Jan 2026 01:16:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.196 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768958171; cv=none; b=R324Pw8UoWlpKVbEAVIsT/s2fsw+6dVX8IroTfOYc/UZP7Ao9PCx5J/cOxTgtfVmhf+zOkZ7Phf3w4oHZFZodST2IXEuvv+KMO1MFXM6PVh2jXXtU6a2m5vwrDnhSgGRJ3qWcRe5wEvYqcYOK4wyjE5kAhBPyEsqie3/vCnHPV8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768958171; c=relaxed/simple; bh=8tK93kNbfRfdSjL6W5C/lx7kmJbOTp0ynbmaT+UmxLU=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:Subject:From:To: References:In-Reply-To; b=bqlTtRAjk2vr8SlydC5YLmq4ff7t2HPLlIzadRoRZfT8iKruv2F4meC0Y/bYYbea5rKEBStw8VHZAdMP+6YNPC/DI1aopycXhQm5S0J/YjrB5rn5o4YS71mLuZ3+OuaSCTVRlF5CiUPl9MM7KLDn6bC2Dd8w96yh5KEnf8E/KME= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=bbL/rA7v; arc=none smtp.client-ip=209.85.210.196 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bbL/rA7v" Received: by mail-pf1-f196.google.com with SMTP id d2e1a72fcca58-81f4e136481so2829220b3a.3 for ; Tue, 20 Jan 2026 17:16:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768958169; x=1769562969; darn=vger.kernel.org; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=TuJvjah/Tw/b3alV1e6g6NeIK8xwKHZbZfdxMeTcSjs=; b=bbL/rA7vKnUK60t458F+k9TNmrrwQRp8FNJf1paJmgyO7pQcG9Tf2qL0FwNlIhhj/M wmtYltkWPyFHUdsyCKbqd5h08PvbVZgVW6ePP6x4NVHWViPuxHkqzTm0gxh8OfPs6vQJ CoiqOT7sQXm04poUyru2FrS/ScaUYPl+3wTfGnhHIBqQFxlhYv9aatxwTWh67PAtLBHJ Y9PzxZWzEPOv5SuVLi91d7OvHTAc4sWuYMTDIvQDFiArd1iN344BmRJ13zI5QeVzP2Ye O/cu6PKyRykf8hSOPQiv/f+f6ecEViOeILdgFEa3vHKTQteqaqUX5o8vxRrXy0Fzf9bH RLEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768958169; x=1769562969; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=TuJvjah/Tw/b3alV1e6g6NeIK8xwKHZbZfdxMeTcSjs=; b=PM8wHCihZokTCC9PV+ALAMSObUWCWLhWomjTTaLNaseIIuoE92THiCWLhtKnSmSu2J WPP/4d6Dvj4XVTAmZ5nDUhgekacqFrpcip2RXOny7Pq8OAaP0gOi1quXL3hiXjGalS8q foI+eJhSj2Lq20QD6EDl3vCWZiXPF983HC7i1f8d+3GYaS7My1phZnUzQ27EnVUuojZ5 tcTSE0mkus3B1tPFgIklL7754dFayb/ap7mSAeOg6ylXbRtPoxZi5v0VcY9uK7qn4KQE elltKhULnsp/Hmj7YQjg5J4rA1DXVXpdeTDsJrKGMSCTQDhLbJetXPrvFz503PMTtgd3 QGdw== X-Forwarded-Encrypted: i=1; AJvYcCXSBGUwsKhj+RMTlMbufoFf1vSE0Nu7A1mlrlw0euJq9O1sWAfVTadtqAbcm8kOypDWxSID6jUIDJKFUtE=@vger.kernel.org X-Gm-Message-State: AOJu0YzNulvfq95QiAJCjaAot2HNSHeuKx1Ri6/8H3HGBKizkfdjcrRW aKbD78oihN0+S8uwWL7qofgBMf+DA3zQOxouY8d1G4cvQad4dyYqcHsZ X-Gm-Gg: AZuq6aIHnSdVReWvucBXPvAJwwPnGX+In0t/hggO9GUlxkysnDeJnPsh/X5WfB1aUqL cGyUHit2nLvWciaCaDn92Z+iNlOl8/1qH/YKjFJJqsjZec5DCRBHiEc8YprW3XBzGnR9vRQwe9s 1CgjPAPhLX60TyCSrtkBKoKjw0pKnkTcShbuuWdL0X/jubLTPFUh3k1dGXaiLygIJRcG5hploZz f/RQsUbP39YwP0a9a/5vvZPNtMsv02hIMIg4IjZ6ygnY9iXMhpimEuzp9ix/lQLNTVTGZ3y4/el mPKPy/5Y9M+0hmLp4E7neERi9dKnosQDhJSxcuMUNFnLIApRs2OCTkSDsaZXT5qxBgxCBBt0PRS 3arPQG4FExRammlLZ4Ag3wpmrngPLxruXuM+kcqPPueAPTMRH4fb7HKa2zueslgJLa51Pi1K4OW EKepczIHrjAxBDZlpX X-Received: by 2002:a05:6a00:1413:b0:81d:8d00:76d2 with SMTP id d2e1a72fcca58-81fa18204a0mr12463838b3a.40.1768958168312; Tue, 20 Jan 2026 17:16:08 -0800 (PST) Received: from localhost ([112.149.32.52]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-81fa108c4dbsm13363443b3a.5.2026.01.20.17.16.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 20 Jan 2026 17:16:07 -0800 (PST) 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 Date: Wed, 21 Jan 2026 10:16:03 +0900 Message-Id: Cc: , , "Nathan Chancellor" , "Nicolas Schier" , "Linux Kbuild mailing list" Subject: Re: [PATCH v2 2/2] scripts: generate_rust_analyzer.py: reduce cfg plumbing From: "Jesung Yang" To: "Tamir Duberstein" , "Miguel Ojeda" , "Boqun Feng" , "Gary Guo" , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , "Benno Lossin" , "Andreas Hindborg" , "Alice Ryhl" , "Trevor Gross" , "Danilo Krummrich" , "Jesung Yang" X-Mailer: aerc 0.21.0 References: <20260120-rust-analyzer-pin-init-duplication-v2-0-a1c76f0d3bef@kernel.org> <20260120-rust-analyzer-pin-init-duplication-v2-2-a1c76f0d3bef@kernel.org> In-Reply-To: <20260120-rust-analyzer-pin-init-duplication-v2-2-a1c76f0d3bef@kernel.org> On Wed Jan 21, 2026 at 1:10 AM KST, Tamir Duberstein wrote: > Centralize `cfg` lookup in `append_crate` to avoid having to do so for > each crate. Remove hardcoded `cfg`s for `pin-init{,-internal}` now that > these are passed from `rust/Makefile`. > > Signed-off-by: Tamir Duberstein > --- > scripts/generate_rust_analyzer.py | 13 +++++-------- > 1 file changed, 5 insertions(+), 8 deletions(-) > > diff --git a/scripts/generate_rust_analyzer.py b/scripts/generate_rust_an= alyzer.py > index 147d0cc94068..b96d3cbe3df1 100755 > --- a/scripts/generate_rust_analyzer.py > +++ b/scripts/generate_rust_analyzer.py > @@ -35,7 +35,9 @@ def generate_crates(srctree, objtree, sysroot_src, exte= rnal_src, cfgs, core_edit > crates_indexes =3D {} > crates_cfgs =3D args_crates_cfgs(cfgs) > =20 > - def append_crate(display_name, root_module, deps, cfg=3D[], is_works= pace_member=3DTrue, is_proc_macro=3DFalse, edition=3D"2021"): > + def append_crate(display_name, root_module, deps, cfg=3DNone, is_wor= kspace_member=3DTrue, is_proc_macro=3DFalse, edition=3D"2021"): > + if cfg is None: > + cfg =3D crates_cfgs.get(display_name, []) Could we add a brief comment explaining how the behavior of `append_crate` changes according to the `cfg` parameter? Since `None` and an empty list have different effects, documenting that distinction would make the intended behavior clearer. This would also help later when we add proper Python docstrings. Thanks! Best regards, Jesung > crate =3D { > "display_name": display_name, > "root_module": str(root_module), > @@ -60,7 +62,7 @@ def generate_crates(srctree, objtree, sysroot_src, exte= rnal_src, cfgs, core_edit > def append_sysroot_crate( > display_name, > deps, > - cfg=3D[], > + cfg=3DNone, > edition=3D"2021", > ): > append_crate( > @@ -75,7 +77,7 @@ def generate_crates(srctree, objtree, sysroot_src, exte= rnal_src, cfgs, core_edit > # NB: sysroot crates reexport items from one another so setting up o= ur transitive dependencies > # here is important for ensuring that rust-analyzer can resolve symb= ols. The sources of truth > # for this dependency graph are `(sysroot_src / crate / "Cargo.toml"= for crate in crates)`. > - append_sysroot_crate("core", [], cfg=3Dcrates_cfgs.get("core", []), = edition=3Dcore_edition) > + append_sysroot_crate("core", [], edition=3Dcore_edition) > append_sysroot_crate("alloc", ["core"]) > append_sysroot_crate("std", ["alloc", "core"]) > append_sysroot_crate("proc_macro", ["core", "std"]) > @@ -90,21 +92,18 @@ def generate_crates(srctree, objtree, sysroot_src, ex= ternal_src, cfgs, core_edit > "proc_macro2", > srctree / "rust" / "proc-macro2" / "lib.rs", > ["core", "alloc", "std", "proc_macro"], > - cfg=3Dcrates_cfgs["proc_macro2"], > ) > =20 > append_crate( > "quote", > srctree / "rust" / "quote" / "lib.rs", > ["alloc", "proc_macro", "proc_macro2"], > - cfg=3Dcrates_cfgs["quote"], > ) > =20 > append_crate( > "syn", > srctree / "rust" / "syn" / "lib.rs", > ["proc_macro", "proc_macro2", "quote"], > - cfg=3Dcrates_cfgs["syn"], > ) > =20 > append_crate( > @@ -124,7 +123,6 @@ def generate_crates(srctree, objtree, sysroot_src, ex= ternal_src, cfgs, core_edit > "pin_init_internal", > srctree / "rust" / "pin-init" / "internal" / "src" / "lib.rs", > [], > - cfg=3D["kernel"], > is_proc_macro=3DTrue, > ) > =20 > @@ -132,7 +130,6 @@ def generate_crates(srctree, objtree, sysroot_src, ex= ternal_src, cfgs, core_edit > "pin_init", > srctree / "rust" / "pin-init" / "src" / "lib.rs", > ["core", "pin_init_internal", "macros"], > - cfg=3D["kernel"], > ) > =20 > append_crate(