DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] build/x86: fix support for older compilers
@ 2025-07-02 15:51 Bruce Richardson
  2025-07-02 15:53 ` Bruce Richardson
  2025-07-02 16:00 ` [PATCH v2] " Bruce Richardson
  0 siblings, 2 replies; 4+ messages in thread
From: Bruce Richardson @ 2025-07-02 15:51 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson, Konstantin Ananyev, Vipin Varghese

Some older compilers e.g. gcc 8.5, do not support overriding
-march=native with another architecture, leading to build warnings such
as reported in Bugzilla (link below). Add a check for that case, and
explicitly add the avx512 flags if necessary.

Note: it appears that it is only the "native" flag that isn't
overridden, which makes the issue hard to reproduce e.g. using
godbolt.org, or on a modern machine. For example, testing with gcc 8.5
on a haswell machine, using 'native' vs explicit 'haswell':

gcc -march=native -march=skylake-avx512 -dM -E - < /dev/null | grep AVX

gcc -march=haswell -march=skylake-avx512 -dM -E - < /dev/null | grep AVX
...

Bugzilla ID: 1736
Fixes: e361ae3f59d3 ("build: reduce use of AVX compiler flags")

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 config/x86/meson.build | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/config/x86/meson.build b/config/x86/meson.build
index e2ccfb6d12..0dcc5ddee4 100644
--- a/config/x86/meson.build
+++ b/config/x86/meson.build
@@ -71,8 +71,13 @@ avx512_march_flag = '-march=x86-64-v4'
 if not cc.has_argument(avx512_march_flag)
     avx512_march_flag = '-march=skylake-avx512'
 endif
+# workaround for older compilers, e.g. gcc 8.5 on RHEL 8.
+# if march flag overriding doesn't work, explicitly add flags for AVX512.
+if cc.get_define('__AVX512F__', args: [machine_args, avx512_march_flag]) == ''
+    avx512_march_flag = ['-mavx512f', '-mavx512bw', '-mavx512cd', '-mavx512dq', '-mavx512vl']
+endif
 cc_avx512_flags = []
-if (binutils_ok and cc.has_argument(avx512_march_flag)
+if (binutils_ok and cc.has_multi_arguments(avx512_march_flag)
         and '-mno-avx512f' not in get_option('c_args'))
     # check if compiler is working with _mm512_extracti64x4_epi64
     # Ref: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82887
-- 
2.48.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] build/x86: fix support for older compilers
  2025-07-02 15:51 [PATCH] build/x86: fix support for older compilers Bruce Richardson
@ 2025-07-02 15:53 ` Bruce Richardson
  2025-07-02 16:00 ` [PATCH v2] " Bruce Richardson
  1 sibling, 0 replies; 4+ messages in thread
From: Bruce Richardson @ 2025-07-02 15:53 UTC (permalink / raw)
  To: dev; +Cc: Konstantin Ananyev, Vipin Varghese

On Wed, Jul 02, 2025 at 04:51:29PM +0100, Bruce Richardson wrote:
> Some older compilers e.g. gcc 8.5, do not support overriding
> -march=native with another architecture, leading to build warnings such
> as reported in Bugzilla (link below). Add a check for that case, and
> explicitly add the avx512 flags if necessary.
> 
> Note: it appears that it is only the "native" flag that isn't
> overridden, which makes the issue hard to reproduce e.g. using
> godbolt.org, or on a modern machine. For example, testing with gcc 8.5
> on a haswell machine, using 'native' vs explicit 'haswell':
> 
> gcc -march=native -march=skylake-avx512 -dM -E - < /dev/null | grep AVX
> 
> gcc -march=haswell -march=skylake-avx512 -dM -E - < /dev/null | grep AVX
> ...
> 

... and of course the output lines get stripped since they start with '#'
for '#define' :-(

> Bugzilla ID: 1736
> Fixes: e361ae3f59d3 ("build: reduce use of AVX compiler flags")
> 
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
>  config/x86/meson.build | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/config/x86/meson.build b/config/x86/meson.build
> index e2ccfb6d12..0dcc5ddee4 100644
> --- a/config/x86/meson.build
> +++ b/config/x86/meson.build
> @@ -71,8 +71,13 @@ avx512_march_flag = '-march=x86-64-v4'
>  if not cc.has_argument(avx512_march_flag)
>      avx512_march_flag = '-march=skylake-avx512'
>  endif
> +# workaround for older compilers, e.g. gcc 8.5 on RHEL 8.
> +# if march flag overriding doesn't work, explicitly add flags for AVX512.
> +if cc.get_define('__AVX512F__', args: [machine_args, avx512_march_flag]) == ''
> +    avx512_march_flag = ['-mavx512f', '-mavx512bw', '-mavx512cd', '-mavx512dq', '-mavx512vl']
> +endif
>  cc_avx512_flags = []
> -if (binutils_ok and cc.has_argument(avx512_march_flag)
> +if (binutils_ok and cc.has_multi_arguments(avx512_march_flag)
>          and '-mno-avx512f' not in get_option('c_args'))
>      # check if compiler is working with _mm512_extracti64x4_epi64
>      # Ref: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82887
> -- 
> 2.48.1
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2] build/x86: fix support for older compilers
  2025-07-02 15:51 [PATCH] build/x86: fix support for older compilers Bruce Richardson
  2025-07-02 15:53 ` Bruce Richardson
@ 2025-07-02 16:00 ` Bruce Richardson
  2025-07-02 18:22   ` Stephen Hemminger
  1 sibling, 1 reply; 4+ messages in thread
From: Bruce Richardson @ 2025-07-02 16:00 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson, Konstantin Ananyev, Vipin Varghese

Some older compilers e.g. gcc 8.5, do not support overriding
-march=native with another architecture, leading to build warnings such
as reported in Bugzilla (link below). Add a check for that case, and
explicitly add the avx512 flags if necessary.

Note: it appears that it is only the "native" flag that isn't
overridden, which makes the issue hard to reproduce e.g. using
godbolt.org, or on a modern machine. For example, testing with gcc 8.5
on a haswell machine, using 'native' vs explicit 'haswell':

gcc -march=native -march=skylake-avx512 -dM -E - < /dev/null | grep AVX512 | wc -l
0

gcc -march=haswell -march=skylake-avx512 -dM -E - < /dev/null | grep AVX512 | wc -l
5

Bugzilla ID: 1736
Fixes: e361ae3f59d3 ("build: reduce use of AVX compiler flags")

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 config/x86/meson.build | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/config/x86/meson.build b/config/x86/meson.build
index e2ccfb6d12..0dcc5ddee4 100644
--- a/config/x86/meson.build
+++ b/config/x86/meson.build
@@ -71,8 +71,13 @@ avx512_march_flag = '-march=x86-64-v4'
 if not cc.has_argument(avx512_march_flag)
     avx512_march_flag = '-march=skylake-avx512'
 endif
+# workaround for older compilers, e.g. gcc 8.5 on RHEL 8.
+# if march flag overriding doesn't work, explicitly add flags for AVX512.
+if cc.get_define('__AVX512F__', args: [machine_args, avx512_march_flag]) == ''
+    avx512_march_flag = ['-mavx512f', '-mavx512bw', '-mavx512cd', '-mavx512dq', '-mavx512vl']
+endif
 cc_avx512_flags = []
-if (binutils_ok and cc.has_argument(avx512_march_flag)
+if (binutils_ok and cc.has_multi_arguments(avx512_march_flag)
         and '-mno-avx512f' not in get_option('c_args'))
     # check if compiler is working with _mm512_extracti64x4_epi64
     # Ref: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82887
-- 
2.48.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] build/x86: fix support for older compilers
  2025-07-02 16:00 ` [PATCH v2] " Bruce Richardson
@ 2025-07-02 18:22   ` Stephen Hemminger
  0 siblings, 0 replies; 4+ messages in thread
From: Stephen Hemminger @ 2025-07-02 18:22 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev, Konstantin Ananyev, Vipin Varghese

On Wed,  2 Jul 2025 17:00:45 +0100
Bruce Richardson <bruce.richardson@intel.com> wrote:

> Some older compilers e.g. gcc 8.5, do not support overriding
> -march=native with another architecture, leading to build warnings such
> as reported in Bugzilla (link below). Add a check for that case, and
> explicitly add the avx512 flags if necessary.
> 
> Note: it appears that it is only the "native" flag that isn't
> overridden, which makes the issue hard to reproduce e.g. using
> godbolt.org, or on a modern machine. For example, testing with gcc 8.5
> on a haswell machine, using 'native' vs explicit 'haswell':
> 
> gcc -march=native -march=skylake-avx512 -dM -E - < /dev/null | grep AVX512 | wc -l
> 0
> 
> gcc -march=haswell -march=skylake-avx512 -dM -E - < /dev/null | grep AVX512 | wc -l
> 5
> 
> Bugzilla ID: 1736
> Fixes: e361ae3f59d3 ("build: reduce use of AVX compiler flags")
> 
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
>  config/x86/meson.build | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/config/x86/meson.build b/config/x86/meson.build
> index e2ccfb6d12..0dcc5ddee4 100644
> --- a/config/x86/meson.build
> +++ b/config/x86/meson.build
> @@ -71,8 +71,13 @@ avx512_march_flag = '-march=x86-64-v4'
>  if not cc.has_argument(avx512_march_flag)
>      avx512_march_flag = '-march=skylake-avx512'
>  endif
> +# workaround for older compilers, e.g. gcc 8.5 on RHEL 8.
> +# if march flag overriding doesn't work, explicitly add flags for AVX512.
> +if cc.get_define('__AVX512F__', args: [machine_args, avx512_march_flag]) == ''
> +    avx512_march_flag = ['-mavx512f', '-mavx512bw', '-mavx512cd', '-mavx512dq', '-mavx512vl']
> +endif

RHEL 8.5 reached end of extended support cycle (EOL).
Why are we still supporting it?

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-07-02 18:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-07-02 15:51 [PATCH] build/x86: fix support for older compilers Bruce Richardson
2025-07-02 15:53 ` Bruce Richardson
2025-07-02 16:00 ` [PATCH v2] " Bruce Richardson
2025-07-02 18:22   ` Stephen Hemminger

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).