Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7533803rwb; Wed, 23 Nov 2022 07:39:36 -0800 (PST) X-Google-Smtp-Source: AA0mqf4QRcbBbnO6faQ7JmeYs4qEY/RMOouNH9iiYiUL44s++c2a+TOJsmedVekqrjGL5vkB4hNV X-Received: by 2002:a62:e218:0:b0:572:30f2:af50 with SMTP id a24-20020a62e218000000b0057230f2af50mr11145639pfi.24.1669217976603; Wed, 23 Nov 2022 07:39:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669217976; cv=none; d=google.com; s=arc-20160816; b=fPpBk3J3V9fMgYV+o6YtnB6yWyYNekt1TdNFa2UF43sN8VxqOjivTCc02qkAIqz8tt aP2b6KsGVD5aLsx62OzwgiJvOM2O9QIBC/PS0WInTUDtB2sw5BE6BLGqu5Q8gmtyBfK7 TMaOXtbADMLIrheCJx2CK4PJxG1N7c6kDV2yFEcvKPMtVlnlp1kJTLpEB9JcJJJ/DSbU EmWTFZQ4vrHHzfJOIMtwhxRr+lwliZdItvtszSad13CuMABG5gWYJeG3P0sQUxp85eqH WNyfv37K+1HbpgTc9/rWPXE4z9TdMao2hMlVLMSxKeXLJwURu4LU+LVpIwoNs8lFcgg0 SFjw== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e17-20020a17090301d100b0016f1781307csi2086923plh.303.2022.11.23.07.39.24; Wed, 23 Nov 2022 07:39:36 -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 + 88 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 Content-Transfer-Encoding: 8bit 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 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 --- 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) -- 2.34.1