* [dpdk-dev] [PATCH] mk: toolchain: gcc: query the compiler macros to obtain the gcc version
@ 2016-03-22 17:13 Markos Chandras
2016-03-22 22:34 ` Thomas Monjalon
2016-03-23 10:00 ` Thomas Monjalon
0 siblings, 2 replies; 6+ messages in thread
From: Markos Chandras @ 2016-03-22 17:13 UTC (permalink / raw)
To: dev; +Cc: 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.
---
mk/toolchain/gcc/rte.toolchain-compat.mk | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
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)
--
2.7.3
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH] mk: toolchain: gcc: query the compiler macros to obtain the gcc version
2016-03-22 17:13 [dpdk-dev] [PATCH] mk: toolchain: gcc: query the compiler macros to obtain the gcc version Markos Chandras
@ 2016-03-22 22:34 ` Thomas Monjalon
2016-03-22 22:50 ` Markos Chandras
2016-03-23 10:00 ` Thomas Monjalon
1 sibling, 1 reply; 6+ messages in thread
From: Thomas Monjalon @ 2016-03-22 22:34 UTC (permalink / raw)
To: Markos Chandras; +Cc: dev
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?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH] mk: toolchain: gcc: query the compiler macros to obtain the gcc version
2016-03-22 22:34 ` Thomas Monjalon
@ 2016-03-22 22:50 ` Markos Chandras
2016-03-23 9:49 ` Thomas Monjalon
0 siblings, 1 reply; 6+ messages in thread
From: Markos Chandras @ 2016-03-22 22:50 UTC (permalink / raw)
To: Thomas Monjalon; +Cc: 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 -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?
--
markos
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH] mk: toolchain: gcc: query the compiler macros to obtain the gcc version
2016-03-22 22:50 ` Markos Chandras
@ 2016-03-23 9:49 ` Thomas Monjalon
2016-03-23 9:56 ` Markos Chandras
0 siblings, 1 reply; 6+ messages in thread
From: Thomas Monjalon @ 2016-03-23 9:49 UTC (permalink / raw)
To: Markos Chandras; +Cc: dev
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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH] mk: toolchain: gcc: query the compiler macros to obtain the gcc version
2016-03-23 9:49 ` Thomas Monjalon
@ 2016-03-23 9:56 ` Markos Chandras
0 siblings, 0 replies; 6+ messages in thread
From: Markos Chandras @ 2016-03-23 9:56 UTC (permalink / raw)
To: Thomas Monjalon; +Cc: dev
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.
--
markos
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH] mk: toolchain: gcc: query the compiler macros to obtain the gcc version
2016-03-22 17:13 [dpdk-dev] [PATCH] mk: toolchain: gcc: query the compiler macros to obtain the gcc version Markos Chandras
2016-03-22 22:34 ` Thomas Monjalon
@ 2016-03-23 10:00 ` Thomas Monjalon
1 sibling, 0 replies; 6+ messages in thread
From: Thomas Monjalon @ 2016-03-23 10:00 UTC (permalink / raw)
To: Markos Chandras; +Cc: dev
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
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-03-23 10:01 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-22 17:13 [dpdk-dev] [PATCH] mk: toolchain: gcc: query the compiler macros to obtain the gcc version Markos Chandras
2016-03-22 22:34 ` Thomas Monjalon
2016-03-22 22:50 ` Markos Chandras
2016-03-23 9:49 ` Thomas Monjalon
2016-03-23 9:56 ` Markos Chandras
2016-03-23 10:00 ` Thomas Monjalon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).