From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-x22a.google.com (mail-wr0-x22a.google.com [IPv6:2a00:1450:400c:c0c::22a]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 2707921A16ECF for ; Tue, 20 Jun 2017 12:58:29 -0700 (PDT) Received: by mail-wr0-x22a.google.com with SMTP id y25so66163528wrd.2 for ; Tue, 20 Jun 2017 12:59:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=100sALdKQwzzSLmyq+0BTAOZ1BZQHDg4kuTB3kLnujI=; b=gRLKiCLNFGGU5t1vBBaR0xQLlu93i207SqX76Kkz+jDqaUdBel8GcvGIBd0N6SQp0d oYicvtJbVBrmvTqTnjaE9DS6Re5fpa0P1p2mYlhXeR9RCPByQDIASy2ZQFpLqUjgoH5D nlWZ+tswCcJVKuxx1t7l4YcBD5kXop8UnSm7s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=100sALdKQwzzSLmyq+0BTAOZ1BZQHDg4kuTB3kLnujI=; b=caw784QqbMCaPeQCG8OgOBiIhcW+rO/Koq5cNpti6QslI9zkqRhgd8gzBBcpglrGHu OsDb9Aw1v/LYL9SnCd3C0/7OAnpwnZHTEZf2ft910FUfT2ebAXqCcHqQDDeb6XeQX/ID TkNwLnaCiNv+o0TQp8Oqovbjj/flzJmh27Wu8G07reLPdjZzohECdCmtPVIul167fm5g 4gChUenLHBKwMzFAuyFqtxL8r8exleSBY1b0eT9riXgmxMbUEl9vcj9DgykeFdt6W4t+ KBhfpAho9l/VEdzpBJMFDiN0UrrJEJhRD8aEAtwUQ/T9yumKT5VWDZAJ0IG2Ui7tRv9d Ne8A== X-Gm-Message-State: AKS2vOxHtnQPncu4kU9zrdrbd3P3ofhsoZwiO/TmoATIIgzSvrNzl3WU 9prJp73EHkV6uwVm X-Received: by 10.28.129.149 with SMTP id c143mr3912662wmd.47.1497988790615; Tue, 20 Jun 2017 12:59:50 -0700 (PDT) Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id f8sm9212184wme.26.2017.06.20.12.59.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Jun 2017 12:59:50 -0700 (PDT) Date: Tue, 20 Jun 2017 20:59:48 +0100 From: Leif Lindholm To: Ard Biesheuvel Cc: edk2-devel@lists.01.org, liming.gao@intel.com, yonghong.zhu@intel.com, lersek@redhat.com Message-ID: <20170620195948.GC26676@bivouac.eciton.net> References: <1497984234-19871-1-git-send-email-ard.biesheuvel@linaro.org> <1497984234-19871-2-git-send-email-ard.biesheuvel@linaro.org> MIME-Version: 1.0 In-Reply-To: <1497984234-19871-2-git-send-email-ard.biesheuvel@linaro.org> User-Agent: Mutt/1.5.23 (2014-03-12) 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: Tue, 20 Jun 2017 19:58:29 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 unless > 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 built > with -mstrict-align into modules of types other than SEC or PEI, since the > 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 to > cause problems. And even if it did, it would still only affect code built > 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 = DEF(GCC5_ARM_DLINK_FLAGS) -flto -Os -L$(WORKS > DEBUG_GCC5_AARCH64_DLINK_XIPFLAGS = -z common-page-size=0x20 > > RELEASE_GCC5_AARCH64_CC_FLAGS = DEF(GCC5_AARCH64_CC_FLAGS) -flto -Wno-unused-but-set-variable -mcmodel=tiny -fomit-frame-pointer > -RELEASE_GCC5_AARCH64_DLINK_FLAGS = DEF(GCC5_AARCH64_DLINK_FLAGS) -flto -Os -L$(WORKSPACE)/ArmPkg/Library/GccLto -llto-aarch64 -Wl,-plugin-opt=-pass-through=-llto-aarch64 > +RELEASE_GCC5_AARCH64_DLINK_FLAGS = DEF(GCC5_AARCH64_DLINK_FLAGS) -flto -Os -L$(WORKSPACE)/ArmPkg/Library/GccLto -llto-aarch64 -Wl,-plugin-opt=-pass-through=-llto-aarch64 -Wno-lto-type-mismatch > > NOOPT_GCC5_AARCH64_CC_FLAGS = DEF(GCC5_AARCH64_CC_FLAGS) -O0 -mcmodel=small > NOOPT_GCC5_AARCH64_DLINK_FLAGS = DEF(GCC5_AARCH64_DLINK_FLAGS) -z common-page-size=0x1000 -O0 > -- > 2.7.4 >