rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kbuild: rust: add `rustupoverride` target
@ 2023-12-14 22:22 Miguel Ojeda
  2023-12-15  2:58 ` Martin Rodriguez Reboredo
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Miguel Ojeda @ 2023-12-14 22:22 UTC (permalink / raw)
  To: Masahiro Yamada, Miguel Ojeda, Wedson Almeida Filho, Alex Gaynor
  Cc: Nathan Chancellor, Nick Desaulniers, Nicolas Schier, Boqun Feng,
	Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Alice Ryhl, linux-kbuild, rust-for-linux, linux-kernel, patches

When setting up the Rust support via `rustup`, one may use an override
in order to select the right version of the Rust toolchain.

The current instructions at Documentation/rust/quick-start.rst assume
one is using an in-tree kernel build (i.e. no `O=`) [1]. We would like
to provide also the way to do so for `O=` builds, but ideally in a way
that keeps the one-liner copy-pastable and without duplication [2].

Thus provide a new Make target, `rustupoverride`, that sets it up for
the user given their build options/variables.

Link: https://lore.kernel.org/rust-for-linux/20231207084846.faset66xzuoyvdlg@vireshk-i7/ [1]
Link: https://lore.kernel.org/rust-for-linux/CANiq72=mvca8PXoxwzSao+QFbAHDCecSKCDtV+ffd+YgZNFaww@mail.gmail.com/ [2]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
---
Viresh may send a patch on top of this to refer to `rustupoverride`
from the Quick Start guide in `Documentation/rust` -- that one should
probably be applied right after this one.

 Makefile | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 70fc4c11dfc0..7fe82dd4dc6f 100644
--- a/Makefile
+++ b/Makefile
@@ -276,7 +276,8 @@ no-dot-config-targets := $(clean-targets) \
 			 cscope gtags TAGS tags help% %docs check% coccicheck \
 			 $(version_h) headers headers_% archheaders archscripts \
 			 %asm-generic kernelversion %src-pkg dt_binding_check \
-			 outputmakefile rustavailable rustfmt rustfmtcheck
+			 outputmakefile rustavailable rustfmt rustfmtcheck \
+			 rustupoverride
 no-sync-config-targets := $(no-dot-config-targets) %install modules_sign kernelrelease \
 			  image_name
 single-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.rsi %.s %.symtypes %/
@@ -1611,6 +1612,7 @@ help:
 	@echo  '                    (requires kernel .config; downloads external repos)'
 	@echo  '  rust-analyzer	  - Generate rust-project.json rust-analyzer support file'
 	@echo  '		    (requires kernel .config)'
+	@echo  '  rustupoverride  - Set up a rustup override for the build directory'
 	@echo  '  dir/file.[os]   - Build specified target only'
 	@echo  '  dir/file.rsi    - Build macro expanded source, similar to C preprocessing.'
 	@echo  '                    Run with RUSTFMT=n to skip reformatting if needed.'
@@ -1735,6 +1737,11 @@ rustfmt:
 rustfmtcheck: rustfmt_flags = --check
 rustfmtcheck: rustfmt

+# `rustup override` setup target
+PHONY += rustupoverride
+rustupoverride:
+	$(Q)rustup override set $(shell $(srctree)/scripts/min-tool-version.sh rustc)
+
 # Misc
 # ---------------------------------------------------------------------------


base-commit: a39b6ac3781d46ba18193c9dbb2110f31e9bffe9
--
2.43.0

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-12-18 13:42 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-14 22:22 [PATCH] kbuild: rust: add `rustupoverride` target Miguel Ojeda
2023-12-15  2:58 ` Martin Rodriguez Reboredo
2023-12-15  7:38 ` David Gow
2023-12-15 11:27   ` Miguel Ojeda
2023-12-16  8:07     ` David Gow
2023-12-18 12:09     ` Masahiro Yamada
2023-12-18 13:33       ` Miguel Ojeda
2023-12-18 13:41         ` Masahiro Yamada
2023-12-15 10:33 ` Alice Ryhl
2023-12-15 11:16 ` Tiago Lam

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).