From: Alice Ryhl <aliceryhl@google.com>
To: Miguel Ojeda <ojeda@kernel.org>,
Tamir Duberstein <tamird@kernel.org>,
Nathan Chancellor <nathan@kernel.org>,
Nicolas Schier <nsc@kernel.org>
Cc: "Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
"Jesung Yang" <y.j3ms.n@gmail.com>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Carlos Llamas" <cmllamas@google.com>,
linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org,
rust-for-linux@vger.kernel.org
Subject: Re: [PATCH v2 1/2] rust: support overriding crate_name
Date: Tue, 10 Mar 2026 15:05:48 +0000 [thread overview]
Message-ID: <abAzTFLYsUxK7VJ6@google.com> (raw)
In-Reply-To: <20260310-binder-crate-name-v2-1-0f7c97900d36@google.com>
On Tue, Mar 10, 2026 at 02:53:40PM +0000, Alice Ryhl wrote:
> Currently you cannot filter out the crate-name argument
> RUSTFLAGS_REMOVE_stem.o because the Rust filter-out invocation does not
> include that particular argument. Since --crate-name is an argument that
> can't be passed multiple times, this means that it's currently not
> possible to override the crate name. Thus, remove the --crate-name
> argument for drivers. This allows them to override the crate name using
> the #![crate_name] annotation.
>
> The --crate-name argument is kept for the crates under rust/ for
> simplicity and to avoid changing many of them by adding #![crate_name].
>
> The rust analyzer script is updated to use rustc to obtain the crate
> name of the driver crates, which picks up the right name when it is
> configured via #![crate_name] or not.
>
> Note that the crate name in the python script is not actually that
> important - the only place where the name actually affects anything is
> in the 'deps' array which specifies an index and name for each
> dependency, and determines what that dependency is called in *this*
> crate. (The same crate may be called different things in each
> dependency.) Since driver crates are leaf crates, this doesn't apply and
> the rustc invocation only affects the 'display_name' parameter.
>
> Signed-off-by: Alice Ryhl <aliceryhl@google.com>
> ---
> scripts/Makefile.build | 1 -
> scripts/generate_rust_analyzer.py | 8 +++++++-
> 2 files changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/scripts/Makefile.build b/scripts/Makefile.build
> index 32e209bc7985..adc3e2d1ac78 100644
> --- a/scripts/Makefile.build
> +++ b/scripts/Makefile.build
> @@ -332,7 +332,6 @@ rust_common_cmd = \
> -Zcrate-attr='feature($(rust_allowed_features))' \
> -Zunstable-options --extern pin_init --extern kernel \
> --crate-type rlib -L $(objtree)/rust/ \
> - --crate-name $(basename $(notdir $@)) \
> --sysroot=/dev/null \
> --out-dir $(dir $@) --emit=dep-info=$(depfile)
>
> diff --git a/scripts/generate_rust_analyzer.py b/scripts/generate_rust_analyzer.py
> index f9b545104f21..d25bc3d7e719 100755
> --- a/scripts/generate_rust_analyzer.py
> +++ b/scripts/generate_rust_analyzer.py
> @@ -194,6 +194,12 @@ def generate_crates(srctree, objtree, sysroot_src, external_src, cfgs, core_edit
> except FileNotFoundError:
> return False
>
> + def get_crate_name(path):
> + return subprocess.check_output(
> + [os.environ["RUSTC"], "--print", "crate-name", path],
> + stdin=subprocess.DEVNULL,
> + ).decode('utf-8').strip()
> +
> # Then, the rest outside of `rust/`.
> #
> # We explicitly mention the top-level folders we want to cover.
> @@ -212,7 +218,7 @@ def generate_crates(srctree, objtree, sysroot_src, external_src, cfgs, core_edit
>
> logging.info("Adding %s", name)
Actually I guess we might want get_crate_name(path) here (or just path).
But the other uses of 'name' should stay as-is.
> append_crate(
> - name,
> + get_crate_name(path),
> path,
> ["core", "kernel", "pin_init"],
> cfg=cfg,
>
> --
> 2.53.0.473.g4a7958ca14-goog
>
next prev parent reply other threads:[~2026-03-10 15:05 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-10 14:53 [PATCH v2 0/2] Change Rust Binder crate name to rust_binder Alice Ryhl
2026-03-10 14:53 ` [PATCH v2 1/2] rust: support overriding crate_name Alice Ryhl
2026-03-10 15:05 ` Alice Ryhl [this message]
2026-03-10 15:45 ` Tamir Duberstein
2026-03-10 19:13 ` Miguel Ojeda
2026-03-10 19:38 ` Tamir Duberstein
2026-03-10 19:58 ` Alice Ryhl
2026-03-10 19:58 ` Miguel Ojeda
2026-03-10 20:01 ` Miguel Ojeda
2026-03-10 20:27 ` Tamir Duberstein
2026-03-10 22:36 ` Gary Guo
2026-03-10 14:53 ` [PATCH v2 2/2] rust_binder: override crate name to rust_binder Alice Ryhl
2026-03-10 19:10 ` Miguel Ojeda
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=abAzTFLYsUxK7VJ6@google.com \
--to=aliceryhl@google.com \
--cc=a.hindborg@kernel.org \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=cmllamas@google.com \
--cc=dakr@kernel.org \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=nathan@kernel.org \
--cc=nsc@kernel.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tamird@kernel.org \
--cc=tmgross@umich.edu \
--cc=y.j3ms.n@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox