Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3474858pxb; Mon, 4 Apr 2022 18:08:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+ynBIP36F568sM7l0a2Npj1/e7fgw9OFbgPkdv9wWHWp1pNfZ2FdBYAtx8UHdikas14B9 X-Received: by 2002:a65:6045:0:b0:399:3a5e:e25a with SMTP id a5-20020a656045000000b003993a5ee25amr733925pgp.139.1649120909398; Mon, 04 Apr 2022 18:08:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649120909; cv=none; d=google.com; s=arc-20160816; b=bl2XW9VVRd3H9sNFW7tzsQRVODeVgcfDNwKPhUgFwZ2QtyxpuUrRXc9zUfHy5aEmv7 t5HtQ3GP5paWfmID+kLNM9yy021HEPtSd1KFfhsiP/Y0smHRET17j22S0roetYGFkM51 6SXZVI7v7DAsOhcMN3MUhD6H6gYVkjz4iv8XUBEYGz9dZYC4Ab5wN02yze/nvbKJdAIr ux7dFuvuyFDrYHSL0b2kwG9ome2A8hKsuOV8Bp30nzE3stvGAdtnW2qTsoXy1k7xfq9D 2fnc7FPTSBLl9lwsJG0bhyLum6idRbUIFO74PdnxlnedXtJ1fB6qTreqZE89E0aDGT/Z 7MGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=JVo6PvtVtdgMxpd5jl/Skg5nwhAOZafV9+4dQT76pxY=; b=j5RJ6vno3LP/zS/ummmJV4id4Okb8LmfAGk0tFNGd3g3P3/cNdXcg43pgeZdi2KDcG MXo/7F5UDC7erUgqdBYdgEiArAW1UFzks/u9rfdyCDKrynPov3rdIa5ZQrsP1vPZUFlE 8xaiO9E+OJ24YhGoeHg3ElRPFPCVDgIOy/0mFYXGXtCBndViGtiUXfaXhs9h7jp3VsfB +rlPs/awycp2UTSgqPvXrtUXvez1723IMotw00x0Gb4gSitJXJbvHkSGW9R26AssEbex JIOcYtQZmYhvJ3eLZsDU/GxRd0kunapcbaci/7oTDhRtW5HvIoBw/wkeSoKpkrrN16oW zgcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bF3QJRnb; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id r28-20020a635d1c000000b0039905cd15f5si6840637pgb.574.2022.04.04.18.08.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 18:08:29 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bF3QJRnb; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 860FA158B8E; Mon, 4 Apr 2022 17:07:48 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242263AbiDDXNk (ORCPT + 99 others); Mon, 4 Apr 2022 19:13:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345218AbiDDXMN (ORCPT ); Mon, 4 Apr 2022 19:12:13 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D9CA393C7 for ; Mon, 4 Apr 2022 15:52:16 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id AF2C7B81A62 for ; Mon, 4 Apr 2022 22:52:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CFCC6C2BBE4; Mon, 4 Apr 2022 22:52:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1649112733; bh=54rQNEoc5ehhks896JDl4yq3WCx9/eYdhiBhR9iefCc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=bF3QJRnbcjc8y6fPNoXkVkRgf5gEx3NVFnuts+9skTbjtP9eot8cnBXlFI8pw4fuE GDxPaF9NNC+WKlfDsnXfLMOEPfRc4SbvvzHprSmilCsuJiNcMP9TXgJX0wirB2EJU0 1jt2jv3o/4kcckKRO0ZLqHFrWfTjDbf8Uy9BGbXRYBZHFHKIj0GPlWBKZvOJgZqbm9 5c2ejL+9CkNE5w62Iy313yMgPWNfOLxHEqB+RZKw2gQBiiajiu/lpyCo/x+BlNMkoK HVm2lhF8OwyNiL9R63NGAXx12znc6NTHCGZABalsH/d85DkPbOIyGTj3JVExakaPjy Smyk9vwpAPC8Q== Date: Mon, 4 Apr 2022 15:52:11 -0700 From: Nathan Chancellor To: Sami Tolvanen Cc: Masahiro Yamada , Kees Cook , Catalin Marinas , Mark Rutland , Nick Desaulniers , Will Deacon , linux-arm-kernel , Linux Kernel Mailing List , llvm@lists.linux.dev Subject: Re: [PATCH 1/3] kbuild: Change CFI_CLANG to depend on __builtin_function_start Message-ID: References: <20220401201916.1487500-1-samitolvanen@google.com> <20220401201916.1487500-2-samitolvanen@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 04, 2022 at 12:40:46PM -0700, Sami Tolvanen wrote: > On Sat, Apr 2, 2022 at 6:32 AM Masahiro Yamada wrote: > > > > On Sat, Apr 2, 2022 at 5:19 AM Sami Tolvanen wrote: > > > > > > Clang 14 added support for the __builtin_function_start() > > > built-in function, which allows us to implement function_nocfi() > > > without architecture-specific inline assembly. This patch changes > > > CONFIG_CFI_CLANG to depend on the built-in and effectively upgrades > > > the minimum supported compiler version for CFI to Clang 14. > > > > From this description, I think the straight-forward change would be: > > > > depends on CLANG_VERSION >= 120000 > > --> > > depends on CLANG_VERSION >= 140000 > > > > Any reason to avoid this? > > I thought testing for the compiler feature was preferred, but I can > certainly just increase the minimum version number here too. I think we have been somewhat inconsistent with feature versus version checking. It might be nice to hash out when a feature check should be done instead of a version one. Generally, I think we tend to prefer version checks, as they are "cheaper" since we do not have to call the compiler again because we already cached the version code. When adding version checks, our policy has always been use the upstream version of LLVM that the feature in question shipped in, even if it is a top of tree version, as people who are using prereleased versions of LLVM should be frequently updating them. Unfortunately, that does not always match reality. For example, Android's LLVM tracks the main branch but they are almost always behind by a few months. For example, the latest release is 14.0.4, based on a version of LLVM from January 28th: https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86/+/ab73cd180863dbd17fdb8f20e39b33ab38030cf9/clang-r450784b/clang_source_info.md https://github.com/llvm/llvm-project/commits/282c83c32384cb2f37030c28650fef4150a8b67c Normally, I would say "who cares?" but Android's LLVM is used by the Android kernel team both downstream and upstream, so I would argue it is important to take that into account when deciding to do a feature check versus a version check. In other words, by moving to a version check, will we knowingly break a version of clang that is relatively widely used? In this case, 14.0.4 has __builtin_function_start(), so I think it is okay to use a version check instead of a feature one. There are times where feature or problem checking is not always possible: https://lore.kernel.org/r/20220318230747.3900772-1-nathan@kernel.org/ In cases like these, we can work to upgrade the compiler before changing the feature check ot a version one, which helps minimize the window for breakage. Another aspect of feature versus version checks is that it is easier to clean up stale versions checks when we bump the minimum supported version of the compiler (as we can just look for "CLANG_VERSION" across the tree) compared to stale feature checks. We could fix this by adding some sort of common keyword, like Compiler check: like Compiler check: clang <= 14.0.0 Cheers, Nathan