Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp882047pxb; Mon, 16 Aug 2021 21:21:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8aRs/0NQPYcQ/Ebwg8qSvVVgTOQ1QXyKMeQT41d0r3kx6H8xs/V5snuRBqRjM0/awOrd3 X-Received: by 2002:a92:7d07:: with SMTP id y7mr1061682ilc.68.1629174087131; Mon, 16 Aug 2021 21:21:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629174087; cv=none; d=google.com; s=arc-20160816; b=R+fW5QSYvM8wzSjEczkxguCy6UuhFJmVTRhfRfLuf3GFHl02kY6haLgur4No4wMaBj MroPLn1h2EKNl5b043QJ8oBwROXh3vkbiw7EAvgflRSvRE0PfOXmFTTfDfDAJPx5PdH6 cGTH+kHoasr5OalNqs/S4sc/Z7ZEE0hflXgEB3KAIKbiSedOTbeSRr26iZI46jB/SGol aEa4LThBNaflxn4j9bHU7i5uTW35YmIQsxKNEtUwp3zyKNSz/yz9pyOYnabnp2/XRON2 cLUpdAzBNTVIW0etOJ47F8WSUgR3WWCoFA9vKrfuRmFpSmUXGbBKry4rtbLXyTPONThi 2KRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=bGyGi/HXZfs2KTisFec4aWzo1FTCWcim0jsJyhKQXD4=; b=wENFmnzD9yKTDX5NJVutXDJRQYNVNDZbi7Uermc/2q0N54XZ0ZhbDn+jSKiLQQGTSV uVXAX1DtyBgflTwz4ocxzr5f/xE86ekmoC1SFarZ9tp4jULRht262Q38MvBNa70D9Pkz Kdo6NTxU/D5C1O0zBMDD4w+3vGyef6lBx6PHakHrIli6kt4uTkRyX4GvbLWA6iSk4LF6 LW2y9vDzYihlOIcDBtd3aTWkHz4qSCKVTRkRlt8mNTCGKJ6oXToeR/3KBosVssQw2tCn d8XctSdN9JyyCO7QE1QsD8dnE2CxU1+Q7z3A94D53XdxZZcKV6/txhCEZxMPOa44j+j4 O9zQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=T0Wiz+2r; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t17si1123944ilp.119.2021.08.16.21.21.15; Mon, 16 Aug 2021 21:21:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=T0Wiz+2r; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237418AbhHQEVI (ORCPT + 99 others); Tue, 17 Aug 2021 00:21:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:33782 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229754AbhHQEVH (ORCPT ); Tue, 17 Aug 2021 00:21:07 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4F7AE60F35; Tue, 17 Aug 2021 04:20:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1629174035; bh=LwXAxW/JbRYjdBCqrHlZG4O/OKef14aoTixFDdZAp1g=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=T0Wiz+2rYAqmYBvxPhY+nP2pHfXU/XE+e7umtS+vPE3zQztFvVZF9upFQaqWUK+eS H/TnKzuaZXXArPKTKlZ3RAASWszSIJZYWkad2pednSRfx+Qd+dIMoJnz1mfQXi7yyH BQIcPy2VjpXB1jYwPT271i09mFYsx81EvLClobVY68SCMn1oD8vBcRuZPTD0TG+D04 PXvCXUWql8LlETLAg1BQo055DIyWuCflGmPpxOOHO95gu4Qc9+WuGvgpVE4mDG54aj plQXt/fCMqg1TBfhuXq1zf+pm5MHvy4gWNO+UY2sVHD8EMr016tIFAduudPdVj/M9j kLbJFEwsH6Saw== Subject: Re: [PATCH] kbuild: Enable -Wimplicit-fallthrough for clang 14.0.0+ To: "Gustavo A. R. Silva" , Linus Torvalds Cc: Kees Cook , Nick Desaulniers , Masahiro Yamada , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com References: <20210817005624.1455428-1-nathan@kernel.org> From: Nathan Chancellor Message-ID: <80fa539a-b767-76ed-dafa-4d8d1a6b063e@kernel.org> Date: Mon, 16 Aug 2021 21:20:33 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20210817005624.1455428-1-nathan@kernel.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/16/2021 5:56 PM, Nathan Chancellor wrote: > Clang prior to 14.0.0 warns when a fallthrough annotation is in an > unreachable spot, which can occur when IS_ENABLED(CONFIG_...) in a > conditional statement prior to the fallthrough annotation such as > > if (IS_ENABLED(CONFIG_...)) > break; > fallthrough; > > which to clang looks like > > break; > fallthrough; > > if CONFIG_... is enabled due to the control flow graph. Example of the > warning in practice: > > sound/core/pcm_native.c:3812:3: warning: fallthrough annotation in > unreachable code [-Wimplicit-fallthrough] > fallthrough; > ^ > > Warning on unreachable annotations makes the warning too noisy and > pointless for the kernel due to the nature of guarding some code on > configuration options so it was disabled in commit d936eb238744 ("Revert > "Makefile: Enable -Wimplicit-fallthrough for Clang""). > > This has been resolved in clang 14.0.0 by moving the unreachable warning > to its own flag under -Wunreachable-code, which the kernel will most > likely never enable due to situations like this. > > Enable -Wimplicit-fallthrough for clang 14+ so that issues such as the > one in commit 652b44453ea9 ("habanalabs/gaudi: fix missing code in ECC > handling") can be caught before they enter the tree. > > Link: https://github.com/ClangBuiltLinux/linux/issues/236 > Link: https://github.com/llvm/llvm-project/commit/9ed4a94d6451046a51ef393cd62f00710820a7e8 > Signed-off-by: Nathan Chancellor > --- > Makefile | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/Makefile b/Makefile > index c19d1638da25..91a4a80409e1 100644 > --- a/Makefile > +++ b/Makefile > @@ -797,11 +797,17 @@ KBUILD_CFLAGS += -Wno-gnu > # source of a reference will be _MergedGlobals and not on of the whitelisted names. > # See modpost pattern 2 > KBUILD_CFLAGS += -mno-global-merge > + > +# Warn about unmarked fall-throughs in switch statement. > +# Clang prior to 14.0.0 warned on unreachable fallthroughs with > +# -Wimplicit-fallthrough, which is unacceptable due to IS_ENABLED(). > +# https://bugs.llvm.org/show_bug.cgi?id=51094 > +ifeq ($(shell test $(CONFIG_CLANG_VERSION) -ge 140000; echo $$?),0) > +KBUILD_CFLAGS += -Wimplicit-fallthrough > +endif > else > > # Warn about unmarked fall-throughs in switch statement. > -# Disabled for clang while comment to attribute conversion happens and > -# https://github.com/ClangBuiltLinux/linux/issues/636 is discussed. > KBUILD_CFLAGS += $(call cc-option,-Wimplicit-fallthrough=5,) > endif > > > base-commit: a2824f19e6065a0d3735acd9fe7155b104e7edf5 > Please do not apply this patch in its current form, as it does not properly credit Gustavo for all of the hard work he has done for enabling this warning. Additionally, there should be some time for the CI systems to update their clang-14 builds, as the recent 0day report shows. Cheers, Nathan