From patchwork Thu Feb 21 04:13:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 158853 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp39035jaa; Wed, 20 Feb 2019 20:15:10 -0800 (PST) X-Google-Smtp-Source: AHgI3IZIt+JQ6c4LBop3e70c/SNJuzfdL8ANzRKscFJmVhguTanHwJiyl6UAKDcl/B0dF8kTclsi X-Received: by 2002:a62:12d5:: with SMTP id 82mr38493930pfs.255.1550722510848; Wed, 20 Feb 2019 20:15:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550722510; cv=none; d=google.com; s=arc-20160816; b=IoNYbBUk870zAFbqhjiUzU6nDrviJZjr5Ym873MyObENlkY9bAo0c+LeU1oq0//umn jVm3OCoGDApb0z91TaXIEVHm45h/8t+2fDArq6Cs0SjxOpdyY4XwtSrnSVAubn9XyZxy fhqIuT/gLYFtXBFXq/h2t0aLtkT4l45S1bOyCjeSkrK4ln8F8HaFu+YEpzQOBs2VCkqd DKfdVubfGk2raQlAOblsKuZsv0zyTqljaj6S+X6OzBANQaIa/hg2A5Vk1Q+6DkaxOuq/ 8LEhpCJ6ArT01UkZr/plFyEYauWmE5gNZtOJh/9fANazksdf4mWyuo7RzjA3hAOcK6ZL oX8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=WB8FMXiddfh/ANaSrDuHT7qAAFTezhEwjn+zv9LMKxk=; b=Z4IsJ21BYWv7pJEyiYfTLr6RuY4LDg1oqQtqLawRvDcriBA7pVu/ulFZdZe1QES6ar Wfode97JjPtA9MfCJ5mh3cJPUufHWfU87DGNgQy1KUkStC1CUHf21RKTfWnsUCzxnNxb 69QSDmEJMkKlmXclec/csRetiYnNp8qY3Oh9OUQUq5dK6s8GKQx4D6oPIp4yaxTiYvp5 Ads8rIXLxk7XhX2MD7TxoHuujdGPeMGc/xhugKnlY1hBTeP+ToIk6MM3jU2WR2+5dGzL jlWTQkuysSpYVyXR1vxD4wtoKmXFY8MN2cixJZNu3sochOV0Gkcp7XvgG5d6irjdpSn/ hEHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=zqsQA10S; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r4si18971744pgv.245.2019.02.20.20.15.10; Wed, 20 Feb 2019 20:15:10 -0800 (PST) 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=@nifty.com header.s=dec2015msa header.b=zqsQA10S; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727410AbfBUEPJ (ORCPT + 32 others); Wed, 20 Feb 2019 23:15:09 -0500 Received: from conuserg-12.nifty.com ([210.131.2.79]:25464 "EHLO conuserg-12.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726974AbfBUEPI (ORCPT ); Wed, 20 Feb 2019 23:15:08 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-12.nifty.com with ESMTP id x1L4Diq6000406; Thu, 21 Feb 2019 13:13:44 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com x1L4Diq6000406 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1550722425; bh=WB8FMXiddfh/ANaSrDuHT7qAAFTezhEwjn+zv9LMKxk=; h=From:To:Cc:Subject:Date:From; b=zqsQA10S48Vhczrf2cOmcTa4usH1M/6JX3zRn3UQTiT5cw+6Lsw8NdnqswNmXUUgU 7Tqso2pbk2Wbap+VzMshmwKh4ZQODB4YRbSQIeYSYQHdzCI8kpZ3ffF5LSKYGTxsKK CeTsgo2KwgXET4EjkcNBs8in+R5y6mBj1b8xkFaxwHxFsCpP1omE1QttGuip9QgQP8 6KCDO+cthiMROsCHvVNztEtXSRkHo732amhqKzO4OhwYBIQ9qSRYVbSaUkmFBMQJZR dcdMmTJfMp3kmnYOLThnooaDw6dIvLWmrt20m02gk+sZXDM6uMIcTrvScWszCPRMEd TOdAeJMB7bFKA== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Nick Desaulniers , Nathan Chancellor , Arnd Bergmann , Masahiro Yamada , Steven Rostedt , linux-kernel@vger.kernel.org, Michal Marek , Ingo Molnar Subject: [PATCH] kbuild: compute false-positive -Wmaybe-uninitialized cases in Kconfig Date: Thu, 21 Feb 2019 13:13:38 +0900 Message-Id: <1550722418-9189-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since -Wmaybe-uninitialized was introduced by GCC 4.7, we have patched various false positives: - commit e74fc973b6e5 ("Turn off -Wmaybe-uninitialized when building with -Os") turned off this option for -Os. - commit 815eb71e7149 ("Kbuild: disable 'maybe-uninitialized' warning for CONFIG_PROFILE_ALL_BRANCHES") turned off this option for CONFIG_PROFILE_ALL_BRANCHES - commit a76bcf557ef4 ("Kbuild: enable -Wmaybe-uninitialized warning for "make W=1"") turned off this option for GCC < 4.9 Arnd provided more explanation in https://lkml.org/lkml/2017/3/14/903 I think this looks better by shifting the logic from Makefile to Kconfig. Signed-off-by: Masahiro Yamada --- Makefile | 10 +++------- init/Kconfig | 17 +++++++++++++++++ kernel/trace/Kconfig | 1 + 3 files changed, 21 insertions(+), 7 deletions(-) -- 2.7.4 Reviewed-by: Nathan Chancellor Tested-by: Nick Desaulniers diff --git a/Makefile b/Makefile index 1bb0535..b21aa2e3 100644 --- a/Makefile +++ b/Makefile @@ -656,17 +656,13 @@ KBUILD_CFLAGS += $(call cc-disable-warning, int-in-bool-context) ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE KBUILD_CFLAGS += $(call cc-option,-Oz,-Os) -KBUILD_CFLAGS += $(call cc-disable-warning,maybe-uninitialized,) -else -ifdef CONFIG_PROFILE_ALL_BRANCHES -KBUILD_CFLAGS += -O2 $(call cc-disable-warning,maybe-uninitialized,) else KBUILD_CFLAGS += -O2 endif -endif -KBUILD_CFLAGS += $(call cc-ifversion, -lt, 0409, \ - $(call cc-disable-warning,maybe-uninitialized,)) +ifdef CONFIG_CC_DISABLE_WARN_MAYBE_UNINITIALIZED +KBUILD_CFLAGS += -Wno-maybe-uninitialized +endif # Tell gcc to never replace conditional load with a non-conditional one KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0) diff --git a/init/Kconfig b/init/Kconfig index c9386a3..1f05a88 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -26,6 +26,22 @@ config CLANG_VERSION config CC_HAS_ASM_GOTO def_bool $(success,$(srctree)/scripts/gcc-goto.sh $(CC)) +config CC_HAS_WARN_MAYBE_UNINITIALIZED + def_bool $(cc-option,-Wmaybe-uninitialized) + help + GCC >= 4.7 supports this option. + +config CC_DISABLE_WARN_MAYBE_UNINITIALIZED + bool + depends on CC_HAS_WARN_MAYBE_UNINITIALIZED + default CC_IS_GCC && GCC_VERSION < 40900 # unreliable for GCC < 4.9 + help + GCC's -Wmaybe-uninitialized is not reliable by definition. + Lots of false positive warnings are produced in some cases. + + If this option is enabled, -Wno-maybe-uninitialzed is passed + to the compiler to suppress maybe-uninitialized warnings. + config CONSTRUCTORS bool depends on !UML @@ -1113,6 +1129,7 @@ config CC_OPTIMIZE_FOR_PERFORMANCE config CC_OPTIMIZE_FOR_SIZE bool "Optimize for size" + imply CC_DISABLE_WARN_MAYBE_UNINITIALIZED # avoid false positives help Enabling this option will pass "-Os" instead of "-O2" to your compiler resulting in a smaller kernel. diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig index fa8b1fe..8bd1d6d 100644 --- a/kernel/trace/Kconfig +++ b/kernel/trace/Kconfig @@ -370,6 +370,7 @@ config PROFILE_ANNOTATED_BRANCHES config PROFILE_ALL_BRANCHES bool "Profile all if conditionals" if !FORTIFY_SOURCE select TRACE_BRANCH_PROFILING + imply CC_DISABLE_WARN_MAYBE_UNINITIALIZED # avoid false positives help This tracer profiles all branch conditions. Every if () taken in the kernel is recorded whether it hit or miss.