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 F0B5EA0AC5 for ; Thu, 2 May 2019 16:42:07 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0BE397D05; Thu, 2 May 2019 16:42:07 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 5AFCD7CEB for ; Thu, 2 May 2019 16:42:05 +0200 (CEST) X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP; 02 May 2019 07:42:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,422,1549958400"; d="scan'208";a="147583590" Received: from bricha3-mobl.ger.corp.intel.com ([10.237.221.48]) by orsmga003.jf.intel.com with SMTP; 02 May 2019 07:42:01 -0700 Received: by (sSMTP sendmail emulation); Thu, 02 May 2019 15:41:59 +0100 Date: Thu, 2 May 2019 15:41:59 +0100 From: Bruce Richardson To: David Marchand Cc: Reshma Pattan , dev Message-ID: <20190502144159.GA316@bricha3-MOBL.ger.corp.intel.com> References: <20190502093334.7546-1-reshma.pattan@intel.com> <20190502141316.25907-1-reshma.pattan@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.11.4 (2019-03-13) 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: <20190502144159.GrqSx487gZbff51FfpBY1U1BjadbMVlFFqTh4ZCv3WI@z> 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 > ‘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]; > | ^~~~~~~~~~~~~~~~~~~~~~~ > Snippet of build after fix > ..lib/librte_eal/linux/eal/eal_memory.c: In function > ‘remap_segment’: > ..lib/librte_eal/linux/eal/eal_memory.c:685:9: warning: taking > address > of packed member of ‘struct rte_mem_config’ may result in an > unaligned > pointer value [-Waddress-of-packed-member] > 685 | msl = &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 += -Wimplicit-fallthrough=2 > WERROR_FLAGS += -Wno-format-truncation > endif > +#Report "taking address of packed member may result > +#in an unaligned pointer value" issues as warnings. > +WERROR_FLAGS += -Wno-error=address-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 those > 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 += > -Wno-address-of-packed-member > It should be something like (untested): > @@ -87,5 +87,10 @@ WERROR_FLAGS += -Wimplicit-fallthrough=2 > WERROR_FLAGS += -Wno-format-truncation > endif > > +# disable packed member unalign warnings > +ifeq ($(shell test $(GCC_VERSION) -ge 90 && echo 1), 1) > +WERROR_FLAGS += -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 recognise, 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] /Bruce