build: fix meson build when gcc >= 10.0

Message ID 20220607025652.1114683-1-wenxuanx.wu@intel.com (mailing list archive)
State Superseded, archived
Delegated to: David Marchand
Headers
Series build: fix meson build when gcc >= 10.0 |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-abi-testing success Testing PASS

Commit Message

Wu, WenxuanX June 7, 2022, 2:56 a.m. UTC
  From: Wenxuan Wu <wenxuanx.wu@intel.com>

GCC version greater than 10.0, with compile option -O2, several warnings info would appear,
this fix omitted these warnings.

Fixes: cfacbcb5a23b ("build: disable gcc 10 zero-length-bounds warning")
Cc: stable@dpdk.org

Signed-off-by: Wenxuan Wu <wenxuanx.wu@intel.com>
---
 config/meson.build | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
  

Comments

Thomas Monjalon June 7, 2022, 10:52 a.m. UTC | #1
07/06/2022 04:56, wenxuanx.wu@intel.com:
> From: Wenxuan Wu <wenxuanx.wu@intel.com>
> 
> GCC version greater than 10.0, with compile option -O2, several warnings info would appear,
> this fix omitted these warnings.
[...]
>  # FIXME: Bugzilla 396
> -    warning_flags += '-Wno-zero-length-bounds'
> +    warning_flags += [
> +      '-Wno-zero-length-bounds',
> +      '-Wno-stringop-overflow',
> +      '-Wno-array-bounds',
> +      '-Wno-format-overflow',

The compilers are reported warnings to help us having a better code.
We should try to resolve the warnings, not hiding them.
  
Stephen Hemminger June 7, 2022, 3:09 p.m. UTC | #2
On Tue, 07 Jun 2022 12:52:32 +0200
Thomas Monjalon <thomas@monjalon.net> wrote:

> 07/06/2022 04:56, wenxuanx.wu@intel.com:
> > From: Wenxuan Wu <wenxuanx.wu@intel.com>
> > 
> > GCC version greater than 10.0, with compile option -O2, several warnings info would appear,
> > this fix omitted these warnings.  
> [...]
> >  # FIXME: Bugzilla 396
> > -    warning_flags += '-Wno-zero-length-bounds'
> > +    warning_flags += [
> > +      '-Wno-zero-length-bounds',
> > +      '-Wno-stringop-overflow',
> > +      '-Wno-array-bounds',
> > +      '-Wno-format-overflow',  
> 
> The compilers are reported warnings to help us having a better code.
> We should try to resolve the warnings, not hiding them.
> 
> 

Agree with Thomas. This not how to address this.
There are fixes already for the zero-length-bounds that are being merged.
Patches accepted to fix the rest.
  
David Marchand June 7, 2022, 3:13 p.m. UTC | #3
On Tue, Jun 7, 2022 at 5:10 PM Stephen Hemminger
<stephen@networkplumber.org> wrote:
> On Tue, 07 Jun 2022 12:52:32 +0200
> Thomas Monjalon <thomas@monjalon.net> wrote:
> > 07/06/2022 04:56, wenxuanx.wu@intel.com:
> > > From: Wenxuan Wu <wenxuanx.wu@intel.com>
> > >
> > > GCC version greater than 10.0, with compile option -O2, several warnings info would appear,
> > > this fix omitted these warnings.
> > [...]
> > >  # FIXME: Bugzilla 396
> > > -    warning_flags += '-Wno-zero-length-bounds'
> > > +    warning_flags += [
> > > +      '-Wno-zero-length-bounds',
> > > +      '-Wno-stringop-overflow',
> > > +      '-Wno-array-bounds',
> > > +      '-Wno-format-overflow',
> >
> > The compilers are reported warnings to help us having a better code.
> > We should try to resolve the warnings, not hiding them.
> >
> >
>
> Agree with Thomas. This not how to address this.
> There are fixes already for the zero-length-bounds that are being merged.

I just merged them, though, afaics, they fix none of the compilation
issues reported with gcc 12.
  
Stephen Hemminger June 7, 2022, 3:25 p.m. UTC | #4
On Tue, 7 Jun 2022 17:13:07 +0200
David Marchand <david.marchand@redhat.com> wrote:

> On Tue, Jun 7, 2022 at 5:10 PM Stephen Hemminger
> <stephen@networkplumber.org> wrote:
> > On Tue, 07 Jun 2022 12:52:32 +0200
> > Thomas Monjalon <thomas@monjalon.net> wrote:  
> > > 07/06/2022 04:56, wenxuanx.wu@intel.com:  
> > > > From: Wenxuan Wu <wenxuanx.wu@intel.com>
> > > >
> > > > GCC version greater than 10.0, with compile option -O2, several warnings info would appear,
> > > > this fix omitted these warnings.  
> > > [...]  
> > > >  # FIXME: Bugzilla 396
> > > > -    warning_flags += '-Wno-zero-length-bounds'
> > > > +    warning_flags += [
> > > > +      '-Wno-zero-length-bounds',
> > > > +      '-Wno-stringop-overflow',
> > > > +      '-Wno-array-bounds',
> > > > +      '-Wno-format-overflow',  
> > >
> > > The compilers are reported warnings to help us having a better code.
> > > We should try to resolve the warnings, not hiding them.
> > >
> > >  
> >
> > Agree with Thomas. This not how to address this.
> > There are fixes already for the zero-length-bounds that are being merged.  
> 
> I just merged them, though, afaics, they fix none of the compilation
> issues reported with gcc 12.
> 
> 

I noticed that several of the gcc 12 issues are because rte_memcpy can access
past the end of the input array in some cases.

Since most of these are small arrays like RSS keys. The simplest fix would
be skip using rte_memcpy (and just use memcpy) for all these trivial places
which are not performance sensitive.
  
Wu, WenxuanX June 8, 2022, 3:27 a.m. UTC | #5
Hi Thomas,

> -----Original Message-----
> From: Thomas Monjalon <thomas@monjalon.net>
> Sent: 2022年6月7日 18:53
> To: Wu, WenxuanX <wenxuanx.wu@intel.com>
> Cc: Richardson, Bruce <bruce.richardson@intel.com>; dev@dpdk.org;
> stable@dpdk.org; david.marchand@redhat.com
> Subject: Re: [PATCH] build: fix meson build when gcc >= 10.0
> 
> 07/06/2022 04:56, wenxuanx.wu@intel.com:
> > From: Wenxuan Wu <wenxuanx.wu@intel.com>
> >
> > GCC version greater than 10.0, with compile option -O2, several
> > warnings info would appear, this fix omitted these warnings.
> [...]
> >  # FIXME: Bugzilla 396
> > -    warning_flags += '-Wno-zero-length-bounds'
> > +    warning_flags += [
> > +      '-Wno-zero-length-bounds',
> > +      '-Wno-stringop-overflow',
> > +      '-Wno-array-bounds',
> > +      '-Wno-format-overflow',
> 
> The compilers are reported warnings to help us having a better code.
> We should try to resolve the warnings, not hiding them.
> 
Yeah,  I can not agree more.  Need to draw more attention to handle these warnings.
  

Patch

diff --git a/config/meson.build b/config/meson.build
index 7134e80e8d..97f0ea6cca 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -273,7 +273,12 @@  warning_flags = [
 ]
 if cc.get_id() == 'gcc' and cc.version().version_compare('>=10.0')
 # FIXME: Bugzilla 396
-    warning_flags += '-Wno-zero-length-bounds'
+    warning_flags += [
+      '-Wno-zero-length-bounds',
+      '-Wno-stringop-overflow',
+      '-Wno-array-bounds',
+      '-Wno-format-overflow',
+      ]
 endif
 if not dpdk_conf.get('RTE_ARCH_64')
 # for 32-bit, don't warn about casting a 32-bit pointer to 64-bit int - it's fine!!