Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1481857ybl; Wed, 28 Aug 2019 15:39:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqw71zBdbTSFjJ9ro6yqK7h1ftrzXXlScVUk66j7EuWlbxJ8th07llHE1y9ao8YbTDuFCCVA X-Received: by 2002:a17:902:4b:: with SMTP id 69mr6703479pla.89.1567031992190; Wed, 28 Aug 2019 15:39:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567031992; cv=none; d=google.com; s=arc-20160816; b=CWhcS80Y8HC9EVBL5FUhXU5sKtEMR7iUM2OcXjaXJ0a1KC5jQdI69CIhGRng6e2HT8 DXBHTgnwsL87awMhNJ8UWEZyOFu5McvbFxQyuby5pa8TL/rIJcXih/vfctepsbchFP2R /5Mbvi42v4+uV1opNXs8DUF+7qyuGTH5olMV1grfdrXK6S+Oq46yn4zXqSKBnvK1YU01 27O0qlbLvQU4qrnaIHUEqAFqH7X3D6+DaIn2lLdWdv1hrRpC9QoDqBaWVAWcPMEKTnXN ip+ZYVSOqiZut1c5kfj489i4G7J81PY7rpShHToYY2skpIqw2DPNOcpRbwo/rnCWcWwe 79zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Bu9OOhELnfJg8/oQexJ+kW+4EUent3eZnfgOh/MjmqQ=; b=rrmdqUyS+sNTS9GWTgnarvLxfbk+7C9sZwuk4uXpQskn3NPvaZeRAHpukuZNiX/1pv I+80zfgjRrcIRrIw6Q/CoCuMAxWDBH10Cb7rRNcyGlZqAAELJmkuxEJmVOaAQ/sefu+A or/s7IL5CVdA4xKEj1Ja2/GM0g3EZPhc/MVL4CNd2kGuZXr7h/4vGJzzCUOqJx3dm2pk v8ykvDa269wMSQ6qPgM2QBm9uFHigEu4xfC/S3krNXWcxkZA+nVW99fWJG5w26CUftdr DlqeUwP67NK27oFuXIyaWuAvgWsKvR2GDOg4tgtMNzCVWBXfjzWL0TD0ye8kogc+Rzys KDNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="IKxFKuX/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y15si493898pfb.28.2019.08.28.15.39.30; Wed, 28 Aug 2019 15:39:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="IKxFKuX/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726947AbfH1Wi2 (ORCPT + 99 others); Wed, 28 Aug 2019 18:38:28 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:39706 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726844AbfH1Wi2 (ORCPT ); Wed, 28 Aug 2019 18:38:28 -0400 Received: by mail-pf1-f195.google.com with SMTP id y200so689410pfb.6 for ; Wed, 28 Aug 2019 15:38:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Bu9OOhELnfJg8/oQexJ+kW+4EUent3eZnfgOh/MjmqQ=; b=IKxFKuX/GZTqj5EV2CQW8Wx38kfPXRfcWO0Uf0CObqMOk/HyWrpeHaaHHpvfp3CFC+ vmFKfoaTXgWaFECgKo7iadeIZWC3dIrTKP0mQrVT7sOUyHacxqeWpRZH4+qsHmZMfyaU E6k1z+9q/f7+hNO9ql3XoNUKTC+FkXkL3CZLK2HiLfFhBbAMULY7wiUWckD/6j59EvPG R63tGsTxB1VtzXyR6SlvpMVDT2XGgPS9sckJXtjeHdnIkUgFX0MX/+bSPVozligUwKET XHIF3/tQzufRIKl47FlfiqWPpJFuBb92gEApiEVUEIUU3czbnwCzEMjPYIkAuNH6M/kg C99w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Bu9OOhELnfJg8/oQexJ+kW+4EUent3eZnfgOh/MjmqQ=; b=hseqShmTPPYNpHpYuXxZmHDxaASwzg1na8fcnZE+QBegPdubGs8VRh+8Udt4xoJrTn 7RxiV5uHqD9i/lhlcD0kJnBdsa4SA1JNC7Ki19+a8NO63VjBOHkA8UiPv8WbI33jk3eQ axhywHsZLL1WzObZgNSVDvIv5vMt9fThe23Ebi46ybEyE23jIaEIiNrTAORjYn1Ly5R8 hsOeU5cQgiDkmGGKrC/zWFGITlWvN63VDsnUxLf69chu2bk9g7dbIG9PKYLOgkE6QjOd 2i2BThgt9mwNRT8W3k+vVlF+29bwTdlyhIpWPbNUs0nArnXE+CR0BZwqS1edjphjR1oo Ffsg== X-Gm-Message-State: APjAAAULRaZfh+D6IxxIR9BkolfirFgidYDF4zN94rdfNWnTxw1ccMry mVAfappFuavSFoEkpmRJ/CsieWJaNuEyU//y9qoBCA== X-Received: by 2002:a63:60a:: with SMTP id 10mr5401454pgg.381.1567031907022; Wed, 28 Aug 2019 15:38:27 -0700 (PDT) MIME-Version: 1.0 References: <20190828055425.24765-1-yamada.masahiro@socionext.com> In-Reply-To: <20190828055425.24765-1-yamada.masahiro@socionext.com> From: Nick Desaulniers Date: Wed, 28 Aug 2019 15:38:15 -0700 Message-ID: Subject: Re: [PATCH 1/2] kbuild: refactor scripts/Makefile.extrawarn To: Masahiro Yamada Cc: Linux Kbuild mailing list , Nathan Chancellor , Miguel Ojeda , Arnd Bergmann , Michal Marek , clang-built-linux , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 27, 2019 at 10:54 PM Masahiro Yamada wrote: > > Instead of the warning-[123] magic, let's accumulate compiler options > to KBUILD_CFLAGS directly as the top Makefile does. I think this makes > easier to understand what is going on in this file. > > This commit slightly changes the behavior, I think all of which are OK. > > [1] Currently, cc-option calls are needlessly evaluated. For example, > warning-3 += $(call cc-option, -Wpacked-bitfield-compat) > needs evaluating only when W=3, but it is actually evaluated for > W=1, W=2 as well. With this commit, only relevant cc-option calls > will be evaluated. This is a slight optimization. > > [2] Currently, unsupported level like W=4 is checked by: > $(error W=$(KBUILD_ENABLE_EXTRA_GCC_CHECKS) is unknown) > This will no longer be checked, but I do not think it is a big > deal. > > [3] Currently, 4 Clang warnings (Winitializer-overrides, Wformat, > Wsign-compare, Wformat-zero-length) are shown by any of W=1, W=2, > and W=3. With this commit, they will be warned only by W=1. I > think this is a more correct behavior since each warning belongs > to only one warning level. > > Signed-off-by: Masahiro Yamada > --- > > scripts/Makefile.extrawarn | 104 +++++++++++++++++++------------------ > 1 file changed, 53 insertions(+), 51 deletions(-) > > diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn > index a74ce2e3c33e..1fa53968e292 100644 > --- a/scripts/Makefile.extrawarn > +++ b/scripts/Makefile.extrawarn > @@ -1,14 +1,6 @@ > # SPDX-License-Identifier: GPL-2.0 > # ========================================================================== > -# > # make W=... settings > -# > -# W=1 - warnings that may be relevant and does not occur too often > -# W=2 - warnings that occur quite often but may still be relevant > -# W=3 - the more obscure warnings, can most likely be ignored > -# > -# $(call cc-option, -W...) handles gcc -W.. options which > -# are not supported by all versions of the compiler > # ========================================================================== > > KBUILD_CFLAGS += $(call cc-disable-warning, packed-not-aligned) > @@ -17,58 +9,68 @@ ifeq ("$(origin W)", "command line") > export KBUILD_ENABLE_EXTRA_GCC_CHECKS := $(W) > endif > > -ifdef KBUILD_ENABLE_EXTRA_GCC_CHECKS > -warning- := $(empty) > +# > +# W=1 - warnings that may be relevant and does not occur too often > +# > +ifneq ($(findstring 1, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),) > > -warning-1 := -Wextra -Wunused -Wno-unused-parameter > -warning-1 += -Wmissing-declarations > -warning-1 += -Wmissing-format-attribute > -warning-1 += -Wmissing-prototypes > -warning-1 += -Wold-style-definition > -warning-1 += -Wmissing-include-dirs > -warning-1 += $(call cc-option, -Wunused-but-set-variable) > -warning-1 += $(call cc-option, -Wunused-const-variable) > -warning-1 += $(call cc-option, -Wpacked-not-aligned) > -warning-1 += $(call cc-option, -Wstringop-truncation) > +KBUILD_CFLAGS += -Wextra -Wunused -Wno-unused-parameter > +KBUILD_CFLAGS += -Wmissing-declarations > +KBUILD_CFLAGS += -Wmissing-format-attribute > +KBUILD_CFLAGS += -Wmissing-prototypes > +KBUILD_CFLAGS += -Wold-style-definition > +KBUILD_CFLAGS += -Wmissing-include-dirs > +KBUILD_CFLAGS += $(call cc-option, -Wunused-but-set-variable) > +KBUILD_CFLAGS += $(call cc-option, -Wunused-const-variable) > +KBUILD_CFLAGS += $(call cc-option, -Wpacked-not-aligned) > +KBUILD_CFLAGS += $(call cc-option, -Wstringop-truncation) > # The following turn off the warnings enabled by -Wextra > -warning-1 += -Wno-missing-field-initializers > -warning-1 += -Wno-sign-compare > - > -warning-2 += -Wcast-align > -warning-2 += -Wdisabled-optimization > -warning-2 += -Wnested-externs > -warning-2 += -Wshadow > -warning-2 += $(call cc-option, -Wlogical-op) > -warning-2 += -Wmissing-field-initializers > -warning-2 += -Wsign-compare > -warning-2 += $(call cc-option, -Wmaybe-uninitialized) > -warning-2 += $(call cc-option, -Wunused-macros) > - > -warning-3 := -Wbad-function-cast > -warning-3 += -Wcast-qual > -warning-3 += -Wconversion > -warning-3 += -Wpacked > -warning-3 += -Wpadded > -warning-3 += -Wpointer-arith > -warning-3 += -Wredundant-decls > -warning-3 += -Wswitch-default > -warning-3 += $(call cc-option, -Wpacked-bitfield-compat) > - > -warning := $(warning-$(findstring 1, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS))) > -warning += $(warning-$(findstring 2, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS))) > -warning += $(warning-$(findstring 3, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS))) > - > -ifeq ("$(strip $(warning))","") > - $(error W=$(KBUILD_ENABLE_EXTRA_GCC_CHECKS) is unknown) > -endif > +KBUILD_CFLAGS += -Wno-missing-field-initializers > +KBUILD_CFLAGS += -Wno-sign-compare > > -KBUILD_CFLAGS += $(warning) > else > > +# W=1 also stops suppressing some warnings > + > ifdef CONFIG_CC_IS_CLANG > KBUILD_CFLAGS += -Wno-initializer-overrides > KBUILD_CFLAGS += -Wno-format > KBUILD_CFLAGS += -Wno-sign-compare > KBUILD_CFLAGS += -Wno-format-zero-length > endif I find this part of the patch exceedingly confusing, and I think it mistakenly changes the behavior of W=2, W=3, and W=4. If W != 1 && CC == clang, then disable some flags? What? So W=2,3,4 those are disabled, but at W=1 are not? Didn't the previous version set these unless any W= was set? > + > +endif > + > +# > +# W=2 - warnings that occur quite often but may still be relevant > +# > +ifneq ($(findstring 2, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),) > + > +KBUILD_CFLAGS += -Wcast-align > +KBUILD_CFLAGS += -Wdisabled-optimization > +KBUILD_CFLAGS += -Wnested-externs > +KBUILD_CFLAGS += -Wshadow > +KBUILD_CFLAGS += $(call cc-option, -Wlogical-op) > +KBUILD_CFLAGS += -Wmissing-field-initializers > +KBUILD_CFLAGS += -Wsign-compare > +KBUILD_CFLAGS += $(call cc-option, -Wmaybe-uninitialized) > +KBUILD_CFLAGS += $(call cc-option, -Wunused-macros) > + > +endif > + > +# > +# W=3 - the more obscure warnings, can most likely be ignored > +# > +ifneq ($(findstring 3, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),) > + > +KBUILD_CFLAGS += -Wbad-function-cast > +KBUILD_CFLAGS += -Wcast-qual > +KBUILD_CFLAGS += -Wconversion > +KBUILD_CFLAGS += -Wpacked > +KBUILD_CFLAGS += -Wpadded > +KBUILD_CFLAGS += -Wpointer-arith > +KBUILD_CFLAGS += -Wredundant-decls > +KBUILD_CFLAGS += -Wswitch-default > +KBUILD_CFLAGS += $(call cc-option, -Wpacked-bitfield-compat) > + > endif > -- > 2.17.1 > -- Thanks, ~Nick Desaulniers