From patchwork Wed Nov 29 00:00:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sami Tolvanen X-Patchwork-Id: 10081229 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8ACE660311 for ; Wed, 29 Nov 2017 00:00:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7AF6C2979C for ; Wed, 29 Nov 2017 00:00:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6FCBB297A2; Wed, 29 Nov 2017 00:00:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, URIBL_BLACK autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D2AD297A1 for ; Wed, 29 Nov 2017 00:00:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753413AbdK2AA3 (ORCPT ); Tue, 28 Nov 2017 19:00:29 -0500 Received: from mail-io0-f194.google.com ([209.85.223.194]:45189 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753068AbdK2AAZ (ORCPT ); Tue, 28 Nov 2017 19:00:25 -0500 Received: by mail-io0-f194.google.com with SMTP id e204so1803631iof.12 for ; Tue, 28 Nov 2017 16:00:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=g+ed8CyMh30/3wM3wW2FXsmSYbvr1XAOQGfZI5/9oUs=; b=V2kUF2zZLocRHoVrYuq02SyIXDH4yFkoZU95HbMfXo1c35V5fgphu6wBd9CojcOXh9 yfUVCXC2i/jotVydYLmiORwaevI4Qp1jEhHkTHS0LLzVXuPK9WOeL7IVqTQf+e+2Yzlw b49ftXrZDAiNF08GdpmF0wFZlNsEkooQ1hHdbD8KcDKEOhai/BwRNbj5AaPBpKYL3oju fEq4MzhKccDemCMG2OI2nw+VZdAxOpyt0XXtoMvMYJ/R+gsEWgbJBCdb5meAfWRKnytz wG94oebxpW9LsnoWvlbzWjkNOpsyEMVPBlqi32jOXSFhBbyQtaArBicSpMfwRg3NE1rL AWkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=g+ed8CyMh30/3wM3wW2FXsmSYbvr1XAOQGfZI5/9oUs=; b=QhkTqBmyKPXSbb2EyhoefG7uIshiWyMrn/TM5kZr4BGru2lBmgzsgP7siE1s0XrHc8 YiqjkmjJZfcvmSb3CpiRjT42AyN928352JYzaMbVvxGl2hZQsYmjf2SnPv443oAf9sFn NcBa2auMMVqT5w0sLa5xclonSckxRhOlmNKnVd7MLgjyunm7W5CxFSi3HM+4gSdF+3xF hkVb55FB4Lor/suCX3euNgw+7qkR80UhgLkNi+0DSXtCKnD4RAY99e8jKXzOgiR1yyvR /f/YHERQIdnL5W7oh/PozXWc1hzJ+tWBGa02pDIxYHrN3j0l0tinNFCOaGkPcGO+8+LB 9i8Q== X-Gm-Message-State: AJaThX7V5rLzdRT4XXdqEgq0CnsY7ytXAwdNoUCZwpEQF6ysLvkoYEin S9l2IMSbZtJhtY+NY7x9rUPSmg== X-Google-Smtp-Source: AGs4zMYBVwEuZr2+triPlupZQU6VlrAE0h8GcS0EWFmgvNG+VBbnzP0zzmxtr3/w8eUyE0sFfgy4IA== X-Received: by 10.107.46.159 with SMTP id u31mr1278554iou.2.1511913623943; Tue, 28 Nov 2017 16:00:23 -0800 (PST) Received: from samitolvanen.mtv.corp.google.com ([100.98.112.14]) by smtp.gmail.com with ESMTPSA id w68sm204836iow.18.2017.11.28.16.00.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Nov 2017 16:00:23 -0800 (PST) From: Sami Tolvanen To: Alex Matveev , Andi Kleen , Ard Biesheuvel , Greg Hackmann , Kees Cook , linux-arm-kernel@lists.infradead.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, Mark Rutland , Masahiro Yamada , Maxim Kuvyrkov , Michal Marek , Nick Desaulniers , Yury Norov , Matthias Kaehlcke Cc: Sami Tolvanen Subject: [PATCH 2/3] kbuild: add cc-if-name-version and compiler-specific variants Date: Tue, 28 Nov 2017 16:00:10 -0800 Message-Id: <20171129000011.55235-3-samitolvanen@google.com> X-Mailer: git-send-email 2.15.0.417.g466bffb3ac-goog In-Reply-To: <20171129000011.55235-1-samitolvanen@google.com> References: <20171129000011.55235-1-samitolvanen@google.com> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This change adds macros for testing both compiler name and version. Current cc-version, cc-ifversion etc. macros that test gcc version are left unchanged to prevent compatibility issues with existing tests. Signed-off-by: Sami Tolvanen --- scripts/Kbuild.include | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 065324a8046f..b6d7d347b203 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -215,6 +215,37 @@ cc-disable-warning = $(call try-run-cached,\ # Expands to either gcc or clang cc-name = $(call shell-cached,$(CC) -v 2>&1 | grep -q "clang version" && echo clang || echo gcc) +# __cc-version +# Returns compiler version +__cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/$(cc-name)-version.sh $(CC)) + +# __cc-fullversion +# Returns full compiler version +__cc-fullversion = $(shell $(CONFIG_SHELL) \ + $(srctree)/scripts/$(cc-name)-version.sh -p $(CC)) + +# cc-if-name-version +# Matches compiler name and version +# Usage: EXTRA_CFLAGS += $(call cc-if-name-version, gcc, -lt, 0402, -O1) +cc-if-name-version = $(shell [ $(cc-name) == $(1) ] && [ $(__cc-version) $(2) $(3) ] && echo $(4) || echo $(5)) + +# cc-if-name-fullversion +# Matches compiler name and full version +# Usage: EXTRA_CFLAGS += $(call cc-if-name-fullversion, gcc, -lt, 040502, -O1) +cc-if-name-fullversion = $(shell [ $(cc-name) == $(1) ] && [ $(__cc-fullversion) $(2) $(3) ] && echo $(4) || echo $(5)) + +# gcc-ifversion +gcc-ifversion = $(call cc-if-name-version, gcc, $(1), $(2), $(3), $(4)) + +# gcc-if-fullversion +gcc-if-fullversion = (call cc-if-name-fullversion, gcc, $(1), $(2), $(3), $(4)) + +# clang-ifversion +clang-ifversion = $(call cc-if-name-version, clang, $(1), $(2), $(3), $(4)) + +# clang-if-fullversion +clang-if-fullversion = (call cc-if-name-fullversion, clang, $(1), $(2), $(3), $(4)) + # cc-version cc-version = $(call shell-cached,$(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC))