From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ua1-f65.google.com (mail-ua1-f65.google.com [209.85.222.65]) by dpdk.org (Postfix) with ESMTP id B33AC7D05 for ; Thu, 2 May 2019 16:24:49 +0200 (CEST) Received: by mail-ua1-f65.google.com with SMTP id o33so758937uae.12 for ; Thu, 02 May 2019 07:24:49 -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=mB4kfbwrShUr9DLupLBu/xK1eXStsJ6JkHczWoPXCRA=; b=dI6Obg1YFZys7A0xtZtIBBwwP/SgCtQ4Hjc5VyShixCSuYAiYD6JHYMTboqjaiTkuS JIBv/r5tb2RPA59sJIgJSLZX5rYiLMRxDk9l88YK73TjrWZ2w45q9EMKPveYIhUqys+o v8duUv7fjEmc7d7iA+Zoqbhk1N0cXTac4zmH9CNobwpQmm3E5pPS0klBpKbRWS2HxnJL 9z35dG2UuCEPYrLEbtuM/nfRI3+R0wJXDFeYlQb9m/+yumSDx2ivBffwstVbquL0qTzz i6Hd69lHm6CRy85+2XWtWvVUBn/yg31TooEiwVIDBmKyzZbIIzVCkInzNhoSsDxoGsmF DDfA== X-Gm-Message-State: APjAAAWHfQtTeblLALG14vrg72FYhYjyvPKEpi4rtn6HaRSxaLaiOu1J UvBkqKoj76FNpnk7wiNPQN6S8Cq81HnXjh6Xo7CV6A== X-Google-Smtp-Source: APXvYqxPj5LhE97NQ5qzGo0IPrKxz3jsRZ0qV9drdhHmDrBRSSeEW4iP85HdyunuVxIE4PKLKSSjgt9zOnqkaOTgDRQ= X-Received: by 2002:ab0:413:: with SMTP id 19mr1946929uav.87.1556807088933; Thu, 02 May 2019 07:24:48 -0700 (PDT) MIME-Version: 1.0 References: <20190502093334.7546-1-reshma.pattan@intel.com> <20190502141316.25907-1-reshma.pattan@intel.com> In-Reply-To: <20190502141316.25907-1-reshma.pattan@intel.com> From: David Marchand Date: Thu, 2 May 2019 16:24:37 +0200 Message-ID: To: Reshma Pattan Cc: dev , Bruce Richardson 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:24:50 -0000 On Thu, May 2, 2019 at 4:13 PM Reshma Pattan 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_se= g_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 result 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_segme= nt=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 result in= an unaligned > pointer value [-Waddress-of-packed-member] > 685 | msl =3D &mcfg->memsegs[msl_idx]; > > Signed-off-by: Reshma Pattan > --- > mk/toolchain/gcc/rte.vars.mk | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/mk/toolchain/gcc/rte.vars.mk b/mk/toolchain/gcc/rte.vars.mk > index d8b99faf6..61032bbbc 100644 > --- a/mk/toolchain/gcc/rte.vars.mk > +++ b/mk/toolchain/gcc/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 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 +=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 + export CC AS AR LD OBJCOPY OBJDUMP STRIP READELF export TOOLCHAIN_CFLAGS TOOLCHAIN_LDFLAGS TOOLCHAIN_ASFLAGS --=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 53CF1A0AC5 for ; Thu, 2 May 2019 16:24:51 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6D6F87EC7; Thu, 2 May 2019 16:24:50 +0200 (CEST) Received: from mail-ua1-f65.google.com (mail-ua1-f65.google.com [209.85.222.65]) by dpdk.org (Postfix) with ESMTP id B33AC7D05 for ; Thu, 2 May 2019 16:24:49 +0200 (CEST) Received: by mail-ua1-f65.google.com with SMTP id o33so758937uae.12 for ; Thu, 02 May 2019 07:24:49 -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=mB4kfbwrShUr9DLupLBu/xK1eXStsJ6JkHczWoPXCRA=; b=dI6Obg1YFZys7A0xtZtIBBwwP/SgCtQ4Hjc5VyShixCSuYAiYD6JHYMTboqjaiTkuS JIBv/r5tb2RPA59sJIgJSLZX5rYiLMRxDk9l88YK73TjrWZ2w45q9EMKPveYIhUqys+o v8duUv7fjEmc7d7iA+Zoqbhk1N0cXTac4zmH9CNobwpQmm3E5pPS0klBpKbRWS2HxnJL 9z35dG2UuCEPYrLEbtuM/nfRI3+R0wJXDFeYlQb9m/+yumSDx2ivBffwstVbquL0qTzz i6Hd69lHm6CRy85+2XWtWvVUBn/yg31TooEiwVIDBmKyzZbIIzVCkInzNhoSsDxoGsmF DDfA== X-Gm-Message-State: APjAAAWHfQtTeblLALG14vrg72FYhYjyvPKEpi4rtn6HaRSxaLaiOu1J UvBkqKoj76FNpnk7wiNPQN6S8Cq81HnXjh6Xo7CV6A== X-Google-Smtp-Source: APXvYqxPj5LhE97NQ5qzGo0IPrKxz3jsRZ0qV9drdhHmDrBRSSeEW4iP85HdyunuVxIE4PKLKSSjgt9zOnqkaOTgDRQ= X-Received: by 2002:ab0:413:: with SMTP id 19mr1946929uav.87.1556807088933; Thu, 02 May 2019 07:24:48 -0700 (PDT) MIME-Version: 1.0 References: <20190502093334.7546-1-reshma.pattan@intel.com> <20190502141316.25907-1-reshma.pattan@intel.com> In-Reply-To: <20190502141316.25907-1-reshma.pattan@intel.com> From: David Marchand Date: Thu, 2 May 2019 16:24:37 +0200 Message-ID: To: Reshma Pattan Cc: dev , Bruce Richardson 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: <20190502142437.5_IZqavftws8_awWr_mDPGDqJ9yM1ccphzgmeO4yDW8@z> On Thu, May 2, 2019 at 4:13 PM Reshma Pattan 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_se= g_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 result 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_segme= nt=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 result in= an unaligned > pointer value [-Waddress-of-packed-member] > 685 | msl =3D &mcfg->memsegs[msl_idx]; > > Signed-off-by: Reshma Pattan > --- > mk/toolchain/gcc/rte.vars.mk | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/mk/toolchain/gcc/rte.vars.mk b/mk/toolchain/gcc/rte.vars.mk > index d8b99faf6..61032bbbc 100644 > --- a/mk/toolchain/gcc/rte.vars.mk > +++ b/mk/toolchain/gcc/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 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 +=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 + export CC AS AR LD OBJCOPY OBJDUMP STRIP READELF export TOOLCHAIN_CFLAGS TOOLCHAIN_LDFLAGS TOOLCHAIN_ASFLAGS --=20 David Marchand