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: 10081241 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 57860602DC for ; Wed, 29 Nov 2017 00:13:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4698B297A5 for ; Wed, 29 Nov 2017 00:13:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3B05E297AA; Wed, 29 Nov 2017 00:13:41 +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=-2.5 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_MED, URIBL_BLACK autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A1BAF297A5 for ; Wed, 29 Nov 2017 00:13:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=B/GUs0Pal9t65hKo7LMK6oWMqjfSTP2fFMFcw3LeHuo=; b=mTU1Cn109oC+nfEyB8NyoNlwuZ ukGtzdih7pg85sVfoTqnybGo1Wq6Lid0vcnJLbAkjH5EHrPXzBBfb9072jb8CjGz/MOfuA4wB+5LG +EWISwPqT+DuK9erEniXuhFmowAgBdO5ratIpt1JHkQe4hyHg4O4upPJSAvMZOSkRxfGtFexayVnU A9W/bEX/gK0PFZoZATsh2unkt3FNuxpf+6HOJYtL8srpuJIliYs++gc+ek6MolKDVGlwug3bqen23 TvWied9HfSleBJ29EGH6JsVeo2EQkwAkzGyGjX6ZP+D/FkE0VNU7y9Kxce+rmJ5PzqR1+rH/hYIQx Gn5rjTRA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eJq0R-0002jl-HL; Wed, 29 Nov 2017 00:13:39 +0000 Received: from mail-io0-x241.google.com ([2607:f8b0:4001:c06::241]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eJpnw-0006Ko-Ka for linux-arm-kernel@lists.infradead.org; Wed, 29 Nov 2017 00:00:46 +0000 Received: by mail-io0-x241.google.com with SMTP id q15so1847232ioh.2 for ; Tue, 28 Nov 2017 16:00:25 -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=Lrf3ShrGBge4Wnoff1ZPgcxIlsB3raGP6/UdLODPLQ4Z5oOMUV9s4uzlSs1a4pmlyJ Ano1gQ7Q5+JvFmoUJezQDZLRH4DA5Bjabt7hHPd0eDJSCOhRPhHZxmAHqw6ejcr27Prs zxNgKvg9W6HTNdqJpQr0Myt9TfDxyBs9rrYRl/Zr/KSv3jIt/5dWRgF24ebzEWxvnmL3 0nbf2RnJRDG+YD5zmc7RybyC6z6zzR2JP77e8MeCO9Fs6lMU1yRrrzMfYHEipCstj4eE uvWiT0nxafEXAk0WUKHXIRPRIG0Xv8Nuic4rhkyY+84wzo0bP02rFZ6FADWxQCvTebZq ecHg== X-Gm-Message-State: AJaThX4Lr4jBRKOnNL0l2cy+7FNmhkp8SxZ4YBOTuvQDNHZZ0jieiWZm 45ke/NxICTa3yAADDNQaLs6inQ== 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171128_160044_773951_F8B86D90 X-CRM114-Status: UNSURE ( 8.60 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sami Tolvanen MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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))