[dpdk-dev] [PATCH] mk: disable warning with gcc 9 on Fedora 30

Pattan, Reshma reshma.pattan at intel.com
Thu May 2 15:35:20 CEST 2019



From: David Marchand [mailto:david.marchand at redhat.com]
Sent: Thursday, May 2, 2019 2:31 PM
To: Richardson, Bruce <bruce.richardson at intel.com>
Cc: Pattan, Reshma <reshma.pattan at intel.com>; dev <dev at dpdk.org>
Subject: Re: [dpdk-dev] [PATCH] mk: disable warning with gcc 9 on Fedora 30



On Thu, May 2, 2019 at 3:26 PM Bruce Richardson <bruce.richardson at intel.com<mailto:bruce.richardson at intel.com>> wrote:
On Thu, May 02, 2019 at 12:07:17PM +0200, David Marchand wrote:
> On Thu, May 2, 2019 at 11:33 AM Reshma Pattan <reshma.pattan at intel.com<mailto:reshma.pattan at intel.com>>
> wrote:
>
> > gcc 9 on Fedora 30 gives an error
> > "taking address of packed member may result in an
> > unaligned pointer value" warnings.
> >
> > For clang builds this warning is already disabled,
> > so disable "-Waddress-of-packed-member" for gcc builds
> > also.
> >
> > Snippet of build error:
> > ...lib/librte_eal/linux/eal/eal_memalloc.c: In function ‘alloc_seg_walk’:
> > ...lib/librte_eal/linux/eal/eal_memalloc.c:768:12: error: taking address
> > of packed member of ‘struct rte_mem_config’ may result in an unaligned
> > pointer value [-Werror=address-of-packed-member]
> >   768 |  cur_msl = &mcfg->memsegs[msl_idx];
> >       |            ^~~~~~~~~~~~~~~~~~~~~~~
> >
> > Signed-off-by: Reshma Pattan <reshma.pattan at intel.com<mailto:reshma.pattan at intel.com>>
> > ---
> >  mk/toolchain/gcc/rte.vars.mk<http://rte.vars.mk> | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/mk/toolchain/gcc/rte.vars.mk<http://rte.vars.mk> b/mk/toolchain/gcc/rte.vars.mk<http://rte.vars.mk>
> > index d8b99faf6..b852fcfd7 100644
> > --- a/mk/toolchain/gcc/rte.vars.mk<http://rte.vars.mk>
> > +++ b/mk/toolchain/gcc/rte.vars.mk<http://rte.vars.mk>
> > @@ -87,5 +87,8 @@ WERROR_FLAGS += -Wimplicit-fallthrough=2
> >  WERROR_FLAGS += -Wno-format-truncation
> >  endif
> >
> > +# disable packed member unalign warnings
> > +WERROR_FLAGS += -Wno-address-of-packed-member
> > +
> >  export CC AS AR LD OBJCOPY OBJDUMP STRIP READELF
> >  export TOOLCHAIN_CFLAGS TOOLCHAIN_LDFLAGS TOOLCHAIN_ASFLAGS
> > --
> > 2.21.0
> >
> >
> Not the best approach to me...
>
Agreed, but this fix does seem reasonable since we already disable this warning
for clang.

> Let me install a fedora 30 and have a look.
Hopefully you can come up with a better fix, but I think we need something
soon for 19.05, so this patch may be needed as a stop-gap fix.

Hiding this warning, we will never fix the places that could be fixed (and I found some where the packed attribute makes no sense to me).
I'd prefer at least a -Wno-error=address-of-packed-member

Hi,

If below is ok, I will send the patch.

diff --git a/mk/toolchain/gcc/rte.vars.mk b/mk/toolchain/gcc/rte.vars.mk
index b852fcfd7..cfe6f2645 100644
--- a/mk/toolchain/gcc/rte.vars.mk
+++ b/mk/toolchain/gcc/rte.vars.mk
@@ -49,6 +49,8 @@ WERROR_FLAGS += -Wcast-align -Wnested-externs -Wcast-qual
WERROR_FLAGS += -Wformat-nonliteral -Wformat-security
WERROR_FLAGS += -Wundef -Wwrite-strings -Wdeprecated

+WERROR_FLAGS += -Wno-error=address-of-packed-member
+

Thanks,
Reshma



More information about the dev mailing list