From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id E935121CEB10B for ; Thu, 7 Sep 2017 08:02:09 -0700 (PDT) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Sep 2017 08:04:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,358,1500966000"; d="scan'208";a="1192624466" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga001.fm.intel.com with ESMTP; 07 Sep 2017 08:04:41 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 7 Sep 2017 08:04:41 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.39]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.98]) with mapi id 14.03.0319.002; Thu, 7 Sep 2017 23:04:39 +0800 From: "Gao, Liming" To: Thomas Lamprecht , "edk2-devel@lists.01.org" CC: Laszlo Ersek Thread-Topic: [edk2] [PATCH] BaseTools/GCC5: set -Wno-unused-const-variables on RELEASE builds Thread-Index: AQHTJ+lLF+S4UfSdgUKnULybjHKC9KKphQtA Date: Thu, 7 Sep 2017 15:04:38 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14D78B7AF@shsmsx102.ccr.corp.intel.com> References: <20170907145432.7571-1-t.lamprecht@proxmox.com> In-Reply-To: <20170907145432.7571-1-t.lamprecht@proxmox.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] BaseTools/GCC5: set -Wno-unused-const-variables on RELEASE builds X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Sep 2017 15:02:10 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable I suggest to also add this option in GCC49 tool chain RELEASE builds. GCC49= can be used for GCC 4.9 or the above version. It doesn't enable LTO.=20 Thanks Liming > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Th= omas Lamprecht > Sent: Thursday, September 7, 2017 10:55 PM > To: edk2-devel@lists.01.org > Cc: Laszlo Ersek ; Gao, Liming > Subject: [edk2] [PATCH] BaseTools/GCC5: set -Wno-unused-const-variables o= n RELEASE builds >=20 > TianoCore BZ#700 >=20 > This fixes the RELEASE build of OVMF with GCC in version 6 or newer. > GCC 6 added the '-Wunused-const-variable' warning, which gets > activated by '-Wunused-variable' and has the following behavior: > "Warn whenever a constant static variable is unused aside from its > declaration" [1] >=20 > Commit 2ad6ba80a1bd58382bde6b994070f7c01d2fb48d introduced a case > where exactly this happens on a RELEASE build. All uses of the static > const variable are located in debug code only, which gets thrown out > by the compiler on RELEASE builds and thus triggers the > unused-const-variable warning. >=20 > There is currently no GCC 6 toolchain target defined and doing so > would add a lot of boilerplate code. Instead, use the fact that GCC > ignores unkown '-Wno-*' options: >=20 > "[...] if the -Wno- form is used [...] no diagnostic is produced for > -Wno-unknown-warning unless other diagnostics are being produced" >=20 > This behavior is available in GCC 5 [2] (and also earlier, for that > matter), so add the flag to the GCC5 toolchain, even if GCC 5 itself > does not supports it. >=20 > Orient the changes on 20d00edf21d2 which moved the > '-Wno-unused-but-set-variable' flag to RELEASE builds only, as there > it ensure that it does not gets raised if the only usage of a > variable is in (then collapsed) debug code. >=20 > [1] https://gcc.gnu.org/onlinedocs/gcc-6.4.0/gcc/Warning-Options.html#ind= ex-Wunused-const-variable > [2] https://gcc.gnu.org/onlinedocs/gcc-5.4.0/gcc/Warning-Options.html >=20 > Cc: Yonghong Zhu > Cc: Liming Gao > Cc: Laszlo Ersek > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Thomas Lamprecht > --- >=20 > I hope I CCed the correct people and got the style right :) >=20 > BaseTools/Conf/tools_def.template | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) >=20 > diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def= .template > index ba1d1a16de..7db7a174c3 100755 > --- a/BaseTools/Conf/tools_def.template > +++ b/BaseTools/Conf/tools_def.template > @@ -5326,7 +5326,7 @@ RELEASE_GCC49_AARCH64_DLINK_FLAGS =3D DEF(GCC49_AA= RCH64_DLINK_FLAGS) > DEBUG_GCC5_IA32_CC_FLAGS =3D DEF(GCC5_IA32_CC_FLAGS) -flto -Os > DEBUG_GCC5_IA32_DLINK_FLAGS =3D DEF(GCC5_IA32_X64_DLINK_FLAGS) -flt= o -Os -Wl,-m,elf_i386,--oformat=3Delf32-i386 >=20 > -RELEASE_GCC5_IA32_CC_FLAGS =3D DEF(GCC5_IA32_CC_FLAGS) -flto -Os -= Wno-unused-but-set-variable > +RELEASE_GCC5_IA32_CC_FLAGS =3D DEF(GCC5_IA32_CC_FLAGS) -flto -Os -= Wno-unused-but-set-variable > -Wno-unused-const-variable > RELEASE_GCC5_IA32_DLINK_FLAGS =3D DEF(GCC5_IA32_X64_DLINK_FLAGS) -flt= o -Os -Wl,-m,elf_i386,--oformat=3Delf32-i386 >=20 > NOOPT_GCC5_IA32_CC_FLAGS =3D DEF(GCC5_IA32_CC_FLAGS) -O0 > @@ -5358,7 +5358,7 @@ RELEASE_GCC5_IA32_DLINK_FLAGS =3D DEF(GCC5_IA32_= X64_DLINK_FLAGS) -flto -Os -Wl, > DEBUG_GCC5_X64_CC_FLAGS =3D DEF(GCC5_X64_CC_FLAGS) -flto -DUSIN= G_LTO -Os > DEBUG_GCC5_X64_DLINK_FLAGS =3D DEF(GCC5_X64_DLINK_FLAGS) -flto -Os >=20 > -RELEASE_GCC5_X64_CC_FLAGS =3D DEF(GCC5_X64_CC_FLAGS) -flto -DUSIN= G_LTO -Os -Wno-unused-but-set-variable > +RELEASE_GCC5_X64_CC_FLAGS =3D DEF(GCC5_X64_CC_FLAGS) -flto -DUSIN= G_LTO -Os -Wno-unused-but-set-variable > -Wno-unused-const-variable > RELEASE_GCC5_X64_DLINK_FLAGS =3D DEF(GCC5_X64_DLINK_FLAGS) -flto -Os >=20 > NOOPT_GCC5_X64_CC_FLAGS =3D DEF(GCC5_X64_CC_FLAGS) -O0 > @@ -5393,7 +5393,7 @@ RELEASE_GCC5_X64_DLINK_FLAGS =3D DEF(GCC5_X64_D= LINK_FLAGS) -flto -Os > DEBUG_GCC5_ARM_CC_FLAGS =3D DEF(GCC5_ARM_CC_FLAGS) -O0 > DEBUG_GCC5_ARM_DLINK_FLAGS =3D DEF(GCC5_ARM_DLINK_FLAGS) >=20 > -RELEASE_GCC5_ARM_CC_FLAGS =3D DEF(GCC5_ARM_CC_FLAGS) -flto -Wno-u= nused-but-set-variable > +RELEASE_GCC5_ARM_CC_FLAGS =3D DEF(GCC5_ARM_CC_FLAGS) -flto -Wno-u= nused-but-set-variable > -Wno-unused-const-variable > RELEASE_GCC5_ARM_DLINK_FLAGS =3D DEF(GCC5_ARM_DLINK_FLAGS) -flto -Os= -L$(WORKSPACE)/ArmPkg/Library/GccLto > -llto-arm -Wl,-plugin-opt=3D-pass-through=3D-llto-arm >=20 > NOOPT_GCC5_ARM_CC_FLAGS =3D DEF(GCC5_ARM_CC_FLAGS) -O0 > @@ -5428,7 +5428,7 @@ RELEASE_GCC5_ARM_DLINK_FLAGS =3D DEF(GCC5_ARM_D= LINK_FLAGS) -flto -Os -L$(WORKS > DEBUG_GCC5_AARCH64_DLINK_FLAGS =3D DEF(GCC5_AARCH64_DLINK_FLAGS) -z co= mmon-page-size=3D0x1000 > DEBUG_GCC5_AARCH64_DLINK_XIPFLAGS =3D -z common-page-size=3D0x20 >=20 > -RELEASE_GCC5_AARCH64_CC_FLAGS =3D DEF(GCC5_AARCH64_CC_FLAGS) -flto -W= no-unused-but-set-variable -mcmodel=3Dtiny > -fomit-frame-pointer > +RELEASE_GCC5_AARCH64_CC_FLAGS =3D DEF(GCC5_AARCH64_CC_FLAGS) -flto -W= no-unused-but-set-variable > -Wno-unused-const-variable -mcmodel=3Dtiny -fomit-frame-pointer > RELEASE_GCC5_AARCH64_DLINK_FLAGS =3D DEF(GCC5_AARCH64_DLINK_FLAGS) -flto= -Os -L$(WORKSPACE)/ArmPkg/Library/GccLto > -llto-aarch64 -Wl,-plugin-opt=3D-pass-through=3D-llto-aarch64 -Wno-lto-ty= pe-mismatch >=20 > NOOPT_GCC5_AARCH64_CC_FLAGS =3D DEF(GCC5_AARCH64_CC_FLAGS) -O0 -mcm= odel=3Dsmall > -- > 2.11.0 >=20 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel