From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vs1-f65.google.com (mail-vs1-f65.google.com [209.85.217.65]) by dpdk.org (Postfix) with ESMTP id ABD5A5F32 for ; Thu, 2 May 2019 16:48:15 +0200 (CEST) Received: by mail-vs1-f65.google.com with SMTP id o10so1509367vsp.12 for ; Thu, 02 May 2019 07:48:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ctN4eX4N8YGqEPL8BO1sMXdkKaNgXkoxZejpNRzcASQ=; b=ZWTKWSdp+oD1aomd1Btz4jqhtoMIwnrTiieftiHmPsj03sDSQ0e7anSOWHh0kYP8ok +Q5Cqb6xJLIutqpQAmT0J0+/e9FomvwgRQuCCm6YC48K6qU/dEycQjQa0ChQ7lXmuPIy c709/8yqltaijTO/0331r3VczocRhAw2GatMWIpydblhnqnbwxq27oS9vLWtEJxPsye6 QquRIes598HIUac8a7H6MluG8i4X+eyJnT4zdgyECs7754TvsmWYfeudmMdS5HGNpeOK as52xXcqyPQS+PuaghnXaFIogi0GSUBUpCJj8ZeiVxD27K6tBAY3KcCQgRaARZ6+kk2r 3STg== X-Gm-Message-State: APjAAAX+1ewHl0bbQ5X4uPaT07Dbd8us9P0tLidmePy40056i4a1w2GW voZbtFCCvgrwT5VzKRbJqBivaI4Qc/wesOu4AC9/EQ== X-Google-Smtp-Source: APXvYqwto4tRheNM0wOFw6jmi9gEbzv96M3j8jWEM8S5RrP9WTaUyrqpwbGp/fGDJi6d4mKJxspyMcExI/kHuZuvcn0= X-Received: by 2002:a67:a446:: with SMTP id p6mr2374805vsh.198.1556808494998; Thu, 02 May 2019 07:48:14 -0700 (PDT) MIME-Version: 1.0 References: <20190502093334.7546-1-reshma.pattan@intel.com> <20190502141316.25907-1-reshma.pattan@intel.com> <20190502144159.GA316@bricha3-MOBL.ger.corp.intel.com> In-Reply-To: <20190502144159.GA316@bricha3-MOBL.ger.corp.intel.com> From: David Marchand Date: Thu, 2 May 2019 16:48:03 +0200 Message-ID: To: Bruce Richardson Cc: Reshma Pattan , dev Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-dev] [PATCH v2] mk: report address of packed member as warning X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 May 2019 14:48:15 -0000 On Thu, May 2, 2019 at 4:42 PM Bruce Richardson wrote: > On Thu, May 02, 2019 at 04:24:37PM +0200, David Marchand wrote: > > On Thu, May 2, 2019 at 4:13 PM Reshma Pattan > > <[1]reshma.pattan@intel.com> wrote: > > > > gcc 9 on Fedora 30 gives an error > > "taking address of packed member may result in an > > unaligned pointer value" for -Waddress-of-packed-member. > > Report it as warning instead of error to fix the build. > > Snippet of build before fix > > ...lib/librte_eal/linux/eal/eal_memalloc.c: In function > > =E2=80=98alloc_seg_walk=E2=80=99: > > ...lib/librte_eal/linux/eal/eal_memalloc.c:768:12: error: taking > > address > > of packed member of =E2=80=98struct rte_mem_config=E2=80=99 may re= sult in an > > unaligned > > pointer value [-Werror=3Daddress-of-packed-member] > > 768 | cur_msl =3D &mcfg->memsegs[msl_idx]; > > | ^~~~~~~~~~~~~~~~~~~~~~~ > > Snippet of build after fix > > ..lib/librte_eal/linux/eal/eal_memory.c: In function > > =E2=80=98remap_segment=E2=80=99: > > ..lib/librte_eal/linux/eal/eal_memory.c:685:9: warning: taking > > address > > of packed member of =E2=80=98struct rte_mem_config=E2=80=99 may re= sult in an > > unaligned > > pointer value [-Waddress-of-packed-member] > > 685 | msl =3D &mcfg->memsegs[msl_idx]; > > Signed-off-by: Reshma Pattan <[2]reshma.pattan@intel.com> > > --- > > mk/toolchain/gcc/[3]rte.vars.mk | 4 ++++ > > 1 file changed, 4 insertions(+) > > diff --git a/mk/toolchain/gcc/[4]rte.vars.mk > > b/mk/toolchain/gcc/[5]rte.vars.mk > > index d8b99faf6..61032bbbc 100644 > > --- a/mk/toolchain/gcc/[6]rte.vars.mk > > +++ b/mk/toolchain/gcc/[7]rte.vars.mk > > @@ -87,5 +87,9 @@ WERROR_FLAGS +=3D -Wimplicit-fallthrough=3D2 > > WERROR_FLAGS +=3D -Wno-format-truncation > > endif > > +#Report "taking address of packed member may result > > +#in an unaligned pointer value" issues as warnings. > > +WERROR_FLAGS +=3D -Wno-error=3Daddress-of-packed-member > > + > > export CC AS AR LD OBJCOPY OBJDUMP STRIP READELF > > export TOOLCHAIN_CFLAGS TOOLCHAIN_LDFLAGS TOOLCHAIN_ASFLAGS > > -- > > 2.21.0 > > > > No, you can't do this unconditionally. > > Looked at clang (in make build system) and meson (globally) and thos= e > > completely disable the warning. > > $ git grep address-of-packed-member origin/master -- > > origin/master:config/meson.build: > '-Wno-address-of-packed-member' > > origin/master:mk/toolchain/clang/rte.vars.mk:WERROR_FLAGS +=3D > > -Wno-address-of-packed-member > > It should be something like (untested): > > @@ -87,5 +87,10 @@ WERROR_FLAGS +=3D -Wimplicit-fallthrough=3D2 > > WERROR_FLAGS +=3D -Wno-format-truncation > > endif > > > > +# disable packed member unalign warnings > > +ifeq ($(shell test $(GCC_VERSION) -ge 90 && echo 1), 1) > > +WERROR_FLAGS +=3D -Wno-address-of-packed-member > > +endif > > + > Actually, you should not need to check the GCC version for this. > GCC always ignores silently any warning disable flags it doesn't recognis= e, > only printing information about them if there is another error to report. > [This is why meson, when you ask it if the compiler supports "-Wno-foo", > will > check the flag and also the -Wfoo flag, as gcc won't report an error with > just the "no" form] > WERROR_FLAGS +=3D -Wno-error=3Daddress-of-packed-member triggers an error. [dmarchan@dmarchan dpdk]$ make EXTRA_CFLAGS=3D"-g -O0" O=3Dmaster cc1: error: -Werror=3Daddress-of-packed-member: no option -Waddress-of-packed-member =3D=3D Build lib cc1: error: -Werror=3Daddress-of-packed-member: no option -Waddress-of-packed-member =3D=3D Build lib/librte_kvargs cc1: error: -Werror=3Daddress-of-packed-member: no option -Waddress-of-packed-member CC rte_kvargs.o cc1: error: -Werror=3Daddress-of-packed-member: no option -Waddress-of-packed-member make[3]: *** [rte_kvargs.o] Error 1 make[2]: *** [librte_kvargs] Error 2 make[1]: *** [lib] Error 2 make: *** [all] Error 2 WERROR_FLAGS +=3D -Wno-address-of-packed-member is ignored. Marvellous :-) Sorry for the noise, let's go with your initial patch. --=20 David Marchand From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 43268A0AC5 for ; Thu, 2 May 2019 16:48:17 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4CD656C9B; Thu, 2 May 2019 16:48:16 +0200 (CEST) Received: from mail-vs1-f65.google.com (mail-vs1-f65.google.com [209.85.217.65]) by dpdk.org (Postfix) with ESMTP id ABD5A5F32 for ; Thu, 2 May 2019 16:48:15 +0200 (CEST) Received: by mail-vs1-f65.google.com with SMTP id o10so1509367vsp.12 for ; Thu, 02 May 2019 07:48:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ctN4eX4N8YGqEPL8BO1sMXdkKaNgXkoxZejpNRzcASQ=; b=ZWTKWSdp+oD1aomd1Btz4jqhtoMIwnrTiieftiHmPsj03sDSQ0e7anSOWHh0kYP8ok +Q5Cqb6xJLIutqpQAmT0J0+/e9FomvwgRQuCCm6YC48K6qU/dEycQjQa0ChQ7lXmuPIy c709/8yqltaijTO/0331r3VczocRhAw2GatMWIpydblhnqnbwxq27oS9vLWtEJxPsye6 QquRIes598HIUac8a7H6MluG8i4X+eyJnT4zdgyECs7754TvsmWYfeudmMdS5HGNpeOK as52xXcqyPQS+PuaghnXaFIogi0GSUBUpCJj8ZeiVxD27K6tBAY3KcCQgRaARZ6+kk2r 3STg== X-Gm-Message-State: APjAAAX+1ewHl0bbQ5X4uPaT07Dbd8us9P0tLidmePy40056i4a1w2GW voZbtFCCvgrwT5VzKRbJqBivaI4Qc/wesOu4AC9/EQ== X-Google-Smtp-Source: APXvYqwto4tRheNM0wOFw6jmi9gEbzv96M3j8jWEM8S5RrP9WTaUyrqpwbGp/fGDJi6d4mKJxspyMcExI/kHuZuvcn0= X-Received: by 2002:a67:a446:: with SMTP id p6mr2374805vsh.198.1556808494998; Thu, 02 May 2019 07:48:14 -0700 (PDT) MIME-Version: 1.0 References: <20190502093334.7546-1-reshma.pattan@intel.com> <20190502141316.25907-1-reshma.pattan@intel.com> <20190502144159.GA316@bricha3-MOBL.ger.corp.intel.com> In-Reply-To: <20190502144159.GA316@bricha3-MOBL.ger.corp.intel.com> From: David Marchand Date: Thu, 2 May 2019 16:48:03 +0200 Message-ID: To: Bruce Richardson Cc: Reshma Pattan , dev Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-dev] [PATCH v2] mk: report address of packed member as warning X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Message-ID: <20190502144803.w2kKHNuaCCfJ3mMSQxPL1AqM9_9UOTn535R8VqOsiO0@z> On Thu, May 2, 2019 at 4:42 PM Bruce Richardson wrote: > On Thu, May 02, 2019 at 04:24:37PM +0200, David Marchand wrote: > > On Thu, May 2, 2019 at 4:13 PM Reshma Pattan > > <[1]reshma.pattan@intel.com> wrote: > > > > gcc 9 on Fedora 30 gives an error > > "taking address of packed member may result in an > > unaligned pointer value" for -Waddress-of-packed-member. > > Report it as warning instead of error to fix the build. > > Snippet of build before fix > > ...lib/librte_eal/linux/eal/eal_memalloc.c: In function > > =E2=80=98alloc_seg_walk=E2=80=99: > > ...lib/librte_eal/linux/eal/eal_memalloc.c:768:12: error: taking > > address > > of packed member of =E2=80=98struct rte_mem_config=E2=80=99 may re= sult in an > > unaligned > > pointer value [-Werror=3Daddress-of-packed-member] > > 768 | cur_msl =3D &mcfg->memsegs[msl_idx]; > > | ^~~~~~~~~~~~~~~~~~~~~~~ > > Snippet of build after fix > > ..lib/librte_eal/linux/eal/eal_memory.c: In function > > =E2=80=98remap_segment=E2=80=99: > > ..lib/librte_eal/linux/eal/eal_memory.c:685:9: warning: taking > > address > > of packed member of =E2=80=98struct rte_mem_config=E2=80=99 may re= sult in an > > unaligned > > pointer value [-Waddress-of-packed-member] > > 685 | msl =3D &mcfg->memsegs[msl_idx]; > > Signed-off-by: Reshma Pattan <[2]reshma.pattan@intel.com> > > --- > > mk/toolchain/gcc/[3]rte.vars.mk | 4 ++++ > > 1 file changed, 4 insertions(+) > > diff --git a/mk/toolchain/gcc/[4]rte.vars.mk > > b/mk/toolchain/gcc/[5]rte.vars.mk > > index d8b99faf6..61032bbbc 100644 > > --- a/mk/toolchain/gcc/[6]rte.vars.mk > > +++ b/mk/toolchain/gcc/[7]rte.vars.mk > > @@ -87,5 +87,9 @@ WERROR_FLAGS +=3D -Wimplicit-fallthrough=3D2 > > WERROR_FLAGS +=3D -Wno-format-truncation > > endif > > +#Report "taking address of packed member may result > > +#in an unaligned pointer value" issues as warnings. > > +WERROR_FLAGS +=3D -Wno-error=3Daddress-of-packed-member > > + > > export CC AS AR LD OBJCOPY OBJDUMP STRIP READELF > > export TOOLCHAIN_CFLAGS TOOLCHAIN_LDFLAGS TOOLCHAIN_ASFLAGS > > -- > > 2.21.0 > > > > No, you can't do this unconditionally. > > Looked at clang (in make build system) and meson (globally) and thos= e > > completely disable the warning. > > $ git grep address-of-packed-member origin/master -- > > origin/master:config/meson.build: > '-Wno-address-of-packed-member' > > origin/master:mk/toolchain/clang/rte.vars.mk:WERROR_FLAGS +=3D > > -Wno-address-of-packed-member > > It should be something like (untested): > > @@ -87,5 +87,10 @@ WERROR_FLAGS +=3D -Wimplicit-fallthrough=3D2 > > WERROR_FLAGS +=3D -Wno-format-truncation > > endif > > > > +# disable packed member unalign warnings > > +ifeq ($(shell test $(GCC_VERSION) -ge 90 && echo 1), 1) > > +WERROR_FLAGS +=3D -Wno-address-of-packed-member > > +endif > > + > Actually, you should not need to check the GCC version for this. > GCC always ignores silently any warning disable flags it doesn't recognis= e, > only printing information about them if there is another error to report. > [This is why meson, when you ask it if the compiler supports "-Wno-foo", > will > check the flag and also the -Wfoo flag, as gcc won't report an error with > just the "no" form] > WERROR_FLAGS +=3D -Wno-error=3Daddress-of-packed-member triggers an error. [dmarchan@dmarchan dpdk]$ make EXTRA_CFLAGS=3D"-g -O0" O=3Dmaster cc1: error: -Werror=3Daddress-of-packed-member: no option -Waddress-of-packed-member =3D=3D Build lib cc1: error: -Werror=3Daddress-of-packed-member: no option -Waddress-of-packed-member =3D=3D Build lib/librte_kvargs cc1: error: -Werror=3Daddress-of-packed-member: no option -Waddress-of-packed-member CC rte_kvargs.o cc1: error: -Werror=3Daddress-of-packed-member: no option -Waddress-of-packed-member make[3]: *** [rte_kvargs.o] Error 1 make[2]: *** [librte_kvargs] Error 2 make[1]: *** [lib] Error 2 make: *** [all] Error 2 WERROR_FLAGS +=3D -Wno-address-of-packed-member is ignored. Marvellous :-) Sorry for the noise, let's go with your initial patch. --=20 David Marchand