From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 26C5E21A16EDD for ; Tue, 20 Jun 2017 19:10:07 -0700 (PDT) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Jun 2017 19:11:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,366,1493708400"; d="scan'208";a="870099686" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by FMSMGA003.fm.intel.com with ESMTP; 20 Jun 2017 19:11:30 -0700 Received: from FMSMSX110.amr.corp.intel.com (10.18.116.10) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 20 Jun 2017 19:11:29 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx110.amr.corp.intel.com (10.18.116.10) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 20 Jun 2017 19:11:29 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.146]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.197]) with mapi id 14.03.0319.002; Wed, 21 Jun 2017 10:11:27 +0800 From: "Gao, Liming" To: Leif Lindholm , Ard Biesheuvel CC: "edk2-devel@lists.01.org" , "Zhu, Yonghong" , "lersek@redhat.com" Thread-Topic: [PATCH 2/2] BaseTools/tools_def: AARCH64: disable LTO type mismatch warnings Thread-Index: AQHS6fUxElzh/WHukk6304zVta1G2qItpYMAgADt7/A= Date: Wed, 21 Jun 2017 02:11:27 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14D74C867@shsmsx102.ccr.corp.intel.com> References: <1497984234-19871-1-git-send-email-ard.biesheuvel@linaro.org> <1497984234-19871-2-git-send-email-ard.biesheuvel@linaro.org> <20170620195948.GC26676@bivouac.eciton.net> In-Reply-To: <20170620195948.GC26676@bivouac.eciton.net> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH 2/2] BaseTools/tools_def: AARCH64: disable LTO type mismatch warnings 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: Wed, 21 Jun 2017 02:10:07 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao >-----Original Message----- >From: Leif Lindholm [mailto:leif.lindholm@linaro.org] >Sent: Wednesday, June 21, 2017 4:00 AM >To: Ard Biesheuvel >Cc: edk2-devel@lists.01.org; Gao, Liming ; Zhu, >Yonghong ; lersek@redhat.com >Subject: Re: [PATCH 2/2] BaseTools/tools_def: AARCH64: disable LTO type >mismatch warnings > >On Tue, Jun 20, 2017 at 08:43:54PM +0200, Ard Biesheuvel wrote: >> On AARCH64, any code that may execute with the MMU off needs to be >built >> with -mstrict-align, given that unaligned accesses are not allowed unles= s >> the MMU is enabled. This does not only affect SEC and PEI modules, but >> also static libraries of the BASE type, which may be linked into such >> modules, as well as into modules of other types. As it turns out, the >> presence of -mstrict-align is reflected in the internal representations >> of the types defined in those libraries. >> >> When -fstrict-aliasing is passed to GCC, it assumes that pointers to >> objects of different types cannot refer to the same memory location, and >> attempts to exploit this fact when optimizing the code. Since such >> assumptions are only valid under very strict conditions which are not >> guaranteed to be met in EDK2, we disable this optimization by passing >> -fno-strict-aliasing by default. > >Just a comment - you don't necessarily have to update this excellent >commit mesage, but: >-fstrict-aliasing is GCC default, because it is a restriction in the C >language. Because it's a bit non-obvious, things can go hilariously >wrong in very non-obvious ways, and the potential optimization gains >are ulikely to be generally relevant, -fno-strict-aliasing is a >sensible thing to always have set (like we do). > >> When LTO is in effect, this applies equally to the code generation that >> may occur at link time, which is why the linker warns about unexpected >> differences in type definitions between the intermediate representations >> that are present in the object files being linked. This may result in >> warnings such as the one below, even if -fno-strict-aliasing is used: >> >> MdePkg/Include/Library/BaseLib.h:1712:1: >> warning: type of 'StrToGuid' does not match original declaration >> [-Wlto-type-mismatch] >> StrToGuid ( >> ^ >> MdePkg/Library/BaseLib/SafeString.c:1506:1: >> note: 'StrToGuid' was previously declared here >> StrToGuid ( >> ^ >> MdePkg/Library/BaseLib/SafeString.c:1506:1: >> note: code may be misoptimized unless -fno-strict-aliasing is used >> >> This warning is inadvertently triggered when linking BASE libraries buil= t >> with -mstrict-align into modules of types other than SEC or PEI, since t= he >> types are subtly different, even though the use of code that maintains >> strict alignment in a module that does not care about this is unlikely t= o >> cause problems. And even if it did, it would still only affect code buil= t >> with -fstrict-aliasing enabled, which we disable unconditionally. So let= 's >> just silence the warning by passing -Wno-lto-type-mismatch. >> >> Contributed-under: TianoCore Contribution Agreement 1.0 >> Signed-off-by: Ard Biesheuvel > >Reviewed-by: Leif Lindholm > >> --- >> BaseTools/Conf/tools_def.template | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/BaseTools/Conf/tools_def.template >b/BaseTools/Conf/tools_def.template >> index 7a58ce365ed2..9a3ba9defb12 100755 >> --- a/BaseTools/Conf/tools_def.template >> +++ b/BaseTools/Conf/tools_def.template >> @@ -5407,7 +5407,7 @@ RELEASE_GCC5_ARM_DLINK_FLAGS =3D >DEF(GCC5_ARM_DLINK_FLAGS) -flto -Os -L$(WORKS >> DEBUG_GCC5_AARCH64_DLINK_XIPFLAGS =3D -z common-page-size=3D0x20 >> >> RELEASE_GCC5_AARCH64_CC_FLAGS =3D DEF(GCC5_AARCH64_CC_FLAGS) - >flto -Wno-unused-but-set-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 >> +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-type-mismatch >> >> NOOPT_GCC5_AARCH64_CC_FLAGS =3D DEF(GCC5_AARCH64_CC_FLAGS) - >O0 -mcmodel=3Dsmall >> NOOPT_GCC5_AARCH64_DLINK_FLAGS =3D >DEF(GCC5_AARCH64_DLINK_FLAGS) -z common-page-size=3D0x1000 -O0 >> -- >> 2.7.4 >>