From mboxrd@z Thu Jan 1 00:00:00 1970 From: Markos Chandras Subject: Re: [PATCH] mk: toolchain: gcc: query the compiler macros to obtain the gcc version Date: Tue, 22 Mar 2016 22:50:08 +0000 Message-ID: <56F1CC20.50707@suse.de> References: <1458666816-29778-1-git-send-email-mchandras@suse.de> <2653966.ML0Fr8PsdQ@xps13> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Cc: dev@dpdk.org To: Thomas Monjalon Return-path: Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by dpdk.org (Postfix) with ESMTP id A877A559C for ; Tue, 22 Mar 2016 23:50:58 +0100 (CET) In-Reply-To: <2653966.ML0Fr8PsdQ@xps13> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 -dumpversi= on >> which could vary across distributions. >> >> Signed-off-by: Markos Chandras >> --- >> In openSUSE Tumbleweed (and in any other SUSE distribution which >> uses (or will use) gcc >=3D 5), gcc -dumpversion returns '5'. This is = on >> purpose as discussed in https://bugzilla.opensuse.org/show_bug.cgi?id=3D= 941428 >=20 > 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. >=20 >> -GCC_VERSION =3D $(subst .,,$(shell $(CC) -dumpversion | cut -f1-2 -d.= )) >> +GCC_MAJOR =3D $(shell echo __GNUC__ | $(CC) -E -x c - | tail -n 1) >> +GCC_MINOR =3D $(shell echo __GNUC_MINOR__ | $(CC) -E -x c - | tail -n= 1) >> +GCC_VERSION =3D $(GCC_MAJOR)$(GCC_MINOR) >=20 > Are we sure the minor will always be only one digit? >=20 Well, I can't be sure but minor has always been a single digit since gcc >=3D 3 if I am not mistaken. But does it matter? What if it is two or mor= e 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? --=20 markos