* [PATCH 0/2] Change Rust Binder crate name to rust_binder
@ 2026-02-24 9:38 Alice Ryhl
2026-02-24 9:38 ` [PATCH 1/2] rust: support overriding crate_name Alice Ryhl
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Alice Ryhl @ 2026-02-24 9:38 UTC (permalink / raw)
To: Miguel Ojeda, Nathan Chancellor, Nicolas Schier
Cc: Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
Andreas Hindborg, Trevor Gross, Danilo Krummrich,
Tamir Duberstein, Jesung Yang, Greg Kroah-Hartman, Carlos Llamas,
linux-kbuild, linux-kernel, rust-for-linux, Alice Ryhl
Currently the crate name of the Rust Binder driver is rust_binder_main,
but I'd like it to be called rust_binder instead. This affects e.g.
symbol names in stack traces.
Thus, introduce a RUST_CRATENAME_stem.o parameter, and set it for Rust
Binder. I tried just using RUSTFLAGS_stem.o and RUSTFLAGS_REMOVE_stem.o,
but RUSTFLAGS_REMOVE_ is incapable of removing the --crate-name
argument. (Even after changing --crate-name to be passed with = instead
of space as the separator to the name.)
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
---
Alice Ryhl (2):
rust: support overriding crate_name
rust_binder: override crate name to rust_binder
drivers/android/binder/Makefile | 1 +
scripts/Makefile.build | 4 +++-
scripts/generate_rust_analyzer.py | 21 ++++++++++++++++++---
3 files changed, 22 insertions(+), 4 deletions(-)
---
base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f
change-id: 20260224-binder-crate-name-15f14e134fca
Best regards,
--
Alice Ryhl <aliceryhl@google.com>
^ permalink raw reply [flat|nested] 10+ messages in thread* [PATCH 1/2] rust: support overriding crate_name 2026-02-24 9:38 [PATCH 0/2] Change Rust Binder crate name to rust_binder Alice Ryhl @ 2026-02-24 9:38 ` Alice Ryhl 2026-02-24 9:38 ` [PATCH 2/2] rust_binder: override crate name to rust_binder Alice Ryhl 2026-02-24 13:24 ` [PATCH 0/2] Change Rust Binder " Miguel Ojeda 2 siblings, 0 replies; 10+ messages in thread From: Alice Ryhl @ 2026-02-24 9:38 UTC (permalink / raw) To: Miguel Ojeda, Nathan Chancellor, Nicolas Schier Cc: Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg, Trevor Gross, Danilo Krummrich, Tamir Duberstein, Jesung Yang, Greg Kroah-Hartman, Carlos Llamas, linux-kbuild, linux-kernel, rust-for-linux, Alice Ryhl 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, add a RUST_CRATENAME_ option to make this possible. The logic for getting the crate name in generate_rust_analyzer.py is a bit hacky, but I'm not sure how to do it otherwise. Signed-off-by: Alice Ryhl <aliceryhl@google.com> --- scripts/Makefile.build | 4 +++- scripts/generate_rust_analyzer.py | 21 ++++++++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 32e209bc7985..dea8320e5bde 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -324,6 +324,8 @@ rust_allowed_features := asm_const,asm_goto,arbitrary_self_types,lint_reasons,of # `--out-dir` is required to avoid temporaries being created by `rustc` in the # current working directory, which may be not accessible in the out-of-tree # modules case. +rust_cratename = $(if $(RUST_CRATENAME_$(target-stem).o),$(RUST_CRATENAME_$(target-stem).o),$(basename $(notdir $@))) + rust_common_cmd = \ OBJTREE=$(abspath $(objtree)) \ RUST_MODFILE=$(modfile) $(RUSTC_OR_CLIPPY) $(rust_flags) \ @@ -332,7 +334,7 @@ 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 $@)) \ + --crate-name $(rust_cratename) \ --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..4126acdc03ec 100755 --- a/scripts/generate_rust_analyzer.py +++ b/scripts/generate_rust_analyzer.py @@ -8,6 +8,7 @@ import json import logging import os import pathlib +import re import subprocess import sys @@ -194,6 +195,16 @@ def generate_crates(srctree, objtree, sysroot_src, external_src, cfgs, core_edit except FileNotFoundError: return False + def get_crate_name(build_file, target): + try: + contents = build_file.read_text() + match = re.search(rf'RUST_CRATENAME_{target}\.o\s*[:=]+\s*(\w+)', contents) + if match: + return match.group(1) + except FileNotFoundError: + pass + return target + # Then, the rest outside of `rust/`. # # We explicitly mention the top-level folders we want to cover. @@ -206,13 +217,17 @@ def generate_crates(srctree, objtree, sysroot_src, external_src, cfgs, core_edit name = path.name.replace(".rs", "") # Skip those that are not crate roots. - if not is_root_crate(path.parent / "Makefile", name) and \ - not is_root_crate(path.parent / "Kbuild", name): + makefile = path.parent / "Makefile" + kbuild = path.parent / "Kbuild" + if not is_root_crate(makefile, name) and \ + not is_root_crate(kbuild, name): continue logging.info("Adding %s", name) + crate_name = get_crate_name(makefile, name) + append_crate( - name, + crate_name, path, ["core", "kernel", "pin_init"], cfg=cfg, -- 2.53.0.371.g1d285c8824-goog ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/2] rust_binder: override crate name to rust_binder 2026-02-24 9:38 [PATCH 0/2] Change Rust Binder crate name to rust_binder Alice Ryhl 2026-02-24 9:38 ` [PATCH 1/2] rust: support overriding crate_name Alice Ryhl @ 2026-02-24 9:38 ` Alice Ryhl 2026-02-24 13:24 ` [PATCH 0/2] Change Rust Binder " Miguel Ojeda 2 siblings, 0 replies; 10+ messages in thread From: Alice Ryhl @ 2026-02-24 9:38 UTC (permalink / raw) To: Miguel Ojeda, Nathan Chancellor, Nicolas Schier Cc: Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg, Trevor Gross, Danilo Krummrich, Tamir Duberstein, Jesung Yang, Greg Kroah-Hartman, Carlos Llamas, linux-kbuild, linux-kernel, rust-for-linux, Alice Ryhl The Rust Binder object file is called rust_binder_main.o because the name rust_binder.o is used for the result of linking together rust_binder_main.o with rust_binderfs.o and a few others. However, the crate name is supposed to be rust_binder without a _main suffix. Thus, override the crate name accordingly. Signed-off-by: Alice Ryhl <aliceryhl@google.com> --- drivers/android/binder/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/android/binder/Makefile b/drivers/android/binder/Makefile index 09eabb527fa0..a28d737d27f4 100644 --- a/drivers/android/binder/Makefile +++ b/drivers/android/binder/Makefile @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only ccflags-y += -I$(src) # needed for trace events +RUST_CRATENAME_rust_binder_main.o := rust_binder obj-$(CONFIG_ANDROID_BINDER_IPC_RUST) += rust_binder.o rust_binder-y := \ rust_binder_main.o \ -- 2.53.0.371.g1d285c8824-goog ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 0/2] Change Rust Binder crate name to rust_binder 2026-02-24 9:38 [PATCH 0/2] Change Rust Binder crate name to rust_binder Alice Ryhl 2026-02-24 9:38 ` [PATCH 1/2] rust: support overriding crate_name Alice Ryhl 2026-02-24 9:38 ` [PATCH 2/2] rust_binder: override crate name to rust_binder Alice Ryhl @ 2026-02-24 13:24 ` Miguel Ojeda 2026-02-24 15:17 ` Alice Ryhl 2 siblings, 1 reply; 10+ messages in thread From: Miguel Ojeda @ 2026-02-24 13:24 UTC (permalink / raw) To: Alice Ryhl Cc: Miguel Ojeda, Nathan Chancellor, Nicolas Schier, Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg, Trevor Gross, Danilo Krummrich, Tamir Duberstein, Jesung Yang, Greg Kroah-Hartman, Carlos Llamas, linux-kbuild, linux-kernel, rust-for-linux On Tue, Feb 24, 2026 at 10:38 AM Alice Ryhl <aliceryhl@google.com> wrote: > > Currently the crate name of the Rust Binder driver is rust_binder_main, > but I'd like it to be called rust_binder instead. This affects e.g. > symbol names in stack traces. We discussed allowing to customize crate names years ago, at least for dashes vs. underscores, for matching C names more closely and perhaps other needs. Back then, we decided to keep things simple to avoid confusion (i.e. a single identifier used everywhere the same way is simpler, at least for humans) and to avoid having to deal with those dual names everywhere (e.g. adding workarounds for rust-analyzer here). I talked with Alice about what she needed here -- could we rename that source file to just something like `binder`? That would avoid the need to have a custom name, so everything would still match (symbols, source file, object file...), and it would give you even shorter names. Cheers, Miguel ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 0/2] Change Rust Binder crate name to rust_binder 2026-02-24 13:24 ` [PATCH 0/2] Change Rust Binder " Miguel Ojeda @ 2026-02-24 15:17 ` Alice Ryhl 2026-03-05 10:49 ` Alice Ryhl 0 siblings, 1 reply; 10+ messages in thread From: Alice Ryhl @ 2026-02-24 15:17 UTC (permalink / raw) To: Miguel Ojeda Cc: Miguel Ojeda, Nathan Chancellor, Nicolas Schier, Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg, Trevor Gross, Danilo Krummrich, Tamir Duberstein, Jesung Yang, Greg Kroah-Hartman, Carlos Llamas, linux-kbuild, linux-kernel, rust-for-linux On Tue, Feb 24, 2026 at 02:24:59PM +0100, Miguel Ojeda wrote: > On Tue, Feb 24, 2026 at 10:38 AM Alice Ryhl <aliceryhl@google.com> wrote: > > > > Currently the crate name of the Rust Binder driver is rust_binder_main, > > but I'd like it to be called rust_binder instead. This affects e.g. > > symbol names in stack traces. > > We discussed allowing to customize crate names years ago, at least for > dashes vs. underscores, for matching C names more closely and perhaps > other needs. > > Back then, we decided to keep things simple to avoid confusion (i.e. a > single identifier used everywhere the same way is simpler, at least > for humans) and to avoid having to deal with those dual names > everywhere (e.g. adding workarounds for rust-analyzer here). > > I talked with Alice about what she needed here -- could we rename that > source file to just something like `binder`? That would avoid the need > to have a custom name, so everything would still match (symbols, > source file, object file...), and it would give you even shorter > names. Sure just renaming rust_binder_main.rs to binder.rs would work too. Alice ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 0/2] Change Rust Binder crate name to rust_binder 2026-02-24 15:17 ` Alice Ryhl @ 2026-03-05 10:49 ` Alice Ryhl 2026-03-05 12:17 ` Gary Guo 0 siblings, 1 reply; 10+ messages in thread From: Alice Ryhl @ 2026-03-05 10:49 UTC (permalink / raw) To: Miguel Ojeda Cc: Miguel Ojeda, Nathan Chancellor, Nicolas Schier, Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg, Trevor Gross, Danilo Krummrich, Tamir Duberstein, Jesung Yang, Greg Kroah-Hartman, Carlos Llamas, linux-kbuild, linux-kernel, rust-for-linux On Tue, Feb 24, 2026 at 03:17:16PM +0000, Alice Ryhl wrote: > On Tue, Feb 24, 2026 at 02:24:59PM +0100, Miguel Ojeda wrote: > > On Tue, Feb 24, 2026 at 10:38 AM Alice Ryhl <aliceryhl@google.com> wrote: > > > > > > Currently the crate name of the Rust Binder driver is rust_binder_main, > > > but I'd like it to be called rust_binder instead. This affects e.g. > > > symbol names in stack traces. > > > > We discussed allowing to customize crate names years ago, at least for > > dashes vs. underscores, for matching C names more closely and perhaps > > other needs. > > > > Back then, we decided to keep things simple to avoid confusion (i.e. a > > single identifier used everywhere the same way is simpler, at least > > for humans) and to avoid having to deal with those dual names > > everywhere (e.g. adding workarounds for rust-analyzer here). > > > > I talked with Alice about what she needed here -- could we rename that > > source file to just something like `binder`? That would avoid the need > > to have a custom name, so everything would still match (symbols, > > source file, object file...), and it would give you even shorter > > names. > > Sure just renaming rust_binder_main.rs to binder.rs would work too. I realized that there's a much simpler way to allow crates to rename themselves: do not pass the --crate-name argument at all. Because if you do not pass this argument, then rustc will use the name of the .rs file as the crate name by default, *but* if the crate contains #![crate_name = "..."], then that will be used instead. Do you still want to enforce that the crate name always matches the file name? It seems unfortunate that it's currently impossible to create a Rust module where the .ko file and crate name is the same, unless no extra object files are linked into the module. Alice ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 0/2] Change Rust Binder crate name to rust_binder 2026-03-05 10:49 ` Alice Ryhl @ 2026-03-05 12:17 ` Gary Guo 2026-03-05 12:27 ` Alice Ryhl 0 siblings, 1 reply; 10+ messages in thread From: Gary Guo @ 2026-03-05 12:17 UTC (permalink / raw) To: Alice Ryhl, Miguel Ojeda Cc: Miguel Ojeda, Nathan Chancellor, Nicolas Schier, Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg, Trevor Gross, Danilo Krummrich, Tamir Duberstein, Jesung Yang, Greg Kroah-Hartman, Carlos Llamas, linux-kbuild, linux-kernel, rust-for-linux On Thu Mar 5, 2026 at 10:49 AM GMT, Alice Ryhl wrote: > On Tue, Feb 24, 2026 at 03:17:16PM +0000, Alice Ryhl wrote: >> On Tue, Feb 24, 2026 at 02:24:59PM +0100, Miguel Ojeda wrote: >> > On Tue, Feb 24, 2026 at 10:38 AM Alice Ryhl <aliceryhl@google.com> wrote: >> > > >> > > Currently the crate name of the Rust Binder driver is rust_binder_main, >> > > but I'd like it to be called rust_binder instead. This affects e.g. >> > > symbol names in stack traces. >> > >> > We discussed allowing to customize crate names years ago, at least for >> > dashes vs. underscores, for matching C names more closely and perhaps >> > other needs. >> > >> > Back then, we decided to keep things simple to avoid confusion (i.e. a >> > single identifier used everywhere the same way is simpler, at least >> > for humans) and to avoid having to deal with those dual names >> > everywhere (e.g. adding workarounds for rust-analyzer here). >> > >> > I talked with Alice about what she needed here -- could we rename that >> > source file to just something like `binder`? That would avoid the need >> > to have a custom name, so everything would still match (symbols, >> > source file, object file...), and it would give you even shorter >> > names. >> >> Sure just renaming rust_binder_main.rs to binder.rs would work too. > > I realized that there's a much simpler way to allow crates to rename > themselves: do not pass the --crate-name argument at all. > > Because if you do not pass this argument, then rustc will use the > name of the .rs file as the crate name by default, *but* if the crate > contains #![crate_name = "..."], then that will be used instead. > > Do you still want to enforce that the crate name always matches the > file name? It seems unfortunate that it's currently impossible to create > a Rust module where the .ko file and crate name is the same, unless no > extra object files are linked into the module. I think previously a fixed crate name is load-bearing because we need rustc to emit outputs to a fixed location. This shouldn't be needed after commit 295d8398c67e ("kbuild: specify output names separately for each emission type from rustc"), so if nothing breaks with `--crate-name` removed, then I think it makes sense to drop it to allow custom rustflags to override them. Best, Gary ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 0/2] Change Rust Binder crate name to rust_binder 2026-03-05 12:17 ` Gary Guo @ 2026-03-05 12:27 ` Alice Ryhl 2026-03-05 12:34 ` Gary Guo 0 siblings, 1 reply; 10+ messages in thread From: Alice Ryhl @ 2026-03-05 12:27 UTC (permalink / raw) To: Gary Guo Cc: Miguel Ojeda, Miguel Ojeda, Nathan Chancellor, Nicolas Schier, Boqun Feng, Björn Roy Baron, Benno Lossin, Andreas Hindborg, Trevor Gross, Danilo Krummrich, Tamir Duberstein, Jesung Yang, Greg Kroah-Hartman, Carlos Llamas, linux-kbuild, linux-kernel, rust-for-linux On Thu, Mar 05, 2026 at 12:17:52PM +0000, Gary Guo wrote: > On Thu Mar 5, 2026 at 10:49 AM GMT, Alice Ryhl wrote: > > On Tue, Feb 24, 2026 at 03:17:16PM +0000, Alice Ryhl wrote: > >> On Tue, Feb 24, 2026 at 02:24:59PM +0100, Miguel Ojeda wrote: > >> > On Tue, Feb 24, 2026 at 10:38 AM Alice Ryhl <aliceryhl@google.com> wrote: > >> > > > >> > > Currently the crate name of the Rust Binder driver is rust_binder_main, > >> > > but I'd like it to be called rust_binder instead. This affects e.g. > >> > > symbol names in stack traces. > >> > > >> > We discussed allowing to customize crate names years ago, at least for > >> > dashes vs. underscores, for matching C names more closely and perhaps > >> > other needs. > >> > > >> > Back then, we decided to keep things simple to avoid confusion (i.e. a > >> > single identifier used everywhere the same way is simpler, at least > >> > for humans) and to avoid having to deal with those dual names > >> > everywhere (e.g. adding workarounds for rust-analyzer here). > >> > > >> > I talked with Alice about what she needed here -- could we rename that > >> > source file to just something like `binder`? That would avoid the need > >> > to have a custom name, so everything would still match (symbols, > >> > source file, object file...), and it would give you even shorter > >> > names. > >> > >> Sure just renaming rust_binder_main.rs to binder.rs would work too. > > > > I realized that there's a much simpler way to allow crates to rename > > themselves: do not pass the --crate-name argument at all. > > > > Because if you do not pass this argument, then rustc will use the > > name of the .rs file as the crate name by default, *but* if the crate > > contains #![crate_name = "..."], then that will be used instead. > > > > Do you still want to enforce that the crate name always matches the > > file name? It seems unfortunate that it's currently impossible to create > > a Rust module where the .ko file and crate name is the same, unless no > > extra object files are linked into the module. > > I think previously a fixed crate name is load-bearing because we need rustc to > emit outputs to a fixed location. > > This shouldn't be needed after commit 295d8398c67e ("kbuild: specify output > names separately for each emission type from rustc"), so if nothing breaks with > `--crate-name` removed, then I think it makes sense to drop it to allow custom > rustflags to override them. Are you sure? I know this commit shows up in blame, but it just adds a backslash to the --crate-name argument. I do not believe that omitting --crate-name changes anything in cases where the crate name already matches the file name. Alice ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 0/2] Change Rust Binder crate name to rust_binder 2026-03-05 12:27 ` Alice Ryhl @ 2026-03-05 12:34 ` Gary Guo 2026-03-05 12:44 ` Alice Ryhl 0 siblings, 1 reply; 10+ messages in thread From: Gary Guo @ 2026-03-05 12:34 UTC (permalink / raw) To: Alice Ryhl, Gary Guo Cc: Miguel Ojeda, Miguel Ojeda, Nathan Chancellor, Nicolas Schier, Boqun Feng, Björn Roy Baron, Benno Lossin, Andreas Hindborg, Trevor Gross, Danilo Krummrich, Tamir Duberstein, Jesung Yang, Greg Kroah-Hartman, Carlos Llamas, linux-kbuild, linux-kernel, rust-for-linux On Thu Mar 5, 2026 at 12:27 PM GMT, Alice Ryhl wrote: > On Thu, Mar 05, 2026 at 12:17:52PM +0000, Gary Guo wrote: >> On Thu Mar 5, 2026 at 10:49 AM GMT, Alice Ryhl wrote: >> > On Tue, Feb 24, 2026 at 03:17:16PM +0000, Alice Ryhl wrote: >> >> On Tue, Feb 24, 2026 at 02:24:59PM +0100, Miguel Ojeda wrote: >> >> > On Tue, Feb 24, 2026 at 10:38 AM Alice Ryhl <aliceryhl@google.com> wrote: >> >> > > >> >> > > Currently the crate name of the Rust Binder driver is rust_binder_main, >> >> > > but I'd like it to be called rust_binder instead. This affects e.g. >> >> > > symbol names in stack traces. >> >> > >> >> > We discussed allowing to customize crate names years ago, at least for >> >> > dashes vs. underscores, for matching C names more closely and perhaps >> >> > other needs. >> >> > >> >> > Back then, we decided to keep things simple to avoid confusion (i.e. a >> >> > single identifier used everywhere the same way is simpler, at least >> >> > for humans) and to avoid having to deal with those dual names >> >> > everywhere (e.g. adding workarounds for rust-analyzer here). >> >> > >> >> > I talked with Alice about what she needed here -- could we rename that >> >> > source file to just something like `binder`? That would avoid the need >> >> > to have a custom name, so everything would still match (symbols, >> >> > source file, object file...), and it would give you even shorter >> >> > names. >> >> >> >> Sure just renaming rust_binder_main.rs to binder.rs would work too. >> > >> > I realized that there's a much simpler way to allow crates to rename >> > themselves: do not pass the --crate-name argument at all. >> > >> > Because if you do not pass this argument, then rustc will use the >> > name of the .rs file as the crate name by default, *but* if the crate >> > contains #![crate_name = "..."], then that will be used instead. >> > >> > Do you still want to enforce that the crate name always matches the >> > file name? It seems unfortunate that it's currently impossible to create >> > a Rust module where the .ko file and crate name is the same, unless no >> > extra object files are linked into the module. >> >> I think previously a fixed crate name is load-bearing because we need rustc to >> emit outputs to a fixed location. >> >> This shouldn't be needed after commit 295d8398c67e ("kbuild: specify output >> names separately for each emission type from rustc"), so if nothing breaks with >> `--crate-name` removed, then I think it makes sense to drop it to allow custom >> rustflags to override them. > > Are you sure? I know this commit shows up in blame, but it just adds a > backslash to the --crate-name argument. > > I do not believe that omitting --crate-name changes anything in cases > where the crate name already matches the file name. Before this change we rely on the crate name to match the file name, otherwise the .d file and .o file will be placed at wrong location and Kbuild cannot find the output files. With this change we specify everything explicitly, so even if you pass `--crate-name=foo`, the object file is still `rust_binder.o` so the build can continue. My point is that you *cannot* reasonably override crate names before this change. Best, Gary ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 0/2] Change Rust Binder crate name to rust_binder 2026-03-05 12:34 ` Gary Guo @ 2026-03-05 12:44 ` Alice Ryhl 0 siblings, 0 replies; 10+ messages in thread From: Alice Ryhl @ 2026-03-05 12:44 UTC (permalink / raw) To: Gary Guo Cc: Miguel Ojeda, Miguel Ojeda, Nathan Chancellor, Nicolas Schier, Boqun Feng, Björn Roy Baron, Benno Lossin, Andreas Hindborg, Trevor Gross, Danilo Krummrich, Tamir Duberstein, Jesung Yang, Greg Kroah-Hartman, Carlos Llamas, linux-kbuild, linux-kernel, rust-for-linux On Thu, Mar 05, 2026 at 12:34:16PM +0000, Gary Guo wrote: > On Thu Mar 5, 2026 at 12:27 PM GMT, Alice Ryhl wrote: > > On Thu, Mar 05, 2026 at 12:17:52PM +0000, Gary Guo wrote: > >> On Thu Mar 5, 2026 at 10:49 AM GMT, Alice Ryhl wrote: > >> > On Tue, Feb 24, 2026 at 03:17:16PM +0000, Alice Ryhl wrote: > >> >> On Tue, Feb 24, 2026 at 02:24:59PM +0100, Miguel Ojeda wrote: > >> >> > On Tue, Feb 24, 2026 at 10:38 AM Alice Ryhl <aliceryhl@google.com> wrote: > >> >> > > > >> >> > > Currently the crate name of the Rust Binder driver is rust_binder_main, > >> >> > > but I'd like it to be called rust_binder instead. This affects e.g. > >> >> > > symbol names in stack traces. > >> >> > > >> >> > We discussed allowing to customize crate names years ago, at least for > >> >> > dashes vs. underscores, for matching C names more closely and perhaps > >> >> > other needs. > >> >> > > >> >> > Back then, we decided to keep things simple to avoid confusion (i.e. a > >> >> > single identifier used everywhere the same way is simpler, at least > >> >> > for humans) and to avoid having to deal with those dual names > >> >> > everywhere (e.g. adding workarounds for rust-analyzer here). > >> >> > > >> >> > I talked with Alice about what she needed here -- could we rename that > >> >> > source file to just something like `binder`? That would avoid the need > >> >> > to have a custom name, so everything would still match (symbols, > >> >> > source file, object file...), and it would give you even shorter > >> >> > names. > >> >> > >> >> Sure just renaming rust_binder_main.rs to binder.rs would work too. > >> > > >> > I realized that there's a much simpler way to allow crates to rename > >> > themselves: do not pass the --crate-name argument at all. > >> > > >> > Because if you do not pass this argument, then rustc will use the > >> > name of the .rs file as the crate name by default, *but* if the crate > >> > contains #![crate_name = "..."], then that will be used instead. > >> > > >> > Do you still want to enforce that the crate name always matches the > >> > file name? It seems unfortunate that it's currently impossible to create > >> > a Rust module where the .ko file and crate name is the same, unless no > >> > extra object files are linked into the module. > >> > >> I think previously a fixed crate name is load-bearing because we need rustc to > >> emit outputs to a fixed location. > >> > >> This shouldn't be needed after commit 295d8398c67e ("kbuild: specify output > >> names separately for each emission type from rustc"), so if nothing breaks with > >> `--crate-name` removed, then I think it makes sense to drop it to allow custom > >> rustflags to override them. > > > > Are you sure? I know this commit shows up in blame, but it just adds a > > backslash to the --crate-name argument. > > > > I do not believe that omitting --crate-name changes anything in cases > > where the crate name already matches the file name. > > Before this change we rely on the crate name to match the file name, otherwise > the .d file and .o file will be placed at wrong location and Kbuild cannot find > the output files. > > With this change we specify everything explicitly, so even if you pass > `--crate-name=foo`, the object file is still `rust_binder.o` so the build can > continue. > > My point is that you *cannot* reasonably override crate names before this > change. Ok I understand now what you're getting at. That commit is required to change the crate name (but it's not required to omit --crate-name without changing what the crate name is). Alice ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2026-03-05 12:45 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-02-24 9:38 [PATCH 0/2] Change Rust Binder crate name to rust_binder Alice Ryhl 2026-02-24 9:38 ` [PATCH 1/2] rust: support overriding crate_name Alice Ryhl 2026-02-24 9:38 ` [PATCH 2/2] rust_binder: override crate name to rust_binder Alice Ryhl 2026-02-24 13:24 ` [PATCH 0/2] Change Rust Binder " Miguel Ojeda 2026-02-24 15:17 ` Alice Ryhl 2026-03-05 10:49 ` Alice Ryhl 2026-03-05 12:17 ` Gary Guo 2026-03-05 12:27 ` Alice Ryhl 2026-03-05 12:34 ` Gary Guo 2026-03-05 12:44 ` Alice Ryhl
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox