Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp6302874rdb; Thu, 14 Dec 2023 14:23:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IF8ngbpPi1+450hccSxS/KI7ffEL/dg+Nhflr+bSBcilS6huA/lP8wVmwvMEJraBPYYidcG X-Received: by 2002:a05:6214:e83:b0:67f:3f8:fdf4 with SMTP id hf3-20020a0562140e8300b0067f03f8fdf4mr4071094qvb.126.1702592604812; Thu, 14 Dec 2023 14:23:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702592604; cv=none; d=google.com; s=arc-20160816; b=urOIUpuuEkjSVBDnQmIdS/XcWHsyamyXPfpvPCnNH++Tx6t5soiSn3gM9uTxycPfyP LKhLC+tnfd5qHJGHQw6DkctPAiVXwyubGh3WiTT8sqkZtqOTUxJn/x5Js/BEE4u8fjOD nXvUmP45sklnmgq17Cw19EnVCyK2N+lraUo6ATX4T1tKzQ93BILqPSSTZ63/xOq/5359 qGR2+DxZgguZOBrzf766jkpOQ4UtjlEU44LBpX03oMjsnDWJWPgWnvB9yMIEfJDQHdZe 1rh3tjzCVKvdVPL3x/WRF/+j2dgKBRQfzWa1CukIqRpbLtVS66n4MSSkdosoJnOQZWpX ml6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=2XXst07nknW0l6uACkPyWWBXUPw/FxLNvLtoP6e392E=; fh=QSgolHeNGRlAM0OXE00xeOGX8y4YA1YVQI+ETCOl/lQ=; b=yOgjnqXVG+LTSRC7QLIahqMa8B6b47fAEsx3AgKHfLiFwlMppAXXeXI5VndPwxBqJY rNQyP079r4K5JBIjfzZ2QGySG00twyaDLoJBM5cB6mIs/Wka12sWTiHKCHvBe+6jZ4v2 Y5YBFkxWkUDRRHvldmMAVZEGq35MPDrYnqkUx3cV93NIyWdqqjPy0okKHYOp3jl5qPyL srR5nFKXC0qyiXxFSHTXMM8ocW8i11GYIhFlp98say+ytEJE3AKoaHTIRf/asvKAQIs9 tcyOs2a2shhTsoiOvI3hNI8GkPf5MG8coTteJYdWvmBfHQ0QzLh9f9p2t9z0yNLyIq14 1tBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hy1KhZDQ; spf=pass (google.com: domain of linux-kernel+bounces-186-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-186-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id m3-20020ad45043000000b0067ef67d9e03si4656398qvq.600.2023.12.14.14.23.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 14:23:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-186-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hy1KhZDQ; spf=pass (google.com: domain of linux-kernel+bounces-186-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-186-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 91F5B1C21E0D for ; Thu, 14 Dec 2023 22:23:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 619CF2C6A5; Thu, 14 Dec 2023 22:23:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hy1KhZDQ" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9B4746720A; Thu, 14 Dec 2023 22:23:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 34043C433C8; Thu, 14 Dec 2023 22:23:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702592591; bh=pgyu4wBiidMdBiu1uYG+TluTmLJL6JHzn+KTryLFeg4=; h=From:To:Cc:Subject:Date:From; b=hy1KhZDQeVmw/PKAZKMyHpyFpLjMJvZ9nzmSzg1q25LbazraEx0KJ3LDB8nRJJvpX 3jXCtGicmnegnajOaGeUiliNcYAg0Kv2/pOJZIINAIncAfSGEUcFTdS6+Sw3FkUUIV O0nRnHfXWkFc0zAIDOsUyh8cCkqx1OCcYo+K5aMstdkf6vM6GKbcRbXYnQdMNrbxjS qHc1tXmWh4RrjAfJAr3gYMqXpOSQIpykKFOM4pyoP6GAAVRIW4qrdMLUlff6dQIqiv /4fO0fIg7F5Iy4RdxU4hqQedtn/JRLasYTUA9lvGmygWOzBJ/DJrzVqJiNz0QSh+q5 z8xkqRXYjB/TQ== From: Miguel Ojeda To: Masahiro Yamada , Miguel Ojeda , Wedson Almeida Filho , Alex Gaynor Cc: Nathan Chancellor , Nick Desaulniers , Nicolas Schier , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , linux-kbuild@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev Subject: [PATCH] kbuild: rust: add `rustupoverride` target Date: Thu, 14 Dec 2023 23:22:53 +0100 Message-ID: <20231214222253.116734-1-ojeda@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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