From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f65.google.com ([209.85.221.65]:36197 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726390AbfGYRBJ (ORCPT ); Thu, 25 Jul 2019 13:01:09 -0400 Date: Thu, 25 Jul 2019 10:01:04 -0700 From: Nathan Chancellor Subject: Re: [PATCH v2] kbuild: Check for unknown options with cc-option usage in Kconfig and clang Message-ID: <20190725170104.GB80773@archlinux-threadripper> References: <20190725154730.80169-1-swboyd@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190725154730.80169-1-swboyd@chromium.org> Sender: linux-kbuild-owner@vger.kernel.org List-ID: To: Stephen Boyd Cc: Masahiro Yamada , Michal Marek , linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, clang-built-linux@googlegroups.com, Peter Smith , Nick Desaulniers , Douglas Anderson On Thu, Jul 25, 2019 at 08:47:30AM -0700, Stephen Boyd wrote: > If the particular version of clang a user has doesn't enable > -Werror=unknown-warning-option by default, even though it is the > default[1], then make sure to pass the option to the Kconfig cc-option > command so that testing options from Kconfig files works properly. > Otherwise, depending on the default values setup in the clang toolchain > we will silently assume options such as -Wmaybe-uninitialized are > supported by clang, when they really aren't. > > A compilation issue only started happening for me once commit > 589834b3a009 ("kbuild: Add -Werror=unknown-warning-option to > CLANG_FLAGS") was applied on top of commit b303c6df80c9 ("kbuild: > compute false-positive -Wmaybe-uninitialized cases in Kconfig"). This > leads kbuild to try and test for the existence of the > -Wmaybe-uninitialized flag with the cc-option command in > scripts/Kconfig.include, and it doesn't see an error returned from the > option test so it sets the config value to Y. Then the Makefile tries to > pass the unknown option on the command line and > -Werror=unknown-warning-option catches the invalid option and breaks the > build. Before commit 589834b3a009 ("kbuild: Add > -Werror=unknown-warning-option to CLANG_FLAGS") the build works fine, > but any cc-option test of a warning option in Kconfig files silently > evaluates to true, even if the warning option flag isn't supported on > clang. > > Note: This doesn't change cc-option usages in Makefiles because those > use a different rule that includes KBUILD_CFLAGS by default (see the > __cc-option command in scripts/Kbuild.incluide). The KBUILD_CFLAGS > variable already has the -Werror=unknown-warning-option flag set. Thanks > to Doug for pointing out the different rule. > > [1] https://clang.llvm.org/docs/DiagnosticsReference.html#wunknown-warning-option > Cc: Peter Smith > Cc: Nathan Chancellor > Cc: Nick Desaulniers > Cc: Douglas Anderson > Reviewed-by: Nathan Chancellor > Signed-off-by: Stephen Boyd Commit message wording looks better to me, thanks for the change! I think we might also want to add: Cc: stable@vger.kernel.org # 4.19+ in addition to Doug's suggested fixes tag because my patch has been AUTOSEL'd by Sasha: https://lore.kernel.org/lkml/20190719040732.17285-44-sashal@kernel.org/ https://git.kernel.org/sashal/linux-stable/c/a28859fa4fea5a834a53d86d51e502012ce09c57 Alternatively, I can just mention that this patch needs to be picked up in addition to that one when it is formally sent out in a stable review. Cheers, Nathan