* [PATCH v3] rust: remove spurious compiler_builtins dependents
@ 2025-07-20 17:20 Tamir Duberstein
2025-07-21 5:54 ` kernel test robot
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Tamir Duberstein @ 2025-07-20 17:20 UTC (permalink / raw)
To: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Danilo Krummrich
Cc: rust-for-linux, linux-kernel, Tamir Duberstein
The dependency on `compiler_builtins.o` was first added in commit
2f7ab1267dc9 ("Kbuild: add Rust support") to `alloc` which matches the
standard library[0] but was copied to other targets in:
- commit ecaa6ddff2fd ("rust: add `build_error` crate")
- commit d072acda4862 ("rust: use custom FFI integer types")
- commit 4e1746656839 ("rust: uapi: Add UAPI crate")
- commit d7659acca7a3 ("rust: add pin-init crate build infrastructure")
The alloc crate was removed in commit 392e34b6bc22 ("kbuild: rust:
remove the `alloc` crate and `GlobalAlloc`"). As far as I can tell none
of the other dependencies are required; it is only required that
compiler_builtins be linked into the rust-enabled kernel. In the
standard library, compiler_builtins is a dependency of std[1].
Remove these dependency edges. Add a dependency edge from
`compiler_builtins` to `core` to `scripts/generate_rust_analyzer.py` to
match `rust/Makefile`. This has been incorrect since commit 8c4555ccc55c
("scripts: add `generate_rust_analyzer.py`")
Link: https://github.com/rust-lang/rust/blob/f820b75feef00654924c9351a2faca8d34818339/library/alloc/Cargo.toml#L19 [0]
Link: https://github.com/rust-lang/rust/blob/f820b75feef00654924c9351a2faca8d34818339/library/std/Cargo.toml#L21 [1]
Link: https://rust-for-linux.zulipchat.com/#narrow/channel/288089-General/topic/rust-analyzer.20improvements/near/510200959
Signed-off-by: Tamir Duberstein <tamird@gmail.com>
---
Changes in v3:
- Fix typo in commit message (fas -> far).
- Link to v2: https://lore.kernel.org/r/20250524-rust-remove-compiler-builtins-deps-v2-1-4fc2ff489391@gmail.com
Changes in v2:
- Rebase on rust-fixes to include "scripts: generate_rust_analyzer: Add
ffi crate".
- Link to v1: https://lore.kernel.org/r/20250408-rust-remove-compiler-builtins-deps-v1-1-4fda4f187190@gmail.com
---
rust/Makefile | 6 +++---
scripts/generate_rust_analyzer.py | 6 +++---
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/rust/Makefile b/rust/Makefile
index 27dec7904c3a..5a6a381bc23d 100644
--- a/rust/Makefile
+++ b/rust/Makefile
@@ -505,16 +505,16 @@ $(obj)/compiler_builtins.o: $(src)/compiler_builtins.rs $(obj)/core.o FORCE
$(obj)/pin_init.o: private skip_gendwarfksyms = 1
$(obj)/pin_init.o: private rustc_target_flags = --extern pin_init_internal \
--extern macros --cfg kernel
-$(obj)/pin_init.o: $(src)/pin-init/src/lib.rs $(obj)/compiler_builtins.o \
+$(obj)/pin_init.o: $(src)/pin-init/src/lib.rs \
$(obj)/$(libpin_init_internal_name) $(obj)/$(libmacros_name) FORCE
+$(call if_changed_rule,rustc_library)
$(obj)/build_error.o: private skip_gendwarfksyms = 1
-$(obj)/build_error.o: $(src)/build_error.rs $(obj)/compiler_builtins.o FORCE
+$(obj)/build_error.o: $(src)/build_error.rs FORCE
+$(call if_changed_rule,rustc_library)
$(obj)/ffi.o: private skip_gendwarfksyms = 1
-$(obj)/ffi.o: $(src)/ffi.rs $(obj)/compiler_builtins.o FORCE
+$(obj)/ffi.o: $(src)/ffi.rs FORCE
+$(call if_changed_rule,rustc_library)
$(obj)/bindings.o: private rustc_target_flags = --extern ffi
diff --git a/scripts/generate_rust_analyzer.py b/scripts/generate_rust_analyzer.py
index 7c3ea2b55041..cab9a80bed49 100755
--- a/scripts/generate_rust_analyzer.py
+++ b/scripts/generate_rust_analyzer.py
@@ -83,7 +83,7 @@ def generate_crates(srctree, objtree, sysroot_src, external_src, cfgs, core_edit
append_crate(
"compiler_builtins",
srctree / "rust" / "compiler_builtins.rs",
- [],
+ ["core"],
)
append_crate(
@@ -96,7 +96,7 @@ def generate_crates(srctree, objtree, sysroot_src, external_src, cfgs, core_edit
append_crate(
"build_error",
srctree / "rust" / "build_error.rs",
- ["core", "compiler_builtins"],
+ ["core"],
)
append_crate(
@@ -117,7 +117,7 @@ def generate_crates(srctree, objtree, sysroot_src, external_src, cfgs, core_edit
append_crate(
"ffi",
srctree / "rust" / "ffi.rs",
- ["core", "compiler_builtins"],
+ ["core"],
)
def append_crate_with_generated(
---
base-commit: cc84ef3b88f407e8bd5a5f7b6906d1e69851c856
change-id: 20250408-rust-remove-compiler-builtins-deps-1f061024dfce
Best regards,
--
Tamir Duberstein <tamird@gmail.com>
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v3] rust: remove spurious compiler_builtins dependents
2025-07-20 17:20 [PATCH v3] rust: remove spurious compiler_builtins dependents Tamir Duberstein
@ 2025-07-21 5:54 ` kernel test robot
2025-07-21 11:56 ` Alice Ryhl
2025-07-21 12:25 ` Miguel Ojeda
2 siblings, 0 replies; 7+ messages in thread
From: kernel test robot @ 2025-07-21 5:54 UTC (permalink / raw)
To: Tamir Duberstein, Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Danilo Krummrich
Cc: llvm, oe-kbuild-all, rust-for-linux, linux-kernel,
Tamir Duberstein
Hi Tamir,
kernel test robot noticed the following build errors:
[auto build test ERROR on cc84ef3b88f407e8bd5a5f7b6906d1e69851c856]
url: https://github.com/intel-lab-lkp/linux/commits/Tamir-Duberstein/rust-remove-spurious-compiler_builtins-dependents/20250721-012236
base: cc84ef3b88f407e8bd5a5f7b6906d1e69851c856
patch link: https://lore.kernel.org/r/20250720-rust-remove-compiler-builtins-deps-v3-1-0df3a493973f%40gmail.com
patch subject: [PATCH v3] rust: remove spurious compiler_builtins dependents
config: x86_64-rhel-9.4-rust (https://download.01.org/0day-ci/archive/20250721/202507211312.M1fkG8v8-lkp@intel.com/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
rustc: rustc 1.88.0 (6b00bc388 2025-06-23)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250721/202507211312.M1fkG8v8-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202507211312.M1fkG8v8-lkp@intel.com/
All errors (new ones prefixed by >>):
>> error[E0463]: can't find crate for `core`
|
= note: the `target` target may not be installed
= help: consider downloading the target with `rustup target add target`
= help: consider building the standard library from source with `cargo build -Zbuild-std`
--
For more information about this error, try `rustc --explain E0463`.
make[3]: *** [rust/Makefile:514: rust/build_error.o] Error 1
>> error[E0463]: can't find crate for `core`
|
= note: the `target` target may not be installed
= help: consider downloading the target with `rustup target add target`
= help: consider building the standard library from source with `cargo build -Zbuild-std`
--
For more information about this error, try `rustc --explain E0463`.
make[3]: *** [rust/Makefile:518: rust/ffi.o] Error 1
>> error[E0463]: can't find crate for `core`
|
= note: the `target` target may not be installed
= help: consider downloading the target with `rustup target add target`
= help: consider building the standard library from source with `cargo build -Zbuild-std`
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3] rust: remove spurious compiler_builtins dependents
2025-07-20 17:20 [PATCH v3] rust: remove spurious compiler_builtins dependents Tamir Duberstein
2025-07-21 5:54 ` kernel test robot
@ 2025-07-21 11:56 ` Alice Ryhl
2025-07-21 12:25 ` Miguel Ojeda
2 siblings, 0 replies; 7+ messages in thread
From: Alice Ryhl @ 2025-07-21 11:56 UTC (permalink / raw)
To: Tamir Duberstein
Cc: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Trevor Gross, Danilo Krummrich, rust-for-linux, linux-kernel
On Sun, Jul 20, 2025 at 01:20:40PM -0400, Tamir Duberstein wrote:
> The dependency on `compiler_builtins.o` was first added in commit
> 2f7ab1267dc9 ("Kbuild: add Rust support") to `alloc` which matches the
> standard library[0] but was copied to other targets in:
> - commit ecaa6ddff2fd ("rust: add `build_error` crate")
> - commit d072acda4862 ("rust: use custom FFI integer types")
> - commit 4e1746656839 ("rust: uapi: Add UAPI crate")
> - commit d7659acca7a3 ("rust: add pin-init crate build infrastructure")
>
> The alloc crate was removed in commit 392e34b6bc22 ("kbuild: rust:
> remove the `alloc` crate and `GlobalAlloc`"). As far as I can tell none
> of the other dependencies are required; it is only required that
> compiler_builtins be linked into the rust-enabled kernel. In the
> standard library, compiler_builtins is a dependency of std[1].
>
> Remove these dependency edges. Add a dependency edge from
> `compiler_builtins` to `core` to `scripts/generate_rust_analyzer.py` to
> match `rust/Makefile`. This has been incorrect since commit 8c4555ccc55c
> ("scripts: add `generate_rust_analyzer.py`")
>
> Link: https://github.com/rust-lang/rust/blob/f820b75feef00654924c9351a2faca8d34818339/library/alloc/Cargo.toml#L19 [0]
> Link: https://github.com/rust-lang/rust/blob/f820b75feef00654924c9351a2faca8d34818339/library/std/Cargo.toml#L21 [1]
> Link: https://rust-for-linux.zulipchat.com/#narrow/channel/288089-General/topic/rust-analyzer.20improvements/near/510200959
> Signed-off-by: Tamir Duberstein <tamird@gmail.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3] rust: remove spurious compiler_builtins dependents
2025-07-20 17:20 [PATCH v3] rust: remove spurious compiler_builtins dependents Tamir Duberstein
2025-07-21 5:54 ` kernel test robot
2025-07-21 11:56 ` Alice Ryhl
@ 2025-07-21 12:25 ` Miguel Ojeda
2025-07-23 15:18 ` Tamir Duberstein
2 siblings, 1 reply; 7+ messages in thread
From: Miguel Ojeda @ 2025-07-21 12:25 UTC (permalink / raw)
To: Tamir Duberstein
Cc: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Danilo Krummrich, rust-for-linux, linux-kernel
On Sun, Jul 20, 2025 at 7:20 PM Tamir Duberstein <tamird@gmail.com> wrote:
>
> Remove these dependency edges.
I should have replied in previous versions: this is wrong -- the 3
changes each individually break the build.
I guess that you are not cleaning everything in your tests before
testing the build.
Cheers,
Miguel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3] rust: remove spurious compiler_builtins dependents
2025-07-21 12:25 ` Miguel Ojeda
@ 2025-07-23 15:18 ` Tamir Duberstein
2025-07-23 19:53 ` Benno Lossin
0 siblings, 1 reply; 7+ messages in thread
From: Tamir Duberstein @ 2025-07-23 15:18 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Danilo Krummrich, rust-for-linux, linux-kernel
On Mon, Jul 21, 2025 at 8:25 AM Miguel Ojeda
<miguel.ojeda.sandonis@gmail.com> wrote:
>
> On Sun, Jul 20, 2025 at 7:20 PM Tamir Duberstein <tamird@gmail.com> wrote:
> >
> > Remove these dependency edges.
>
> I should have replied in previous versions: this is wrong -- the 3
> changes each individually break the build.
>
> I guess that you are not cleaning everything in your tests before
> testing the build.
You're absolutely right, this patch is incorrect. I was indeed not
blowing away build artifcats.
Thanks Miguel.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3] rust: remove spurious compiler_builtins dependents
2025-07-23 15:18 ` Tamir Duberstein
@ 2025-07-23 19:53 ` Benno Lossin
2025-07-23 20:12 ` Tamir Duberstein
0 siblings, 1 reply; 7+ messages in thread
From: Benno Lossin @ 2025-07-23 19:53 UTC (permalink / raw)
To: Tamir Duberstein, Miguel Ojeda
Cc: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Andreas Hindborg, Alice Ryhl, Trevor Gross,
Danilo Krummrich, rust-for-linux, linux-kernel
On Wed Jul 23, 2025 at 5:18 PM CEST, Tamir Duberstein wrote:
> On Mon, Jul 21, 2025 at 8:25 AM Miguel Ojeda
> <miguel.ojeda.sandonis@gmail.com> wrote:
>>
>> On Sun, Jul 20, 2025 at 7:20 PM Tamir Duberstein <tamird@gmail.com> wrote:
>> >
>> > Remove these dependency edges.
>>
>> I should have replied in previous versions: this is wrong -- the 3
>> changes each individually break the build.
>>
>> I guess that you are not cleaning everything in your tests before
>> testing the build.
>
> You're absolutely right, this patch is incorrect. I was indeed not
> blowing away build artifcats.
So is the `compiler_builtins` dependency correct for all crates?
---
Cheers,
Benno
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3] rust: remove spurious compiler_builtins dependents
2025-07-23 19:53 ` Benno Lossin
@ 2025-07-23 20:12 ` Tamir Duberstein
0 siblings, 0 replies; 7+ messages in thread
From: Tamir Duberstein @ 2025-07-23 20:12 UTC (permalink / raw)
To: Benno Lossin
Cc: Miguel Ojeda, Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Andreas Hindborg, Alice Ryhl, Trevor Gross,
Danilo Krummrich, rust-for-linux, linux-kernel
On Wed, Jul 23, 2025 at 3:53 PM Benno Lossin <lossin@kernel.org> wrote:
>
> On Wed Jul 23, 2025 at 5:18 PM CEST, Tamir Duberstein wrote:
> > On Mon, Jul 21, 2025 at 8:25 AM Miguel Ojeda
> > <miguel.ojeda.sandonis@gmail.com> wrote:
> >>
> >> On Sun, Jul 20, 2025 at 7:20 PM Tamir Duberstein <tamird@gmail.com> wrote:
> >> >
> >> > Remove these dependency edges.
> >>
> >> I should have replied in previous versions: this is wrong -- the 3
> >> changes each individually break the build.
> >>
> >> I guess that you are not cleaning everything in your tests before
> >> testing the build.
> >
> > You're absolutely right, this patch is incorrect. I was indeed not
> > blowing away build artifcats.
>
> So is the `compiler_builtins` dependency correct for all crates?
Looks that way to me.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-07-23 20:13 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-20 17:20 [PATCH v3] rust: remove spurious compiler_builtins dependents Tamir Duberstein
2025-07-21 5:54 ` kernel test robot
2025-07-21 11:56 ` Alice Ryhl
2025-07-21 12:25 ` Miguel Ojeda
2025-07-23 15:18 ` Tamir Duberstein
2025-07-23 19:53 ` Benno Lossin
2025-07-23 20:12 ` Tamir Duberstein
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).