From patchwork Mon Sep 5 08:36:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 12965831 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1933CECAAD5 for ; Mon, 5 Sep 2022 08:38:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236854AbiIEIi4 (ORCPT ); Mon, 5 Sep 2022 04:38:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237545AbiIEIiK (ORCPT ); Mon, 5 Sep 2022 04:38:10 -0400 Received: from conuserg-08.nifty.com (conuserg-08.nifty.com [210.131.2.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC5AC15FE0; Mon, 5 Sep 2022 01:37:45 -0700 (PDT) Received: from zoe.. (133-32-182-133.west.xps.vectant.ne.jp [133.32.182.133]) (authenticated) by conuserg-08.nifty.com with ESMTP id 2858aYjD013979; Mon, 5 Sep 2022 17:36:35 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com 2858aYjD013979 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1662366995; bh=Vt4IowzK+iXEF9eSOlkcqvghicJnWrspKfJyi1CRqyU=; h=From:To:Cc:Subject:Date:From; b=IMqKvKN+bK1+N0cZB6530aaXcy7bg+xZhSyAc5qAeOfEgOXpec72JikOvRQX51WgD WTQu6SSISSJPXhFlVCqS++0U8A0cHiSE+vSzEHTe29qozgnHiD3d8cF1KwfvbgUOXg sU260haY5LO1C8eDCmWynLeRW5/a9bYK6QI+b+HSgRiveaQdfNvcCQMkQ4Ifh2ChgZ mziHFxi1wTJFSsy8W2Ctd81IK95Wfe9fvM3Vs8B7oQzDGlHGNodCajlPfYtyq5ZhyL r2qCyx9w7mybixPwgS7dVExGUdgkrRUJ0cNzC2kVlNB2AXOHzu7P2wSaKlboTgRN5+ YnJVB8G7R476w== X-Nifty-SrcIP: [133.32.182.133] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , Michal Marek , Nick Desaulniers , linux-kernel@vger.kernel.org Subject: [PATCH 1/2] kbuild: move -Werror from KBUILD_CFLAGS to KBUILD_CPPFLAGS Date: Mon, 5 Sep 2022 17:36:18 +0900 Message-Id: <20220905083619.672091-1-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org CONFIG_WERROR makes warnings into errors, but it only happens for *.c files because -Werror is added to KBUILD_CFLAGS. For example, you can put a #warning directive in any preprocessed source file: #warning "blah blah ..." If it is placed in a *.c file, it emits a warning by default, and it is promoted to an error when CONFIG_WERROR is enabled: error: #warning "blah blah ..." [-Werror=cpp] If it is placed in a *.S file, it is still a warning. Move it to KBUILD_CPPFLAGS, so it works in the same way for *.c, *.S, *.lds.S or whatever needs preprocessing. Signed-off-by: Masahiro Yamada Reviewed-by: Nick Desaulniers --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ebcb75442d7f..027d9163eff6 100644 --- a/Makefile +++ b/Makefile @@ -788,7 +788,8 @@ stackp-flags-$(CONFIG_STACKPROTECTOR_STRONG) := -fstack-protector-strong KBUILD_CFLAGS += $(stackp-flags-y) -KBUILD_CFLAGS-$(CONFIG_WERROR) += -Werror +KBUILD_CPPFLAGS-$(CONFIG_WERROR) += -Werror +KBUILD_CPPFLAGS += $(KBUILD_CPPFLAGS-y) KBUILD_CFLAGS-$(CONFIG_CC_NO_ARRAY_BOUNDS) += -Wno-array-bounds KBUILD_CFLAGS += $(KBUILD_CFLAGS-y) $(CONFIG_CC_IMPLICIT_FALLTHROUGH) From patchwork Mon Sep 5 08:36:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 12965830 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9444AECAAA1 for ; Mon, 5 Sep 2022 08:38:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236333AbiIEIiz (ORCPT ); Mon, 5 Sep 2022 04:38:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236977AbiIEIiL (ORCPT ); Mon, 5 Sep 2022 04:38:11 -0400 Received: from conuserg-08.nifty.com (conuserg-08.nifty.com [210.131.2.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC75E1A06F; Mon, 5 Sep 2022 01:37:45 -0700 (PDT) Received: from zoe.. (133-32-182-133.west.xps.vectant.ne.jp [133.32.182.133]) (authenticated) by conuserg-08.nifty.com with ESMTP id 2858aYjE013979; Mon, 5 Sep 2022 17:36:35 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com 2858aYjE013979 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1662366996; bh=KusObtaX7Ag7sc+HekaUhYfJGxNdYNFdGQ0FDlAuqWQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TAoL0IwUki+XcjS/ltKVdSfc09ebVkONdrUqkDk48xkjpdxK7itGNH7bxm9sV+H/y weRKAsZaN5C8pJEogdKbEaIGNk764fHAFkkbIh0bc5uZnu6eY9zOHHoQ6aS6FQ2SbG VpzgRMveAOBHhRQcQ4VXQBnyyp7b3ypt2EpTPfGoKEUyYZQ6DR2BfA5/WGOYTDkTfG xi3mIBSnABQYo1RKUAi7vkqAtb3n5Ndze0/eksQR2qT/zweqok/13mDwVNDIQCYcBi QqNGUEHIA2ZoFkG/7Q4WGBCy4HSFEMKu3bG3yi0xxkWXIlXIIccLd1/fMsdTSq10mg WNpCbuqofnyWA== X-Nifty-SrcIP: [133.32.182.133] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , Michal Marek , Nick Desaulniers , linux-kernel@vger.kernel.org Subject: [PATCH 2/2] kbuild: move -Wundef from KBUILD_CFLAGS to KBUILD_CPPFLAGS Date: Mon, 5 Sep 2022 17:36:19 +0900 Message-Id: <20220905083619.672091-2-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220905083619.672091-1-masahiroy@kernel.org> References: <20220905083619.672091-1-masahiroy@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org The use of an undefined macro in an #if directive is warned, but only in *.c files. No warning from other files such as *.S, *.lds.S. Since -Wundef is a preprocessor-related warning, it should be added to KBUILD_CPPFLAGS instead of KBUILD_CFLAGS. Signed-off-by: Masahiro Yamada Reported-by: kernel test robot Reported-by: kernel test robot --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 027d9163eff6..898a759e314e 100644 --- a/Makefile +++ b/Makefile @@ -523,12 +523,12 @@ LINUXINCLUDE := \ $(USERINCLUDE) KBUILD_AFLAGS := -D__ASSEMBLY__ -fno-PIE -KBUILD_CFLAGS := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \ +KBUILD_CFLAGS := -Wall -Werror=strict-prototypes -Wno-trigraphs \ -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \ -Werror=implicit-function-declaration -Werror=implicit-int \ -Werror=return-type -Wno-format-security \ -std=gnu11 -KBUILD_CPPFLAGS := -D__KERNEL__ +KBUILD_CPPFLAGS := -D__KERNEL__ -Wundef KBUILD_AFLAGS_KERNEL := KBUILD_CFLAGS_KERNEL := KBUILD_AFLAGS_MODULE := -DMODULE