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 24D718224E for ; Wed, 22 Feb 2017 17:14:26 -0800 (PST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Feb 2017 17:14:25 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,197,1484035200"; d="scan'208";a="228621800" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga004.fm.intel.com with ESMTP; 22 Feb 2017 17:14:25 -0800 Received: from fmsmsx123.amr.corp.intel.com (10.18.125.38) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 22 Feb 2017 17:14:25 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx123.amr.corp.intel.com (10.18.125.38) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 22 Feb 2017 17:14:25 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.88]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.204]) with mapi id 14.03.0248.002; Thu, 23 Feb 2017 09:14:22 +0800 From: "Gao, Liming" To: Laszlo Ersek , "Zhu, Yonghong" , "edk2-devel@ml01.01.org" Thread-Topic: [edk2] [Patch] BaseTools: add error check for Macro usage in the INF file Thread-Index: AQHSi+BtosM0nHLjZ0+tobSkW2PI+KF1Qy8AgAACuoCAAIZsIA== Date: Thu, 23 Feb 2017 01:14:22 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14D6E3223@shsmsx102.ccr.corp.intel.com> References: <1487639901-43004-1-git-send-email-yonghong.zhu@intel.com> <43a78396-e70c-287e-275e-2891154c0d5c@redhat.com> <0dd4b927-a41f-e3a8-cb59-2421f20d8857@redhat.com> In-Reply-To: <0dd4b927-a41f-e3a8-cb59-2421f20d8857@redhat.com> 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] BaseTools: add error check for Macro usage in the INF file X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Feb 2017 01:14:26 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Laszlo: Yonghong has sent the another patch to its regression issue. Could you ve= rify it? Thanks Liming -----Original Message----- From: Laszlo Ersek [mailto:lersek@redhat.com]=20 Sent: Thursday, February 23, 2017 9:12 AM To: Zhu, Yonghong ; edk2-devel@ml01.01.org Cc: Gao, Liming Subject: Re: [edk2] [Patch] BaseTools: add error check for Macro usage in t= he INF file On 02/23/17 02:02, Laszlo Ersek wrote: > Hi, >=20 > On 02/21/17 02:18, Yonghong Zhu wrote: >> Use of MACRO statements in the EDK II INF files is limited to local >> usage only; global or external macros are not permitted. This patch >> add the check for not defined macros. >> >> Cc: Liming Gao >> Contributed-under: TianoCore Contribution Agreement 1.0 >> Signed-off-by: Yonghong Zhu >> --- >> BaseTools/Source/Python/Workspace/MetaFileParser.py | 9 ++++++++- >> BaseTools/Source/Python/Workspace/WorkspaceDatabase.py | 4 +++- >> 2 files changed, 11 insertions(+), 2 deletions(-) >> >> diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseT= ools/Source/Python/Workspace/MetaFileParser.py >> index 1a5fdf5..37a7f5d 100644 >> --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py >> +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py >> @@ -1,9 +1,9 @@ >> ## @file >> # This file is used to parse meta files >> # >> -# Copyright (c) 2008 - 2016, Intel Corporation. All rights reserved. >> +# Copyright (c) 2008 - 2017, Intel Corporation. All rights reserved. >> # (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
>> # This program and the accompanying materials >> # are licensed and made available under the terms and conditions of the= BSD License >> # which accompanies this distribution. The full text of the license ma= y be found at >> # http://opensource.org/licenses/bsd-license.php >> @@ -349,10 +349,17 @@ class MetaFileParser(object): >> EdkLogger.error('Parser', FORMAT_INVALID, "No value specifi= ed", >> ExtraData=3Dself._CurrentLine, File=3Dself.= MetaFile, Line=3Dself._LineIndex + 1) >> =20 >> self._ValueList =3D [ReplaceMacro(Value, self._Macros) for Valu= e in self._ValueList] >> Name, Value =3D self._ValueList[1], self._ValueList[2] >> + MacroUsed =3D GlobalData.gMacroRefPattern.findall(Value) >> + if len(MacroUsed) !=3D 0: >> + for Macro in MacroUsed: >> + if Macro in GlobalData.gGlobalDefines: >> + EdkLogger.error("Parser", FORMAT_INVALID, "Global m= acro %s is not permitted." % (Macro), ExtraData=3Dself._CurrentLine, File= =3Dself.MetaFile, Line=3Dself._LineIndex + 1) >> + else: >> + EdkLogger.error("Parser", FORMAT_INVALID, "%s not defin= ed" % (Macro), ExtraData=3Dself._CurrentLine, File=3Dself.MetaFile, Line=3D= self._LineIndex + 1) >> # Sometimes, we need to make differences between EDK and EDK2 m= odules=20 >> if Name =3D=3D 'INF_VERSION': >> if re.match(r'0[xX][\da-f-A-F]{5,8}', Value): >> self._Version =3D int(Value, 0) =20 >> elif re.match(r'\d+\.\d+', Value): >> diff --git a/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py b/Ba= seTools/Source/Python/Workspace/WorkspaceDatabase.py >> index e7bc87d..0686721 100644 >> --- a/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py >> +++ b/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py >> @@ -1,9 +1,9 @@ >> ## @file >> # This file is used to create a database used by build tool >> # >> -# Copyright (c) 2008 - 2016, Intel Corporation. All rights reserved. >> +# Copyright (c) 2008 - 2017, Intel Corporation. All rights reserved. >> # (C) Copyright 2016 Hewlett Packard Enterprise Development LP
>> # This program and the accompanying materials >> # are licensed and made available under the terms and conditions of the= BSD License >> # which accompanies this distribution. The full text of the license ma= y be found at >> # http://opensource.org/licenses/bsd-license.php >> @@ -1828,10 +1828,12 @@ class InfBuildData(ModuleBuildClassObject): >> self.__Macros =3D {} >> # EDK_GLOBAL defined macros can be applied to EDK module >> if self.AutoGenVersion < 0x00010005: >> self.__Macros.update(GlobalData.gEdkGlobal) >> self.__Macros.update(GlobalData.gGlobalDefines) >> + else: >> + self.__Macros.update(self.Defines) >> return self.__Macros >> =20 >> ## Get architecture >> def _GetArch(self): >> return self._Arch >> >=20 > I don't understand how, but this patch (commit dc4c770763d0) breaks OVMF = for me. >=20 > I bisected it, I didn't want to believe it, then I built the tree right b= efore it, and that worked. >=20 > I also built the tree at current master (526f160f311c, "ArmPkg/ArmMmuLib:= AARCH64: enable stack alignment checking", 2017-02-22), with this commit r= everted on top, and that also works. >=20 > This is the error I see in the OVMF log: >=20 >> Loading driver E660EA85-058E-4B55-A54B-F02F83A24707 >> InstallProtocolInterface: 5B1B31A1-9562-11D2-8E3F-00A0C969723B 7E8752C0 >> Loading driver at 0x0007E4B7000 EntryPoint=3D0x0007E4B727B DisplayEngine= .efi >> InstallProtocolInterface: BC62157E-3E33-4FEC-9920-2D3B36D750DF 7E875518 >> ProtectUefiImageCommon - 0x7E8752C0 >> - 0x000000007E4B7000 - 0x000000000001BAE0 >> ASSERT .../MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLi= b.c(928): mCDLStringPackHandle !=3D ((void *) 0) >=20 > I don't have the slightest clue what's going on. Apparently, this change = causes BaseTools to mis-build OVMF. If it's any help, I think that the second hunk breaks library constructors = somehow. I compared the build report files between "good" (--> without this patch) a= nd "bad" (--> with this patch), and the differences I see follow this patte= rn, under every module that links against library instance with a construct= or: >-------------------------------------------------------------------------= ---------------------------------------------< Library --------------------------------------------------------------------------= ---------------------------------------------- MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf {MemoryAllocationLib} MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt= .inf {PeiServicesTablePointerLib} MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf {PcdLib} MdePkg/Library/BaseLib/BaseLib.inf {BaseLib} MdePkg/Library/BaseMemoryLibRepStr/BaseMemoryLibRepStr.inf {BaseMemoryLib} MdePkg/Library/PeiHobLib/PeiHobLib.inf {HobLib} MdePkg/Library/PeiServicesLib/PeiServicesLib.inf {PeiServicesLib} MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf {DebugPrintErrorLevelLib} MdePkg/Library/BasePrintLib/BasePrintLib.inf {PrintLib} MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf {IoLib} OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf -{DebugLib: C =3D PlatformDebugLibIoPortConstructor} +{DebugLib: C =3D PlatformDebugLibIoPortConstructor PlatformDebugLibIoPort= Constructor} MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf {PeimEntryPoint} <-------------------------------------------------------------------------= ---------------------------------------------> Note "DebugLib". In the "bad" case, the constructor name seems to be duplic= ated. This applies to all other constructor functions as well. Thanks Laszlo