rust: add `rustcheck` make target for check-only builds
Onur Özkan
reviewerv2 cover rust: add `rustcheck` make target for check-only builds
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(+)
Signature · 1 line
2.51.0
Onur Özkan
reviewerPATCH v2 1/1 rust: add `rustcheck` make target for check-only builds
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.
--- Makefile | 7 +++++ rust/Makefile | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+)
Makefile +7 -0
@@ -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
rust/Makefile +73 -0
79 lines not on this page · raw message
Signature · 1 line
2.51.0
Quoted 34 lines · Onur Özkan
Adds a new
rustcheckmake target to run a check-only build similar tocargo 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 <[email protected]>Signed-off-by Onur Özkan <[email protected]>--- Makefile | 7 +++++ rust/Makefile | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+)Makefile +2
-0@@ -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'
Makefile PHONY += rustdoc · line 1828
Quoted 6 lines
Makefile +3
-0@@ -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?
Quoted 10 lines
Makefile +2
-0+ $(Q)$(MAKE) $(build)=rust $@ + # Testing target PHONY += rusttest rusttest: preparerust/Makefile +0
-0
rust/Makefile rusttest-kernel: $(src)/kernel/lib.rs rusttestlib-ffi rusttestlib-kernel \ · line 271
Quoted 7 lines
rust/Makefile +4
-0@@ -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
Onur Özkan
reviewerQuoted 41 lines · On Mon, 22 Sep 2025 08:02:36 +0200 Nicolas Schier <[email protected]>…
Quoted 40 lines · Onur Özkan
Adds a new
rustcheckmake target to run a check-only build similar tocargo 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 <[email protected]>Link:
https://rust-for-linux.zulipchat.com/#narrow/channel/288089/topic/x/near/539103602Signed-off-by Onur Özkan <[email protected]> ---Makefile | 7 +++++ rust/Makefile | 73+++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+)
Makefile +0
-0@@ -1716,6 +1716,8 @@ help: @echo ' is formatted, printing a diffotherwise.' @echo ' rustdoc - Generate Rust
documentation' @echo ' (requires kernel
.config)'Makefile +1
-0+ @echo ' rustcheck - Check that the Rust codebuilds'
Makefile +1
-0+ @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 $@
Quoted 6 lines
Makefile PHONY += rustdoc · line 1828
Quoted 3 lines
Makefile +3
-0+# Checking Rust sources. +PHONY += rustcheck +rustcheck: prepare0Why 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".
Quoted 20 lines
Quoted 13 lines
Makefile +2
-0+ $(Q)$(MAKE) $(build)=rust $@ + # Testing target PHONY += rusttest rusttest: preparerust/Makefile +0
-0@@ -265,6 +265,79 @@ rusttest-kernel: $(src)/kernel/lib.rsrusttestlib-ffi rusttestlib-kernel \ rusttestlib-uapi rusttestlib-pin_init FORCE +$(call if_changed,rustc_test)
rust/Makefile rusttest-kernel: $(src)/kernel/lib.rs rusttestlib-ffi rusttestlib-kernel \ · line 271
Quoted 4 lines
rust/Makefile +4
-0+## 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?
Quoted 8 lines
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
Quoted 78 lines · Onur Özkan
Quoted 41 lines · On Mon, 22 Sep 2025 08:02:36 +0200 Nicolas Schier <[email protected]>…
Quoted 40 lines · Onur Özkan
Adds a new
rustcheckmake target to run a check-only build similar tocargo 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 <[email protected]>Link:
https://rust-for-linux.zulipchat.com/#narrow/channel/288089/topic/x/near/539103602Signed-off-by Onur Özkan <[email protected]> ---Makefile | 7 +++++ rust/Makefile | 73+++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+)
Makefile +0
-0@@ -1716,6 +1716,8 @@ help: @echo ' is formatted, printing a diffotherwise.' @echo ' rustdoc - Generate Rust
documentation' @echo ' (requires kernel
.config)'Makefile +1
-0+ @echo ' rustcheck - Check that the Rust codebuilds'
Makefile +1
-0+ @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 $@Quoted 6 lines
Makefile PHONY += rustdoc · line 1828
Quoted 3 lines
Makefile +3
-0+# Checking Rust sources. +PHONY += rustcheck +rustcheck: prepare0Why 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".
Quoted 24 lines
Quoted 13 lines
Makefile +2
-0+ $(Q)$(MAKE) $(build)=rust $@ + # Testing target PHONY += rusttest rusttest: preparerust/Makefile +0
-0@@ -265,6 +265,79 @@ rusttest-kernel: $(src)/kernel/lib.rsrusttestlib-ffi rusttestlib-kernel \ rusttestlib-uapi rusttestlib-pin_init FORCE +$(call if_changed,rustc_test)
rust/Makefile rusttest-kernel: $(src)/kernel/lib.rs rusttestlib-ffi rusttestlib-kernel \ · line 271
Quoted 4 lines
rust/Makefile +4
-0+## 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
Quoted 7 lines
Quoted 4 lines
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.
Onur
reviewerQuoted 11 lines · On Mon, 15 Sep 2025 14:53:10 +0300 Onur Özkan <[email protected]> wrote:
Changes in v2:
- Couple of indentation fixes inrust/Makefile.Onur Özkan (1):
rust: addrustcheckmake target for check-only buildsMakefile | 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
Onur Özkan
reviewerQuoted 11 lines · On Mon, 15 Sep 2025 14:53:10 +0300 Onur Özkan <[email protected]> wrote:
Changes in v2:
- Couple of indentation fixes inrust/Makefile.Onur Özkan (1):
rust: addrustcheckmake target for check-only buildsMakefile | 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