From patchwork Wed Nov 23 15:18:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 25053 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2856296wrr; Wed, 23 Nov 2022 07:27:10 -0800 (PST) X-Google-Smtp-Source: AA0mqf5Eh0FqJA5SzO4cOzMwDoMfnVD4Cm/FYS6pQ21v+EXQycUERZ8cxjq4xiU2M8Ky7AsWlGYF X-Received: by 2002:a17:90a:3d41:b0:213:d34:a80b with SMTP id o1-20020a17090a3d4100b002130d34a80bmr31406719pjf.74.1669217229765; Wed, 23 Nov 2022 07:27:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669217229; cv=none; d=google.com; s=arc-20160816; b=MdocVQX+nFCmcsQuoUP33mOpmnqVMv5nGGbDaE9zo4Vt2fyZD3y5vcuuQTQ90hBkfr NWB7CZ9ThWYCAGLk0nAaAcwudOznCti+41WAB1Te55WmtlqqzI/aMHAOmqCS8TFCSK1x gp/c+LDdNDM6Z4HFsBR4O0Io+Du2Aki+pGpWF0p83MNiCaUg6g8fgpM03dvVka9eylXX R4yM/MKewryzFtg+wKb/09loqRySXZiUwIC82Q1tfJk9wr9JXWJaMeuweH/ynXKM4SbS DKJItZXWg9gx3rRpQiROFnx4TyZSK4ZtM6Y8fmFrhoSov4do6HKuEQ25aTKCA/yzvvmI CE0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ztVMqwpl2gT9e14Dt5zPLHVaAGsq5p/P2n7WKdzzQ4c=; b=BCz1Bl5SDlkiUHEWRNS9YqnqoWjHjX2jopuvhEtTcAcjER70N/QzPQb0Y8zMfmxMgA m6jwJ1yEpp0yxhPp8L+m1241IYE1rwshJK96oWI+XmxnFiB5mIhnGMeOeRs8Q+MrW8jf S6Pnz+VD3MYz4QgfoyJXyC1/cST0cvZBE0HuhVGfcPgMQiyWfcVtqep7IrMxcNeLqVH7 huDnSvr/ts9Uo9YDvVATIlug6w0UPws/dv2Z9vQ0iwrnSjG+sfy5k/mtHh2nC+/yQhUG tpmWLZ4I9Ukc4aWcnTt6FrUVrqk/LyuM7m79F6yP0AcfncTLZptCbRcsC2yf41aCJTvQ dMmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=u78ZRFdh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x14-20020aa79ace000000b0056ea2b142b6si16266641pfp.373.2022.11.23.07.26.55; Wed, 23 Nov 2022 07:27:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=u78ZRFdh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S238487AbiKWPTa (ORCPT + 99 others); Wed, 23 Nov 2022 10:19:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237256AbiKWPT1 (ORCPT ); Wed, 23 Nov 2022 10:19:27 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F2872AE08; Wed, 23 Nov 2022 07:19:26 -0800 (PST) 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 14AF0B8201C; Wed, 23 Nov 2022 15:19:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1E926C433D6; Wed, 23 Nov 2022 15:19:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669216763; bh=zZ9vzObwysMPcl9yyFyu+hM9JhD2sJD/mwetUOgE8Dc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u78ZRFdhLLKDOiXCo43KHNi5x4eN+sGMnlkZhZxhh3Zo0KVTH0mpwpKJoTiizKtaw UMEtdoP5kGu2uwa92JY1T16CK+MW1zge+M3dhb1ztCGfyNyycOs/Ses6zKE2tpIwc2 /V1N2q5WazBhktgQHq26rhp21iNgXR5vg58MchCLIBNIdtW4VTQcn2MBX2QV0d2JP3 Kggcc4K2uibSlJkbFNo496Fzv4PM2P1a3WoFr32yWGh6fB84EkxOdqgfl57WUCpbMu guv5ppWMHxrcwqfxWb+2V9j1zhrskW9jryNi0H1Io6Uu+w9YTTHBg+L4oSqHB6OjE0 p+QAlYHf/p0Pw== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , Nicolas Schier , Tom Rix , llvm@lists.linux.dev Subject: [PATCH v2 2/5] kbuild: implement {gcc,clang}-min-version only with built-in functions Date: Thu, 24 Nov 2022 00:18:25 +0900 Message-Id: <20221123151828.509565-2-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221123151828.509565-1-masahiroy@kernel.org> References: <20221123151828.509565-1-masahiroy@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750301125922908996?= X-GMAIL-MSGID: =?utf-8?q?1750301125922908996?= Converting clang-min-version is straightforward because the versions are always 6-digit. gcc-min-version is somewhat tricky because the minimal GCC version is GCC 5.2; prepend '0' to the version that is less than 10 so that test-ge is always passed with 6-digit versions. Signed-off-by: Masahiro Yamada Reviewed-by: Nicolas Schier --- Changes in v2: - Covert gcc-min-version in a different way scripts/Makefile.compiler | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/Makefile.compiler b/scripts/Makefile.compiler index 20d353dcabfb..cd75f81e88ef 100644 --- a/scripts/Makefile.compiler +++ b/scripts/Makefile.compiler @@ -63,11 +63,15 @@ cc-disable-warning = $(call try-run,\ # gcc-min-version # Usage: cflags-$(call gcc-min-version, 70100) += -foo -gcc-min-version = $(shell [ $(CONFIG_GCC_VERSION)0 -ge $(1)0 ] && echo y) + +# Preprend 0 to the version that is less than 10 so test-ge works. +gcc-min-version = $(call test-ge, \ + $(or $(filter 1%, $(CONFIG_GCC_VERSION)), 0$(CONFIG_GCC_VERSION)), \ + $(or $(filter 1%, $1), 0$(strip $1))) # clang-min-version # Usage: cflags-$(call clang-min-version, 110000) += -foo -clang-min-version = $(shell [ $(CONFIG_CLANG_VERSION)0 -ge $(1)0 ] && echo y) +clang-min-version = $(call test-ge, $(CONFIG_CLANG_VERSION), $1) # ld-option # Usage: KBUILD_LDFLAGS += $(call ld-option, -X, -Y)