From patchwork Sun May 19 21:12:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miguel Ojeda X-Patchwork-Id: 13667944 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 412FC26AEC; Sun, 19 May 2024 21:12:47 +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=1716153168; cv=none; b=hU1MWqiGgK6EN2hyhG6k0nTihu3jlmNv+r4icmw0nd+0B+Upqu1668tmwoPCRyEyPjp6T2HspnQa9HyLoUbjZCu5LCrlwLiC/p/SJ0JppB6YE1yceeRjNzG9a6hZeJoo5YqxhIXxrWnubGeuOArYFUqTpADMUXlkEI/6epn+zkA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716153168; c=relaxed/simple; bh=e2u0UG0wuyw4TbBEmJFcpe0xCx60m/GShz0PKNVG8As=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=EWmmWp34yJWpAkxNrSEYFJql6DX9ZLCoXZaM3AGl5B4hhADUE1h4W5RK+YBRU1Np0aj3kVD1J7aRjQZLwPbEbk9/PuC2hW0LoAzeSiOMPgF5UWMM2F2RgSt0JrJ5bBc5Z3cPiDku8zTL2pWNJDzRrNebTdLSy/mIhpP7Q21gJEY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Js1yFGSO; 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="Js1yFGSO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 408B0C32781; Sun, 19 May 2024 21:12:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716153167; bh=e2u0UG0wuyw4TbBEmJFcpe0xCx60m/GShz0PKNVG8As=; h=From:To:Cc:Subject:Date:From; b=Js1yFGSOqbapVHh1Hmmi9E6X5MWNAr7fD6efIWps0bj+fs2rQMPjHOOrc6AOQkiDm x7kh2+QW70OTH4gySqsQi51cKf6yXscbi+oefcNO36VDGEMDzxZhNUV7hUHDAmGmaf d6w1f3qkbIC1pk3Zzztw14BG95JhBhmAafxXEroBS6hUuL5P/oix6q1QCHZpfMyyka kqj1YPJbyVW1PB7fcvgm/TrIIViBWZ0h0txMTmaZXmteHDIpvZNUtkXdzEEKauqYA7 qn+k9vNMhX8xVvqoN2yd+uhnuLnWjOwCmLgZWUevazxkv92U+MADIbKy4KVzdG+cx7 jfoPN2GLNQHmQ== From: Miguel Ojeda To: Masahiro Yamada , Miguel Ojeda , Wedson Almeida Filho , Alex Gaynor Cc: Nathan Chancellor , Nicolas Schier , Boqun Feng , Gary Guo , =?utf-8?q?B?= =?utf-8?q?j=C3=B6rn_Roy_Baron?= , 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 1/3] kbuild: rust: move `-Dwarnings` handling to `Makefile.extrawarn` Date: Sun, 19 May 2024 23:12:33 +0200 Message-ID: <20240519211235.589325-1-ojeda@kernel.org> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Following commit e88ca24319e4 ("kbuild: consolidate warning flags in scripts/Makefile.extrawarn"), move `-Dwarnings` handling into `Makefile.extrawarn` like C's `-Werror`. No functional change intended. Signed-off-by: Miguel Ojeda Reviewed-by: Alice Ryhl --- Makefile | 3 --- scripts/Makefile.extrawarn | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 763b6792d3d5..fba567a55607 100644 --- a/Makefile +++ b/Makefile @@ -842,9 +842,6 @@ stackp-flags-$(CONFIG_STACKPROTECTOR_STRONG) := -fstack-protector-strong KBUILD_CFLAGS += $(stackp-flags-y) -KBUILD_RUSTFLAGS-$(CONFIG_WERROR) += -Dwarnings -KBUILD_RUSTFLAGS += $(KBUILD_RUSTFLAGS-y) - ifdef CONFIG_FRAME_POINTER KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls KBUILD_RUSTFLAGS += -Cforce-frame-pointers=y diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn index 3ce5d503a6da..48114e91c386 100644 --- a/scripts/Makefile.extrawarn +++ b/scripts/Makefile.extrawarn @@ -26,6 +26,9 @@ endif KBUILD_CPPFLAGS-$(CONFIG_WERROR) += -Werror KBUILD_CPPFLAGS += $(KBUILD_CPPFLAGS-y) +KBUILD_RUSTFLAGS-$(CONFIG_WERROR) += -Dwarnings +KBUILD_RUSTFLAGS += $(KBUILD_RUSTFLAGS-y) + KBUILD_CFLAGS-$(CONFIG_CC_NO_ARRAY_BOUNDS) += -Wno-array-bounds ifdef CONFIG_CC_IS_CLANG From patchwork Sun May 19 21:12:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miguel Ojeda X-Patchwork-Id: 13667945 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 5B89F26AEC; Sun, 19 May 2024 21:12:52 +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=1716153172; cv=none; b=QJIgu/yRdg4VHRqnnmb9TnaPrmdKsJGLtTqMx3BY7T/yDJKdURftdFx6ZgwkNVA+1INh2sdariCkJWoNE1lqKAEf15/Ezg8n+wIASJBWbKCHNLjdI2TC/LP/vIZjOTgU5X5S9Oy3NMqxwbwLz+tRwp48yFjHx5Azy0amV0BZTdI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716153172; c=relaxed/simple; bh=uz3qaXVHS+S2eSkdqp8UHPcIOILSeq1SMRGGBFONyUA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kDRF2/akiS6OTAKDmWgbBe/FCf/SYXWhN6xDpmlTQKH7QwRZ9nxVTEYYGxuwtrCgtAoFyr3ohdzt8G5DRsmSysbXQLPxFSlCxJYRXWz51r3MipRCY/dwD+EXasVdUzhchH63Y5Wgu5FJUm2kKzy3Y+HxqYbauZuo5/f+dszKizg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qg8iqhW1; 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="qg8iqhW1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 58A31C32786; Sun, 19 May 2024 21:12:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716153171; bh=uz3qaXVHS+S2eSkdqp8UHPcIOILSeq1SMRGGBFONyUA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qg8iqhW1axS5SGiECrbyxZuMhDzlCRjHLg7oz/T9K9K9IHMz60zyHGWJ7cmDnKoie +vOj34a6+AlIOn5FLdtlivuXs8ZklavC4fLCk4FY/9i6YYgYfRXkOF8mp9QE/Aoxpu jukOfQmn6Gi2d3ouys3ZqQ/VZ2KtnqHLkvlLvzztk2BNc0WS457rPsgEk65M2SomKC cf8RU/05aWKIza0jHwvffitUKpxSlYV5aCVJFHD6rWjUPiISXtXuVLMrYYn6sJKYKi U9X8tF5ctq2bTKQ9AdRRqRcDhh77HJ41N02422Q8bEVs4y8P3Ox5HXFIrx3mZjXC0U Sj94m85oDHWeA== From: Miguel Ojeda To: Masahiro Yamada , Miguel Ojeda , Wedson Almeida Filho , Alex Gaynor Cc: Nathan Chancellor , Nicolas Schier , Boqun Feng , Gary Guo , =?utf-8?q?B?= =?utf-8?q?j=C3=B6rn_Roy_Baron?= , 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 2/3] kbuild: rust: apply `CONFIG_WERROR` to all Rust targets Date: Sun, 19 May 2024 23:12:34 +0200 Message-ID: <20240519211235.589325-2-ojeda@kernel.org> In-Reply-To: <20240519211235.589325-1-ojeda@kernel.org> References: <20240519211235.589325-1-ojeda@kernel.org> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Make all Rust code (i.e. not just kernel code) respect `CONFIG_WERROR`, so that we keep everything warning clean. In particular, this affects targets in `rust/` (`RUSTDOC H`, `RUSTC TL`, `RUSTDOC T`, `RUSTC T` and `RUSTC P`), plus host programs and any others we may add later. Signed-off-by: Miguel Ojeda Reviewed-by: Alice Ryhl --- This one requires the `rusttest` warning cleanup at https://lore.kernel.org/rust-for-linux/20240519210735.587323-1-ojeda@kernel.org/ Makefile | 4 ++-- scripts/Makefile.extrawarn | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) -- 2.45.1 diff --git a/Makefile b/Makefile index fba567a55607..2d0ea441cb9c 100644 --- a/Makefile +++ b/Makefile @@ -469,7 +469,7 @@ export rust_common_flags := --edition=2021 \ KBUILD_HOSTCFLAGS := $(KBUILD_USERHOSTCFLAGS) $(HOST_LFS_CFLAGS) $(HOSTCFLAGS) KBUILD_HOSTCXXFLAGS := -Wall -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS) -KBUILD_HOSTRUSTFLAGS := $(rust_common_flags) -O -Cstrip=debuginfo \ +KBUILD_HOSTRUSTFLAGS = $(rust_common_flags) -O -Cstrip=debuginfo \ -Zallow-features= $(HOSTRUSTFLAGS) KBUILD_HOSTLDFLAGS := $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS) KBUILD_HOSTLDLIBS := $(HOST_LFS_LIBS) $(HOSTLDLIBS) @@ -560,7 +560,7 @@ KBUILD_CFLAGS += -fno-PIE KBUILD_CFLAGS += -fno-strict-aliasing KBUILD_CPPFLAGS := -D__KERNEL__ -KBUILD_RUSTFLAGS := $(rust_common_flags) \ +KBUILD_RUSTFLAGS = $(rust_common_flags) \ -Cpanic=abort -Cembed-bitcode=n -Clto=n \ -Cforce-unwind-tables=n -Ccodegen-units=1 \ -Csymbol-mangling-version=v0 \ diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn index 48114e91c386..990890821889 100644 --- a/scripts/Makefile.extrawarn +++ b/scripts/Makefile.extrawarn @@ -26,8 +26,8 @@ endif KBUILD_CPPFLAGS-$(CONFIG_WERROR) += -Werror KBUILD_CPPFLAGS += $(KBUILD_CPPFLAGS-y) -KBUILD_RUSTFLAGS-$(CONFIG_WERROR) += -Dwarnings -KBUILD_RUSTFLAGS += $(KBUILD_RUSTFLAGS-y) +rust_common_flags-$(CONFIG_WERROR) += -Dwarnings +rust_common_flags += $(rust_common_flags-y) KBUILD_CFLAGS-$(CONFIG_CC_NO_ARRAY_BOUNDS) += -Wno-array-bounds From patchwork Sun May 19 21:12:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miguel Ojeda X-Patchwork-Id: 13667946 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 736CA26AEC; Sun, 19 May 2024 21:12:56 +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=1716153176; cv=none; b=Xj6Y2Znx7Y9QSwp07e36yIr/twIxYOZDMEWGK/wg3+TxKzCslTjdDQ/GmTakl2PDtN27PmR1FqH3dZGQvehW8jUx27/3e5SITI55yEDZurmV3ySKvFrqoNXe26cgcqUN/6F2PF1q5ehKDI48NfYwmGLhckRQ/D8qHWTl2AnDGfI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716153176; c=relaxed/simple; bh=ycHchcNNkPJYHuh6grxXiGPIJUsXEsvkI6+Ndfvc6L0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UKBW3G7TsT4SawD8CtvbFfBhmajcjfs8Vleg/wggEdYsGE1+p9K0ggPfJNtGagKnb1kPFHC7omP3fqJUdp7YItXLu1i4L+ttu/nLrZTrfcSgUZVDO9LlMYlUDLbKqAVrhyMd6Z0KTrxQVAIcTyGypBEA0ZHTngEpenIcq/PVksQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RB5Hff15; 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="RB5Hff15" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6EC64C32781; Sun, 19 May 2024 21:12:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716153176; bh=ycHchcNNkPJYHuh6grxXiGPIJUsXEsvkI6+Ndfvc6L0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RB5Hff15TXv+xZ+4FoMJHqq91r+V9dYXpxdjHbBAOPgvPgIlH5dhy5OifIA9U6LQO uec6kb2dypXp42GiUWluk7mqoo+a+7PSNIFhxzb6tOlxjhSkp4Amcwm0KG7WfFXaJG DQbuETZs/Qvxxf4KI95TjX5CqMms8aN+RAla9DoH83c8A5HDU3H26qF2eGBCCFmHe1 e6RcXIWt7hZ2099tnpps2TYnbFyXZ9Zk3C1l8x2rkAKQ2XacQO8LiLDDNVQr0+QLJX w60rOaMK0THM1SvctabMwFtvCV/C9FyQfEApmQewgq0N/w/z+gSv1E0zQYGXjnAlhx OdTijlbyczy+A== From: Miguel Ojeda To: Masahiro Yamada , Miguel Ojeda , Wedson Almeida Filho , Alex Gaynor Cc: Nathan Chancellor , Nicolas Schier , Boqun Feng , Gary Guo , =?utf-8?q?B?= =?utf-8?q?j=C3=B6rn_Roy_Baron?= , 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 3/3] kbuild: rust: support `W=e` for Rust Date: Sun, 19 May 2024 23:12:35 +0200 Message-ID: <20240519211235.589325-3-ojeda@kernel.org> In-Reply-To: <20240519211235.589325-1-ojeda@kernel.org> References: <20240519211235.589325-1-ojeda@kernel.org> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 With `W=e`, kernel C targets error out on warnings. Add support for the same feature for Rust code, but take the opportunity to apply it for every Rust target (i.e. not just kernel code), so that it behaves like having set `CONFIG_WERROR`. Signed-off-by: Miguel Ojeda Reviewed-by: Alice Ryhl --- scripts/Makefile.extrawarn | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn index 990890821889..214b5edce4f2 100644 --- a/scripts/Makefile.extrawarn +++ b/scripts/Makefile.extrawarn @@ -206,5 +206,6 @@ endif ifneq ($(findstring e, $(KBUILD_EXTRA_WARN)),) KBUILD_CFLAGS += -Werror +rust_common_flags += -Dwarnings endif