* [PATCH v2 0/1] rust: add `rustcheck` make target for check-only builds
@ 2025-09-15 11:53 Onur Özkan
  2025-09-15 11:53 ` [PATCH v2 1/1] " Onur Özkan
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Onur Özkan @ 2025-09-15 11:53 UTC (permalink / raw)
  To: rust-for-linux
  Cc: ojeda, nathan, nicolas.schier, masahiroy, aliceryhl,
	thomas.weissschuh, tamird, linux-kbuild, linux-kernel,
	alex.gaynor, boqun.feng, gary, bjorn3_gh, lossin, a.hindborg,
	tmgross, dakr, Onur Özkan
Changes in v2:
  - Couple of indentation fixes in rust/Makefile.
Onur Özkan (1):
  rust: add `rustcheck` make target for check-only builds
 Makefile      |  7 +++++
 rust/Makefile | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 80 insertions(+)
-- 
2.51.0
^ permalink raw reply	[flat|nested] 7+ messages in thread* [PATCH v2 1/1] rust: add `rustcheck` make target for check-only builds 2025-09-15 11:53 [PATCH v2 0/1] rust: add `rustcheck` make target for check-only builds Onur Özkan @ 2025-09-15 11:53 ` Onur Özkan 2025-09-22 6:02 ` Nicolas Schier 2025-09-16 12:06 ` [PATCH v2 0/1] " Onur 2025-10-09 12:54 ` Onur Özkan 2 siblings, 1 reply; 7+ messages in thread From: Onur Özkan @ 2025-09-15 11:53 UTC (permalink / raw) To: rust-for-linux Cc: ojeda, nathan, nicolas.schier, masahiroy, aliceryhl, thomas.weissschuh, tamird, linux-kbuild, linux-kernel, alex.gaynor, boqun.feng, gary, bjorn3_gh, lossin, a.hindborg, tmgross, dakr, Onur Özkan Adds a new `rustcheck` make target to run a check-only build similar to `cargo check`. This allows us to verify that the Rust sources can build without building/linking final artifacts, which speeds up the iteration (a lot) during development. The target also supports the CLIPPY flag (e.g., `make LLVM=1 rustcheck CLIPPY=1) to run Clippy in a faster way. Also, unlike `make LLVM=1`, it doesn't compile large amounts of C code (on a fresh checkout) when the goal is only to check that Rust builds are not broken after some changes. Suggested-by: Benno Losin <lossin@kernel.org> Link: https://rust-for-linux.zulipchat.com/#narrow/channel/288089/topic/x/near/539103602 Signed-off-by: Onur Özkan <work@onurozkan.dev> --- Makefile | 7 +++++ rust/Makefile | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) diff --git a/Makefile b/Makefile index cf37b9407821..7812cdc72938 100644 --- a/Makefile +++ b/Makefile @@ -1716,6 +1716,8 @@ help: @echo ' is formatted, printing a diff otherwise.' @echo ' rustdoc - Generate Rust documentation' @echo ' (requires kernel .config)' + @echo ' rustcheck - Check that the Rust code builds' + @echo ' (requires kernel .config)' @echo ' rusttest - Runs the Rust tests' @echo ' (requires kernel .config; downloads external repos)' @echo ' rust-analyzer - Generate rust-project.json rust-analyzer support file' @@ -1821,6 +1823,11 @@ PHONY += rustdoc rustdoc: prepare $(Q)$(MAKE) $(build)=rust $@ +# Checking Rust sources. +PHONY += rustcheck +rustcheck: prepare0 + $(Q)$(MAKE) $(build)=rust $@ + # Testing target PHONY += rusttest rusttest: prepare diff --git a/rust/Makefile b/rust/Makefile index bfa915b0e588..b45878870207 100644 --- a/rust/Makefile +++ b/rust/Makefile @@ -265,6 +265,79 @@ rusttest-kernel: $(src)/kernel/lib.rs rusttestlib-ffi rusttestlib-kernel \ rusttestlib-uapi rusttestlib-pin_init FORCE +$(call if_changed,rustc_test) +## Check-only compilation (similar to `cargo check`) +quiet_cmd_rustc_check_library = $(RUSTC_OR_CLIPPY_QUIET) CHECK $< + cmd_rustc_check_library = \ + OBJTREE=$(abspath $(objtree)) \ + $(RUSTC_OR_CLIPPY) $(rust_common_flags) \ + @$(objtree)/include/generated/rustc_cfg $(rustc_target_flags) \ + --crate-type $(if $(rustc_check_library_proc),proc-macro,rlib) \ + $(if $(rustc_check_library_proc),,--emit=metadata) \ + --out-dir $(objtree)/$(obj)/check -L$(objtree)/$(obj)/check \ + --crate-name $(if $(rustc_check_crate_name),$(rustc_check_crate_name), \ + $(subst rustcheck-,,$(subst rustchecklib-,,$@))) $< + +rustcheck: rustchecklib-build_error rustchecklib-ffi rustchecklib-macros \ + rustchecklib-compiler_builtins rustchecklib-pin_init_internal \ + rustchecklib-pin_init rustchecklib-bindings rustchecklib-uapi \ + rustchecklib-kernel + +rustchecklib-build_error: $(src)/build_error.rs FORCE + +$(call if_changed,rustc_check_library) + +rustchecklib-ffi: $(src)/ffi.rs FORCE + +$(call if_changed,rustc_check_library) + +rustchecklib-macros: private rustc_target_flags = --extern proc_macro +rustchecklib-macros: private rustc_check_library_proc = yes +rustchecklib-macros: $(src)/macros/lib.rs FORCE + +$(call if_changed,rustc_check_library) + +rustchecklib-compiler_builtins: private rustc_check_crate_name = compiler_builtins_kernel +rustchecklib-compiler_builtins: $(src)/compiler_builtins.rs FORCE + +$(call if_changed,rustc_check_library) + +rustchecklib-pin_init_internal: private rustc_target_flags = --cfg kernel \ + --extern proc_macro +rustchecklib-pin_init_internal: private rustc_check_library_proc = yes +rustchecklib-pin_init_internal: $(src)/pin-init/internal/src/lib.rs FORCE + +$(call if_changed,rustc_check_library) + +rustchecklib-pin_init: private rustc_target_flags = --extern pin_init_internal \ + --extern macros --cfg kernel +rustchecklib-pin_init: $(src)/pin-init/src/lib.rs rustchecklib-macros \ + rustchecklib-pin_init_internal FORCE + +$(call if_changed,rustc_check_library) + +rustchecklib-bindings: private rustc_target_flags = --extern ffi +rustchecklib-bindings: $(src)/bindings/lib.rs \ + $(obj)/bindings/bindings_generated.rs \ + $(obj)/bindings/bindings_helpers_generated.rs \ + rustchecklib-ffi FORCE + +$(call if_changed,rustc_check_library) + +rustchecklib-uapi: private rustc_target_flags = --extern ffi +rustchecklib-uapi: $(src)/uapi/lib.rs $(obj)/uapi/uapi_generated.rs \ + rustchecklib-ffi FORCE + +$(call if_changed,rustc_check_library) + +ifdef CONFIG_JUMP_LABEL +rustchecklib-kernel: $(obj)/kernel/generated_arch_static_branch_asm.rs FORCE +endif +ifndef CONFIG_UML +ifdef CONFIG_BUG +rustchecklib-kernel: $(obj)/kernel/generated_arch_warn_asm.rs \ + $(obj)/kernel/generated_arch_reachable_asm.rs FORCE +endif +endif + +rustchecklib-kernel: private rustc_target_flags = --extern ffi --extern pin_init \ + --extern build_error --extern macros --extern bindings --extern uapi +rustchecklib-kernel: $(src)/kernel/lib.rs rustchecklib-ffi rustchecklib-pin_init \ + rustchecklib-build_error rustchecklib-macros rustchecklib-bindings \ + rustchecklib-uapi FORCE + +$(call if_changed,rustc_check_library) + ifdef CONFIG_CC_IS_CLANG bindgen_c_flags = $(c_flags) else -- 2.51.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/1] rust: add `rustcheck` make target for check-only builds 2025-09-15 11:53 ` [PATCH v2 1/1] " Onur Özkan @ 2025-09-22 6:02 ` Nicolas Schier 2025-09-23 3:47 ` Onur Özkan 0 siblings, 1 reply; 7+ messages in thread From: Nicolas Schier @ 2025-09-22 6:02 UTC (permalink / raw) To: Onur Özkan Cc: rust-for-linux, ojeda, nathan, nicolas.schier, masahiroy, aliceryhl, thomas.weissschuh, tamird, linux-kbuild, linux-kernel, alex.gaynor, boqun.feng, gary, bjorn3_gh, lossin, a.hindborg, tmgross, dakr [-- Attachment #1: Type: text/plain, Size: 2690 bytes --] On Mon, Sep 15, 2025 at 02:53:11PM +0300, Onur Özkan wrote: > Adds a new `rustcheck` make target to run a check-only build > similar to `cargo check`. This allows us to verify that the Rust > sources can build without building/linking final artifacts, > which speeds up the iteration (a lot) during development. > > The target also supports the CLIPPY flag (e.g., `make LLVM=1 > rustcheck CLIPPY=1) to run Clippy in a faster way. > > Also, unlike `make LLVM=1`, it doesn't compile large amounts of C > code (on a fresh checkout) when the goal is only to check that > Rust builds are not broken after some changes. > > Suggested-by: Benno Losin <lossin@kernel.org> > Link: https://rust-for-linux.zulipchat.com/#narrow/channel/288089/topic/x/near/539103602 > Signed-off-by: Onur Özkan <work@onurozkan.dev> > --- > Makefile | 7 +++++ > rust/Makefile | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 80 insertions(+) > > diff --git a/Makefile b/Makefile > index cf37b9407821..7812cdc72938 100644 > --- a/Makefile > +++ b/Makefile > @@ -1716,6 +1716,8 @@ help: > @echo ' is formatted, printing a diff otherwise.' > @echo ' rustdoc - Generate Rust documentation' > @echo ' (requires kernel .config)' > + @echo ' rustcheck - Check that the Rust code builds' > + @echo ' (requires kernel .config)' > @echo ' rusttest - Runs the Rust tests' > @echo ' (requires kernel .config; downloads external repos)' > @echo ' rust-analyzer - Generate rust-project.json rust-analyzer support file' > @@ -1821,6 +1823,11 @@ PHONY += rustdoc > rustdoc: prepare > $(Q)$(MAKE) $(build)=rust $@ > > +# Checking Rust sources. > +PHONY += rustcheck > +rustcheck: prepare0 Why do you let rustcheck depend on prepare0 instead of prepare? > + $(Q)$(MAKE) $(build)=rust $@ > + > # Testing target > PHONY += rusttest > rusttest: prepare > diff --git a/rust/Makefile b/rust/Makefile > index bfa915b0e588..b45878870207 100644 > --- a/rust/Makefile > +++ b/rust/Makefile > @@ -265,6 +265,79 @@ rusttest-kernel: $(src)/kernel/lib.rs rusttestlib-ffi rusttestlib-kernel \ > rusttestlib-uapi rusttestlib-pin_init FORCE > +$(call if_changed,rustc_test) > > +## Check-only compilation (similar to `cargo check`) > +quiet_cmd_rustc_check_library = $(RUSTC_OR_CLIPPY_QUIET) CHECK $< > + cmd_rustc_check_library = \ > + OBJTREE=$(abspath $(objtree)) \ Have you tried this? OBJTREE=$(CURDIR) \ or OBJTREE=$(abs_output) \ I'd favor using one of these instead. Kind regards, Nicolas [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/1] rust: add `rustcheck` make target for check-only builds 2025-09-22 6:02 ` Nicolas Schier @ 2025-09-23 3:47 ` Onur Özkan 2025-10-10 18:56 ` Nicolas Schier 0 siblings, 1 reply; 7+ messages in thread From: Onur Özkan @ 2025-09-23 3:47 UTC (permalink / raw) To: Nicolas Schier Cc: rust-for-linux, ojeda, nathan, masahiroy, aliceryhl, thomas.weissschuh, tamird, linux-kbuild, linux-kernel, alex.gaynor, boqun.feng, gary, bjorn3_gh, lossin, a.hindborg, tmgross, dakr On Mon, 22 Sep 2025 08:02:36 +0200 Nicolas Schier <nicolas.schier@linux.dev> wrote: > On Mon, Sep 15, 2025 at 02:53:11PM +0300, Onur Özkan wrote: > > Adds a new `rustcheck` make target to run a check-only build > > similar to `cargo check`. This allows us to verify that the Rust > > sources can build without building/linking final artifacts, > > which speeds up the iteration (a lot) during development. > > > > The target also supports the CLIPPY flag (e.g., `make LLVM=1 > > rustcheck CLIPPY=1) to run Clippy in a faster way. > > > > Also, unlike `make LLVM=1`, it doesn't compile large amounts of C > > code (on a fresh checkout) when the goal is only to check that > > Rust builds are not broken after some changes. > > > > Suggested-by: Benno Losin <lossin@kernel.org> > > Link: > > https://rust-for-linux.zulipchat.com/#narrow/channel/288089/topic/x/near/539103602 > > Signed-off-by: Onur Özkan <work@onurozkan.dev> --- > > Makefile | 7 +++++ > > rust/Makefile | 73 > > +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files > > changed, 80 insertions(+) > > > > diff --git a/Makefile b/Makefile > > index cf37b9407821..7812cdc72938 100644 > > --- a/Makefile > > +++ b/Makefile > > @@ -1716,6 +1716,8 @@ help: > > @echo ' is formatted, printing a diff > > otherwise.' @echo ' rustdoc - Generate Rust > > documentation' @echo ' (requires kernel > > .config)' > > + @echo ' rustcheck - Check that the Rust code > > builds' > > + @echo ' (requires kernel .config)' > > @echo ' rusttest - Runs the Rust tests' > > @echo ' (requires kernel .config; > > downloads external repos)' @echo ' rust-analyzer - > > Generate rust-project.json rust-analyzer support file' @@ -1821,6 > > +1823,11 @@ PHONY += rustdoc rustdoc: prepare > > $(Q)$(MAKE) $(build)=rust $@ > > > > +# Checking Rust sources. > > +PHONY += rustcheck > > +rustcheck: prepare0 > > Why do you let rustcheck depend on prepare0 instead of prepare? > Because "prepare" does more job which isn't necessary (therefore waste of time) for "rustcheck". > > + $(Q)$(MAKE) $(build)=rust $@ > > + > > # Testing target > > PHONY += rusttest > > rusttest: prepare > > diff --git a/rust/Makefile b/rust/Makefile > > index bfa915b0e588..b45878870207 100644 > > --- a/rust/Makefile > > +++ b/rust/Makefile > > @@ -265,6 +265,79 @@ rusttest-kernel: $(src)/kernel/lib.rs > > rusttestlib-ffi rusttestlib-kernel \ rusttestlib-uapi > > rusttestlib-pin_init FORCE +$(call if_changed,rustc_test) > > > > +## Check-only compilation (similar to `cargo check`) > > +quiet_cmd_rustc_check_library = $(RUSTC_OR_CLIPPY_QUIET) CHECK $< > > + cmd_rustc_check_library = \ > > + OBJTREE=$(abspath $(objtree)) \ > > Have you tried this? > > OBJTREE=$(CURDIR) \ > > or > > OBJTREE=$(abs_output) \ > > I'd favor using one of these instead. > I don't have a strong opinion on any of them. I followed the existing approach from the other use cases used in the same file. Regards, Onur ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/1] rust: add `rustcheck` make target for check-only builds 2025-09-23 3:47 ` Onur Özkan @ 2025-10-10 18:56 ` Nicolas Schier 0 siblings, 0 replies; 7+ messages in thread From: Nicolas Schier @ 2025-10-10 18:56 UTC (permalink / raw) To: Onur Özkan Cc: rust-for-linux, ojeda, nathan, masahiroy, aliceryhl, thomas.weissschuh, tamird, linux-kbuild, linux-kernel, alex.gaynor, boqun.feng, gary, bjorn3_gh, lossin, a.hindborg, tmgross, dakr On Tue, Sep 23, 2025 at 06:47:20AM +0300, Onur Özkan wrote: > On Mon, 22 Sep 2025 08:02:36 +0200 > Nicolas Schier <nicolas.schier@linux.dev> wrote: > > > On Mon, Sep 15, 2025 at 02:53:11PM +0300, Onur Özkan wrote: > > > Adds a new `rustcheck` make target to run a check-only build > > > similar to `cargo check`. This allows us to verify that the Rust > > > sources can build without building/linking final artifacts, > > > which speeds up the iteration (a lot) during development. > > > > > > The target also supports the CLIPPY flag (e.g., `make LLVM=1 > > > rustcheck CLIPPY=1) to run Clippy in a faster way. > > > > > > Also, unlike `make LLVM=1`, it doesn't compile large amounts of C > > > code (on a fresh checkout) when the goal is only to check that > > > Rust builds are not broken after some changes. > > > > > > Suggested-by: Benno Losin <lossin@kernel.org> > > > Link: > > > https://rust-for-linux.zulipchat.com/#narrow/channel/288089/topic/x/near/539103602 > > > Signed-off-by: Onur Özkan <work@onurozkan.dev> --- > > > Makefile | 7 +++++ > > > rust/Makefile | 73 > > > +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files > > > changed, 80 insertions(+) > > > > > > diff --git a/Makefile b/Makefile > > > index cf37b9407821..7812cdc72938 100644 > > > --- a/Makefile > > > +++ b/Makefile > > > @@ -1716,6 +1716,8 @@ help: > > > @echo ' is formatted, printing a diff > > > otherwise.' @echo ' rustdoc - Generate Rust > > > documentation' @echo ' (requires kernel > > > .config)' > > > + @echo ' rustcheck - Check that the Rust code > > > builds' > > > + @echo ' (requires kernel .config)' > > > @echo ' rusttest - Runs the Rust tests' > > > @echo ' (requires kernel .config; > > > downloads external repos)' @echo ' rust-analyzer - > > > Generate rust-project.json rust-analyzer support file' @@ -1821,6 > > > +1823,11 @@ PHONY += rustdoc rustdoc: prepare > > > $(Q)$(MAKE) $(build)=rust $@ > > > > > > +# Checking Rust sources. > > > +PHONY += rustcheck > > > +rustcheck: prepare0 > > > > Why do you let rustcheck depend on prepare0 instead of prepare? > > > > Because "prepare" does more job which isn't necessary (therefore waste > of time) for "rustcheck". > > > > + $(Q)$(MAKE) $(build)=rust $@ > > > + > > > # Testing target > > > PHONY += rusttest > > > rusttest: prepare > > > diff --git a/rust/Makefile b/rust/Makefile > > > index bfa915b0e588..b45878870207 100644 > > > --- a/rust/Makefile > > > +++ b/rust/Makefile > > > @@ -265,6 +265,79 @@ rusttest-kernel: $(src)/kernel/lib.rs > > > rusttestlib-ffi rusttestlib-kernel \ rusttestlib-uapi > > > rusttestlib-pin_init FORCE +$(call if_changed,rustc_test) > > > > > > +## Check-only compilation (similar to `cargo check`) > > > +quiet_cmd_rustc_check_library = $(RUSTC_OR_CLIPPY_QUIET) CHECK $< > > > + cmd_rustc_check_library = \ > > > + OBJTREE=$(abspath $(objtree)) \ > > > > Have you tried this? > > > > OBJTREE=$(CURDIR) \ > > > > or > > > > OBJTREE=$(abs_output) \ > > > > I'd favor using one of these instead. > > > > I don't have a strong opinion on any of them. I followed the existing > approach from the other use cases used in the same file. well, you're right, it's not really consistent right now. Acked-by: Nicolas Schier <nsc@kernel.org> ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 0/1] rust: add `rustcheck` make target for check-only builds 2025-09-15 11:53 [PATCH v2 0/1] rust: add `rustcheck` make target for check-only builds Onur Özkan 2025-09-15 11:53 ` [PATCH v2 1/1] " Onur Özkan @ 2025-09-16 12:06 ` Onur 2025-10-09 12:54 ` Onur Özkan 2 siblings, 0 replies; 7+ messages in thread From: Onur @ 2025-09-16 12:06 UTC (permalink / raw) To: rust-for-linux Cc: ojeda, nathan, nicolas.schier, masahiroy, aliceryhl, thomas.weissschuh, tamird, linux-kbuild, linux-kernel, alex.gaynor, boqun.feng, gary, bjorn3_gh, lossin, a.hindborg, tmgross, dakr On Mon, 15 Sep 2025 14:53:10 +0300 Onur Özkan <work@onurozkan.dev> wrote: > Changes in v2: > - Couple of indentation fixes in rust/Makefile. > > Onur Özkan (1): > rust: add `rustcheck` make target for check-only builds > > Makefile | 7 +++++ > rust/Makefile | 73 > +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, > 80 insertions(+) > Should we document this target on [0]? I think it will be used quite frequently by Rust developers on the kernel once we land it, so I think it's worth documenting. I can include a patch for that if others would agree. [0]: https://docs.kernel.org/rust/quick-start.html Regards, Onur ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 0/1] rust: add `rustcheck` make target for check-only builds 2025-09-15 11:53 [PATCH v2 0/1] rust: add `rustcheck` make target for check-only builds Onur Özkan 2025-09-15 11:53 ` [PATCH v2 1/1] " Onur Özkan 2025-09-16 12:06 ` [PATCH v2 0/1] " Onur @ 2025-10-09 12:54 ` Onur Özkan 2 siblings, 0 replies; 7+ messages in thread From: Onur Özkan @ 2025-10-09 12:54 UTC (permalink / raw) To: rust-for-linux Cc: ojeda, nathan, nicolas.schier, masahiroy, aliceryhl, thomas.weissschuh, tamird, linux-kbuild, linux-kernel, alex.gaynor, boqun.feng, gary, bjorn3_gh, lossin, a.hindborg, tmgross, dakr On Mon, 15 Sep 2025 14:53:10 +0300 Onur Özkan <work@onurozkan.dev> wrote: > Changes in v2: > - Couple of indentation fixes in rust/Makefile. > > Onur Özkan (1): > rust: add `rustcheck` make target for check-only builds > > Makefile | 7 +++++ > rust/Makefile | 73 > +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, > 80 insertions(+) > A friendly ping on this patch. It's been over two weeks with no feedback, would appreciate any thoughts or suggestions. Regards, Onur ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-10-10 18:57 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-09-15 11:53 [PATCH v2 0/1] rust: add `rustcheck` make target for check-only builds Onur Özkan 2025-09-15 11:53 ` [PATCH v2 1/1] " Onur Özkan 2025-09-22 6:02 ` Nicolas Schier 2025-09-23 3:47 ` Onur Özkan 2025-10-10 18:56 ` Nicolas Schier 2025-09-16 12:06 ` [PATCH v2 0/1] " Onur 2025-10-09 12:54 ` Onur Özkan
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).