From patchwork Mon Sep 2 16:55:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miguel Ojeda X-Patchwork-Id: 13787528 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 638951AB6E8; Mon, 2 Sep 2024 16:56:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725296172; cv=none; b=NERD7RQ48gEfXigxdrJiuDA7s63RzEIzEUtStl7rcHkyVRiVFn5yJnIKPdGEGKfZuVrqgrNpRixthfVMrPbHlFfxG7ldwOn1A3cJj0TrXD4G2GpNCnF2VmZ0uiijrw8uq6L3/io2sDGx34UNH6PcMQD6VKuIgCURsWDvze25vjk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725296172; c=relaxed/simple; bh=Py8aXDwihPSg2fJ40DevYcamcRTgb64eTsUQY/xmr6Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WdF/f/xxBeWvGKFD0cM8vs1dGGXxJlLKMiG/LOsuaOBCx0zdYrltVv8c80Kk55lJ/9lNnchixKHJGRzCn0HamGLK3JIJ10XjMoQAWPrgy3sr2jaBe8mEwe+qq7toXWMjH88hbq1kPU9VX9Q9lZ+ZTsgFGkfOzdK5msDZrFdwOAs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kKxBx91f; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kKxBx91f" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BF4ADC4CEC7; Mon, 2 Sep 2024 16:56:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725296171; bh=Py8aXDwihPSg2fJ40DevYcamcRTgb64eTsUQY/xmr6Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kKxBx91flDChNZo/qI/zDXN+iFkvr4fJ38taaQ0lsNqxzBu4XVZh/Fscl59ttHewm Tb99CuciXKvLjFLFjQuDjJ7urgDIlPJYItr9sEFCysJbqTSnbYnS+CNWpOZCK4NTlS u0Z5ez9jvwULsDfIfkQjiJ2M7AwdQMeskeX+bWsO8o6FeoRQKdDAdSq/81r4V9g4vT nkm4yZg5xw/kRJEpgp+pnvW4GMLRHft4mBl5SWHrxm8Xth5kD7Pw0IcaPchRW1MpQA obNDnaxA6nrAfhWRgH4ydA6gAF93FsgLRLDer1Cz2TChwanGYmqvk1C+mYajtnEC9Q B5o5CgfO64iZQ== From: Miguel Ojeda To: Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Masahiro Yamada Cc: Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , rust-for-linux@vger.kernel.org, Nathan Chancellor , Nicolas Schier , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev Subject: [PATCH v2 3/6] kbuild: rust: rebuild if the version text changes Date: Mon, 2 Sep 2024 18:55:30 +0200 Message-ID: <20240902165535.1101978-4-ojeda@kernel.org> In-Reply-To: <20240902165535.1101978-1-ojeda@kernel.org> References: <20240902165535.1101978-1-ojeda@kernel.org> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Now that `RUSTC_VERSION_TEXT` exists, use it to rebuild `core` when the version text changes (which in turn will trigger a rebuild of all the kernel Rust code). This also applies to proc macros (which only work with the `rustc` that compiled them), via the already existing dependency on `core.o`. That is cleaned up in the next commit. However, this does not cover host programs written in Rust, which is the same case in the C side. This is accomplished by referencing directly the generated file, instead of using the `fixdep` header trick, since we cannot change the Rust standard library sources. This is not too much of a burden, since it only needs to be done for `core`. Tested-by: Alice Ryhl Signed-off-by: Miguel Ojeda --- rust/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rust/Makefile b/rust/Makefile index e13d14ec5fe7..bb57a7c30f1a 100644 --- a/rust/Makefile +++ b/rust/Makefile @@ -389,7 +389,8 @@ $(obj)/core.o: private skip_clippy = 1 $(obj)/core.o: private skip_flags = -Wunreachable_pub $(obj)/core.o: private rustc_objcopy = $(foreach sym,$(redirect-intrinsics),--redefine-sym $(sym)=__rust$(sym)) $(obj)/core.o: private rustc_target_flags = $(core-cfgs) -$(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs FORCE +$(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs \ + $(wildcard $(objtree)/include/config/RUSTC_VERSION_TEXT) FORCE +$(call if_changed_rule,rustc_library) ifneq ($(or $(CONFIG_X86_64),$(CONFIG_X86_32)),) $(obj)/core.o: scripts/target.json