From patchwork Fri Mar 1 07:10:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 10834569 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 15EB01399 for ; Fri, 1 Mar 2019 07:10:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE6682F529 for ; Fri, 1 Mar 2019 07:10:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E32FF2F675; Fri, 1 Mar 2019 07:10:54 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham 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 8D7102F5BE for ; Fri, 1 Mar 2019 07:10:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727707AbfCAHKy (ORCPT ); Fri, 1 Mar 2019 02:10:54 -0500 Received: from conuserg-10.nifty.com ([210.131.2.77]:16716 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726823AbfCAHKx (ORCPT ); Fri, 1 Mar 2019 02:10:53 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-10.nifty.com with ESMTP id x217APwr017759; Fri, 1 Mar 2019 16:10:25 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com x217APwr017759 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1551424225; bh=8t7excQEtZ3k0zZuNz5dRZOkstOKAajR6OxsjLRcbGs=; h=From:To:Cc:Subject:Date:From; b=uQ3era+zc3DAxv59/5kHhrafsI8uOdFCVnltLf4qo+rFtb/qRpK6N/qh+3wbdC3m5 /KSBiTDjm/UdqEg5iV06b8d/KYx/6XwFKi/Wywj956et37/0zE1mJXqeHeU+wBxpzW w4T4ybSG8ihRkglQSM5zAyIJRdyh/xnIvIj3Q55fgC0BuA86miIlqgait9YjblAm6C C03KepwLTtIlnejmSxf79q2XAk7/NzHL3khsESCRDXUzyOugG6Q90WOuYU4a/wXTlE itY6JFYH3Ghp4XZ7f1rzdkqLYa7kzVRAGv14YHcqmtANczl27ccHBqmoapf0IQpfmp slt+jhmWvPYUQ== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 1/3] kbuild: update comment block of scripts/clang-version.sh Date: Fri, 1 Mar 2019 16:10:20 +0900 Message-Id: <1551424222-3727-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 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 Commit 469cb7376c06 ("kconfig: add CC_IS_CLANG and CLANG_VERSION") changed the code, but missed to update the comment block. The -p option was gone, and the output is 5-digit (or 6-digit when Clang 10 is released). Update the comment now. Signed-off-by: Masahiro Yamada --- scripts/clang-version.sh | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/scripts/clang-version.sh b/scripts/clang-version.sh index e65fbc3..6fabf06 100755 --- a/scripts/clang-version.sh +++ b/scripts/clang-version.sh @@ -1,14 +1,10 @@ #!/bin/sh # SPDX-License-Identifier: GPL-2.0 # -# clang-version [-p] clang-command -# -# Prints the compiler version of `clang-command' in a canonical 4-digit form -# such as `0500' for clang-5.0 etc. -# -# With the -p option, prints the patchlevel as well, for example `050001' for -# clang-5.0.1 etc. +# clang-version clang-command # +# Print the compiler version of `clang-command' in a 5 or 6-digit form +# such as `50001' for clang-5.0.1 etc. compiler="$*" From patchwork Fri Mar 1 07:10:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 10834573 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0C7201399 for ; Fri, 1 Mar 2019 07:11:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ECF732F5BE for ; Fri, 1 Mar 2019 07:11:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E17BE2F68E; Fri, 1 Mar 2019 07:11:07 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham 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 7745D2F65A for ; Fri, 1 Mar 2019 07:11:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731869AbfCAHLH (ORCPT ); Fri, 1 Mar 2019 02:11:07 -0500 Received: from conuserg-10.nifty.com ([210.131.2.77]:17147 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726036AbfCAHLH (ORCPT ); Fri, 1 Mar 2019 02:11:07 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-10.nifty.com with ESMTP id x217APws017759; Fri, 1 Mar 2019 16:10:26 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com x217APws017759 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1551424226; bh=ePc3zu1pq/u4/yjsicbC/fuitXjH2YJiwIfWsJXCxDg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A2BS+upCGQVuwDAR31FfzgDjbuwt0ph2DhwutBFWobEcpXMzfpoPSJ31RsjRgO+4R 0o8lcb+HbBfd2JdNF2hJhc6gbjKfdXEjIxqnI4MrCZd5vtM6hHT6bvPpcSbL406vAK Gb5PySYpZGyIhbYQDzO5WM+xt+6nqqTG29K4S51hoDgxtsazwKTkDbnXZcFkdo4M2b SkxvANNV1VBHW9GF3oa2Awg5w09vm85sEl8zT9XMRgAiigJKLQObYNyU+wJcAqVjkA VkoIgrDrG4xTyr9AEJcHxtFlxK8NFlwUIFJxzATmjlOqbs1q4gSNj/DnNhiNHQZ1jP tm0Xw9aQQ4HaA== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan Corbet , Michal Marek Subject: [PATCH 2/3] kbuild: remove cc-version macro Date: Fri, 1 Mar 2019 16:10:21 +0900 Message-Id: <1551424222-3727-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1551424222-3727-1-git-send-email-yamada.masahiro@socionext.com> References: <1551424222-3727-1-git-send-email-yamada.masahiro@socionext.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 There is no more direct user of this macro; it is only used by cc-ifversion. Calling this macro is not efficient since it invokes the compiler to get the compiler version. CONFIG_GCC_VERSION is already calculated in the Kconfig stage, so Makefile can reuse it. Here is a note about the slight difference between cc-version and CONFIG_GCC_VERSION: When using Clang, cc-version is evaluated to '0402' because Clang defines __GNUC__ and __GNUC__MINOR__, and looks like GCC 4.2 in the version point of view. On the other hand, CONFIG_GCC_VERSION=0 when $(CC) is clang. There are currently two users of cc-ifversion: arch/mips/loongson64/Platform arch/powerpc/Makefile They are not affected by this change. The format of cc-version is , while CONFIG_GCC_VERSION . I adjusted cc-ifversion for the difference of the number of digits. Signed-off-by: Masahiro Yamada --- Documentation/kbuild/makefiles.txt | 17 ----------------- scripts/Kbuild.include | 5 +---- 2 files changed, 1 insertion(+), 21 deletions(-) diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt index 48eab0b..f124be6 100644 --- a/Documentation/kbuild/makefiles.txt +++ b/Documentation/kbuild/makefiles.txt @@ -499,23 +499,6 @@ more details, with real examples. In the above example, -Wno-unused-but-set-variable will be added to KBUILD_CFLAGS only if gcc really accepts it. - cc-version - cc-version returns a numerical version of the $(CC) compiler version. - The format is where both are two digits. So for example - gcc 3.41 would return 0341. - cc-version is useful when a specific $(CC) version is faulty in one - area, for example -mregparm=3 was broken in some gcc versions - even though the option was accepted by gcc. - - Example: - #arch/x86/Makefile - cflags-y += $(shell \ - if [ $(cc-version) -ge 0300 ] ; then \ - echo "-mregparm=3"; fi ;) - - In the above example, -mregparm=3 is only used for gcc version greater - than or equal to gcc 3.0. - cc-ifversion cc-ifversion tests the version of $(CC) and equals the fourth parameter if version expression is true, or the fifth (if given) if the version diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index d93250b..b59983e 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -138,12 +138,9 @@ cc-option-yn = $(call try-run,\ cc-disable-warning = $(call try-run,\ $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1))) -# cc-version -cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC)) - # cc-ifversion # Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1) -cc-ifversion = $(shell [ $(cc-version) $(1) $(2) ] && echo $(3) || echo $(4)) +cc-ifversion = $(shell [ $(CONFIG_GCC_VERSION)0 $(1) $(2)000 ] && echo $(3) || echo $(4)) # cc-ldoption # Usage: ldflags += $(call cc-ldoption, -Wl$(comma)--hash-style=both) From patchwork Fri Mar 1 07:10:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 10834571 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BB1741390 for ; Fri, 1 Mar 2019 07:11:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A4CC52889B for ; Fri, 1 Mar 2019 07:11:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 990212F65A; Fri, 1 Mar 2019 07:11:03 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham 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 080A22F619 for ; Fri, 1 Mar 2019 07:11:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731278AbfCAHK4 (ORCPT ); Fri, 1 Mar 2019 02:10:56 -0500 Received: from conuserg-10.nifty.com ([210.131.2.77]:16717 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726036AbfCAHKy (ORCPT ); Fri, 1 Mar 2019 02:10:54 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-10.nifty.com with ESMTP id x217APwt017759; Fri, 1 Mar 2019 16:10:26 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com x217APwt017759 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1551424226; bh=C0sHvPANucd8+RgfELTY1HPKylG28HrnpVhzUAgdkk0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2d9PP7OBoHFTitYH2UMIfMvNNqNPknytSM9VQng+F2Gmc1kx8uGd03p+jQ8t3EQDK lZ46v3lDLI2ifd3Hzt4XuXQAZ/lzXtlIZhVX5JLPUrtxvBI1s0bvfS3An1j/pMvaEn v+oq5IVsZJulIm3lzfU+PYW8WMOXiCnI4IkWJxIOykzmlRgFyoyPxtiPVCjDzAJhuH tVUF1ILoQxhdsVEuZcFqvHdmCi3X7OKtfQOm9pqqn/W46WQQ5b8PFp+3mU3vpqCXzR bsKArSqls5lTrTRnJ8qSndTHLqMChD4Y5Dt+LB7JEmcVafb9wQWZHOVfQbS1p36Cx8 VFbVeyk7OJdIg== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 3/3] kbuild: clean up scripts/gcc-version.sh Date: Fri, 1 Mar 2019 16:10:22 +0900 Message-Id: <1551424222-3727-3-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1551424222-3727-1-git-send-email-yamada.masahiro@socionext.com> References: <1551424222-3727-1-git-send-email-yamada.masahiro@socionext.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 Now that the Kconfig is the only user of this script, we can drop unneeded code. Remove the -p option, and stop prepending the output with zero, so that Kconfig can directly use the output from this script. Signed-off-by: Masahiro Yamada --- init/Kconfig | 2 +- scripts/Kconfig.include | 2 +- scripts/gcc-version.sh | 27 +++++++-------------------- 3 files changed, 9 insertions(+), 22 deletions(-) diff --git a/init/Kconfig b/init/Kconfig index 1f05a88..74a0217 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -13,7 +13,7 @@ config CC_IS_GCC config GCC_VERSION int - default $(shell,$(srctree)/scripts/gcc-version.sh -p $(CC) | sed 's/^0*//') if CC_IS_GCC + default $(shell,$(srctree)/scripts/gcc-version.sh $(CC)) if CC_IS_GCC default 0 config CC_IS_CLANG diff --git a/scripts/Kconfig.include b/scripts/Kconfig.include index dad5583..87ff1dc 100644 --- a/scripts/Kconfig.include +++ b/scripts/Kconfig.include @@ -27,4 +27,4 @@ cc-option = $(success,$(CC) -Werror $(1) -E -x c /dev/null -o /dev/null) ld-option = $(success,$(LD) -v $(1)) # gcc version including patch level -gcc-version := $(shell,$(srctree)/scripts/gcc-version.sh -p $(CC) | sed 's/^0*//') +gcc-version := $(shell,$(srctree)/scripts/gcc-version.sh $(CC)) diff --git a/scripts/gcc-version.sh b/scripts/gcc-version.sh index 11bb909..ae35343 100755 --- a/scripts/gcc-version.sh +++ b/scripts/gcc-version.sh @@ -1,33 +1,20 @@ #!/bin/sh # SPDX-License-Identifier: GPL-2.0 # -# gcc-version [-p] gcc-command -# -# Prints the gcc version of `gcc-command' in a canonical 4-digit form -# such as `0295' for gcc-2.95, `0303' for gcc-3.3, etc. -# -# With the -p option, prints the patchlevel as well, for example `029503' for -# gcc-2.95.3, `030301' for gcc-3.3.1, etc. +# gcc-version gcc-command # - -if [ "$1" = "-p" ] ; then - with_patchlevel=1; - shift; -fi +# Print the gcc version of `gcc-command' in a 5 or 6-digit form +# such as `29503' for gcc-2.95.3, `30301' for gcc-3.3.1, etc. compiler="$*" if [ ${#compiler} -eq 0 ]; then - echo "Error: No compiler specified." - printf "Usage:\n\t$0 \n" + echo "Error: No compiler specified." >&2 + printf "Usage:\n\t$0 \n" >&2 exit 1 fi MAJOR=$(echo __GNUC__ | $compiler -E -x c - | tail -n 1) MINOR=$(echo __GNUC_MINOR__ | $compiler -E -x c - | tail -n 1) -if [ "x$with_patchlevel" != "x" ] ; then - PATCHLEVEL=$(echo __GNUC_PATCHLEVEL__ | $compiler -E -x c - | tail -n 1) - printf "%02d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL -else - printf "%02d%02d\\n" $MAJOR $MINOR -fi +PATCHLEVEL=$(echo __GNUC_PATCHLEVEL__ | $compiler -E -x c - | tail -n 1) +printf "%d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL