Message ID | 1458666816-29778-1-git-send-email-mchandras@suse.de (mailing list archive) |
---|---|
State | Accepted, archived |
Delegated to: | Thomas Monjalon |
Headers |
Return-Path: <dev-bounces@dpdk.org> X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 86C792BDD; Tue, 22 Mar 2016 19:07:49 +0100 (CET) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by dpdk.org (Postfix) with ESMTP id BAEB92BA9 for <dev@dpdk.org>; Tue, 22 Mar 2016 18:13:41 +0100 (CET) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id DB69DACB3 for <dev@dpdk.org>; Tue, 22 Mar 2016 17:13:40 +0000 (UTC) From: Markos Chandras <mchandras@suse.de> To: dev@dpdk.org Cc: Markos Chandras <mchandras@suse.de> Date: Tue, 22 Mar 2016 17:13:36 +0000 Message-Id: <1458666816-29778-1-git-send-email-mchandras@suse.de> X-Mailer: git-send-email 2.7.3 X-Mailman-Approved-At: Tue, 22 Mar 2016 19:07:47 +0100 Subject: [dpdk-dev] [PATCH] mk: toolchain: gcc: query the compiler macros to obtain the gcc version X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK <dev.dpdk.org> List-Unsubscribe: <http://dpdk.org/ml/options/dev>, <mailto:dev-request@dpdk.org?subject=unsubscribe> List-Archive: <http://dpdk.org/ml/archives/dev/> List-Post: <mailto:dev@dpdk.org> List-Help: <mailto:dev-request@dpdk.org?subject=help> List-Subscribe: <http://dpdk.org/ml/listinfo/dev>, <mailto:dev-request@dpdk.org?subject=subscribe> Errors-To: dev-bounces@dpdk.org Sender: "dev" <dev-bounces@dpdk.org> |
Commit Message
Markos Chandras
March 22, 2016, 5:13 p.m. UTC
This is similar to what's being used in the Linux kernel. Querying the
GCC macros directly gives more accurate results compared to -dumpversion
which could vary across distributions.
Signed-off-by: Markos Chandras <mchandras@suse.de>
---
In openSUSE Tumbleweed (and in any other SUSE distribution which
uses (or will use) gcc >= 5), gcc -dumpversion returns '5'. This is on
purpose as discussed in https://bugzilla.opensuse.org/show_bug.cgi?id=941428
As a result of which, the gcc-4.x comparison (40 against 5) does not
work leading to tons of warnings and failures during build. This patch
aims to change the way the gcc version is obtained by using the gcc macros
directly.
---
mk/toolchain/gcc/rte.toolchain-compat.mk | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
Comments
2016-03-22 17:13, Markos Chandras: > This is similar to what's being used in the Linux kernel. Querying the > GCC macros directly gives more accurate results compared to -dumpversion > which could vary across distributions. > > Signed-off-by: Markos Chandras <mchandras@suse.de> > --- > In openSUSE Tumbleweed (and in any other SUSE distribution which > uses (or will use) gcc >= 5), gcc -dumpversion returns '5'. This is on > purpose as discussed in https://bugzilla.opensuse.org/show_bug.cgi?id=941428 Good to know. It could be in the commit log. > As a result of which, the gcc-4.x comparison (40 against 5) does not > work leading to tons of warnings and failures during build. This patch > aims to change the way the gcc version is obtained by using the gcc macros > directly. Thanks for catching. > -GCC_VERSION = $(subst .,,$(shell $(CC) -dumpversion | cut -f1-2 -d.)) > +GCC_MAJOR = $(shell echo __GNUC__ | $(CC) -E -x c - | tail -n 1) > +GCC_MINOR = $(shell echo __GNUC_MINOR__ | $(CC) -E -x c - | tail -n 1) > +GCC_VERSION = $(GCC_MAJOR)$(GCC_MINOR) Are we sure the minor will always be only one digit?
Hi, On 22/03/16 22:34, Thomas Monjalon wrote: > 2016-03-22 17:13, Markos Chandras: >> This is similar to what's being used in the Linux kernel. Querying the >> GCC macros directly gives more accurate results compared to -dumpversion >> which could vary across distributions. >> >> Signed-off-by: Markos Chandras <mchandras@suse.de> >> --- >> In openSUSE Tumbleweed (and in any other SUSE distribution which >> uses (or will use) gcc >= 5), gcc -dumpversion returns '5'. This is on >> purpose as discussed in https://bugzilla.opensuse.org/show_bug.cgi?id=941428 > > Good to know. It could be in the commit log. I can add this information to the commit message and send a v2 if needed. > >> -GCC_VERSION = $(subst .,,$(shell $(CC) -dumpversion | cut -f1-2 -d.)) >> +GCC_MAJOR = $(shell echo __GNUC__ | $(CC) -E -x c - | tail -n 1) >> +GCC_MINOR = $(shell echo __GNUC_MINOR__ | $(CC) -E -x c - | tail -n 1) >> +GCC_VERSION = $(GCC_MAJOR)$(GCC_MINOR) > > Are we sure the minor will always be only one digit? > Well, I can't be sure but minor has always been a single digit since gcc >= 3 if I am not mistaken. But does it matter? What if it is two or more digits? The previous code did something similar so if you had gcc 5.12.34 installed (and lets assume this is what is being returned by -dumpversion), it would have returned 512. The comparison would still work as it is at the moment no?
2016-03-22 22:50, Markos Chandras: > On 22/03/16 22:34, Thomas Monjalon wrote: > > 2016-03-22 17:13, Markos Chandras: > >> This is similar to what's being used in the Linux kernel. Querying the > >> GCC macros directly gives more accurate results compared to -dumpversion > >> which could vary across distributions. > >> > >> Signed-off-by: Markos Chandras <mchandras@suse.de> > >> --- > >> In openSUSE Tumbleweed (and in any other SUSE distribution which > >> uses (or will use) gcc >= 5), gcc -dumpversion returns '5'. This is on > >> purpose as discussed in https://bugzilla.opensuse.org/show_bug.cgi?id=941428 > > > > Good to know. It could be in the commit log. > > I can add this information to the commit message and send a v2 if needed. I will apply with this info. > >> -GCC_VERSION = $(subst .,,$(shell $(CC) -dumpversion | cut -f1-2 -d.)) > >> +GCC_MAJOR = $(shell echo __GNUC__ | $(CC) -E -x c - | tail -n 1) > >> +GCC_MINOR = $(shell echo __GNUC_MINOR__ | $(CC) -E -x c - | tail -n 1) > >> +GCC_VERSION = $(GCC_MAJOR)$(GCC_MINOR) > > > > Are we sure the minor will always be only one digit? > > Well, I can't be sure but minor has always been a single digit since gcc > >= 3 if I am not mistaken. But does it matter? What if it is two or more > digits? The previous code did something similar so if you had gcc > 5.12.34 installed (and lets assume this is what is being returned by > -dumpversion), it would have returned 512. The comparison would still > work as it is at the moment no? Yes, I was asking for an improvement in case it could happen. But GCC is probably conservative with numbering so we can keep only one digit.
On 03/23/2016 09:49 AM, Thomas Monjalon wrote: > 2016-03-22 22:50, Markos Chandras: >> On 22/03/16 22:34, Thomas Monjalon wrote: >>> 2016-03-22 17:13, Markos Chandras: >>>> This is similar to what's being used in the Linux kernel. Querying the >>>> GCC macros directly gives more accurate results compared to -dumpversion >>>> which could vary across distributions. >>>> >>>> Signed-off-by: Markos Chandras <mchandras@suse.de> >>>> --- >>>> In openSUSE Tumbleweed (and in any other SUSE distribution which >>>> uses (or will use) gcc >= 5), gcc -dumpversion returns '5'. This is on >>>> purpose as discussed in https://bugzilla.opensuse.org/show_bug.cgi?id=941428 >>> >>> Good to know. It could be in the commit log. >> >> I can add this information to the commit message and send a v2 if needed. > > I will apply with this info. Thank you Thomas.
2016-03-22 17:13, Markos Chandras: > This is similar to what's being used in the Linux kernel. Querying the > GCC macros directly gives more accurate results compared to -dumpversion > which could vary across distributions. > > Signed-off-by: Markos Chandras <mchandras@suse.de> > --- > In openSUSE Tumbleweed (and in any other SUSE distribution which > uses (or will use) gcc >= 5), gcc -dumpversion returns '5'. This is on > purpose as discussed in https://bugzilla.opensuse.org/show_bug.cgi?id=941428 > As a result of which, the gcc-4.x comparison (40 against 5) does not > work leading to tons of warnings and failures during build. This patch > aims to change the way the gcc version is obtained by using the gcc macros > directly. > --- Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com> Applied, thanks
diff --git a/mk/toolchain/gcc/rte.toolchain-compat.mk b/mk/toolchain/gcc/rte.toolchain-compat.mk index e144216..6eed20c 100644 --- a/mk/toolchain/gcc/rte.toolchain-compat.mk +++ b/mk/toolchain/gcc/rte.toolchain-compat.mk @@ -38,7 +38,9 @@ #find out GCC version -GCC_VERSION = $(subst .,,$(shell $(CC) -dumpversion | cut -f1-2 -d.)) +GCC_MAJOR = $(shell echo __GNUC__ | $(CC) -E -x c - | tail -n 1) +GCC_MINOR = $(shell echo __GNUC_MINOR__ | $(CC) -E -x c - | tail -n 1) +GCC_VERSION = $(GCC_MAJOR)$(GCC_MINOR) # if GCC is older than 4.x ifeq ($(shell test $(GCC_VERSION) -lt 40 && echo 1), 1)