From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,TRACKER_ID,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5F81C3A5A1 for ; Wed, 28 Aug 2019 07:20:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8F37E217F5 for ; Wed, 28 Aug 2019 07:20:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gna4DkQN" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726529AbfH1HUg (ORCPT ); Wed, 28 Aug 2019 03:20:36 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:38278 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726328AbfH1HUg (ORCPT ); Wed, 28 Aug 2019 03:20:36 -0400 Received: by mail-wm1-f66.google.com with SMTP id o184so837670wme.3; Wed, 28 Aug 2019 00:20:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:reply-to:from:date:message-id :subject:to:cc; bh=m/1xpIzC+XYlVD64Z0IJa2mF9XyPRy3AeZIkoZXGzMo=; b=gna4DkQNcwGwTSZ2FyWnRWVUKoNEjyPCN1gCD0L6u1OvPXZRkT8AQXC6w0+ixGTieX /usU7OTZVunXxzVQJGu60teKh+5dpWKhj4qysfqIwiW0HIIi/s2QEwFUI1dmnr8lUiBx jYpIGVMTh07OSyaFBXUfYIMXo5Yj26oyXVAP34iA2fCwenMPODWAmm6uYUbzDXtQzP6b tO/BME7kwMGC9OCs9uO7RgxD5SgxiFSDhW/ILJfXYPhUiaAAgXKgLhpV4QNplLkRaj83 U976dWOooMuFdK1w8GucNL15anUIJyGBPvSkIon7UVX5HSODCeWsPZ54jSFHurwFQDAM QuYQ== 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:reply-to :from:date:message-id:subject:to:cc; bh=m/1xpIzC+XYlVD64Z0IJa2mF9XyPRy3AeZIkoZXGzMo=; b=gnleoB5ca2G4e/4+PvlN1Mi/rI4IweXYDQtqQPViYrjJMca3PNz6wqbC8h+coO6jc/ GghWH52012+YW0dVp1m45ei3jngNj9O5BpNECwfkTLj5qYTtIQmUmtzMmzEKx+L9Qxpl hXeZajDvzVVrrcE2UQf9mcqiqg5yO+Zi40vHIuDWHlkF0mk0+wszPc90CrciqjRlc45G 4auBfRAifkw/Ml+jgThb+4o9rAuOs8/FcqYY6yaCSFSaWluErRfoKL8iLz/oqUOxcrdy lAX7vJoCHuBf6k75PTzX28N+ngf+mUVANpNGDnVLtMrBAYH7cu34kLW0x1XdgRW7rOP+ BiPw== X-Gm-Message-State: APjAAAXVzomitlTf/l2HQ7o4pCcQLvMWy0kfl5vvWpbXrffpYS3XBJmT lnnSRiXl3AEIkqycHp94fJcLnQ8FAZuq9bmopco= X-Google-Smtp-Source: APXvYqzg2b1zHKS1UE3SO9g8GJZNkRHETMRIdkuowvcglJI472hmi9cccXIFIWXYAd+M4wBlPW4rhU08cKKITml0sqQ= X-Received: by 2002:a05:600c:225a:: with SMTP id a26mr3045439wmm.81.1566976832798; Wed, 28 Aug 2019 00:20:32 -0700 (PDT) MIME-Version: 1.0 References: <20190828055425.24765-1-yamada.masahiro@socionext.com> In-Reply-To: <20190828055425.24765-1-yamada.masahiro@socionext.com> Reply-To: sedat.dilek@gmail.com From: Sedat Dilek Date: Wed, 28 Aug 2019 09:20:21 +0200 Message-ID: Subject: Re: [PATCH 1/2] kbuild: refactor scripts/Makefile.extrawarn To: Masahiro Yamada Cc: linux-kbuild@vger.kernel.org, Nick Desaulniers , Nathan Chancellor , Miguel Ojeda , Arnd Bergmann , Michal Marek , Clang-Built-Linux ML , linux-kernel@vger.kernel.org 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 Wed, Aug 28, 2019 at 7:55 AM 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. > Hi Masahiro Yamada, thanks for your patch series. If KBUILD_ENABLE_EXTRA_GCC_CHECKS does extra(-warning)-checks for GCC and Clang, please rename the Kconfig into... KBUILD_ENABLE_EXTRA_CC_CHECKS ...or something similiar (and maybe with some notes in its Kconfig help-text?). Regards, - Sedat - > [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 > + > +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 > > -- > You received this message because you are subscribed to the Google Groups "Clang Built Linux" group. > To unsubscribe from this group and stop receiving emails from it, send an email to clang-built-linux+unsubscribe@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/20190828055425.24765-1-yamada.masahiro%40socionext.com.