From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=40.107.70.139; helo=nam04-sn1-obe.outbound.protection.outlook.com; envelope-from=christopher.co@microsoft.com; receiver=edk2-devel@lists.01.org Received: from NAM04-SN1-obe.outbound.protection.outlook.com (mail-eopbgr700139.outbound.protection.outlook.com [40.107.70.139]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 3092A21B02845 for ; Wed, 27 Jun 2018 13:03:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9EfJ5EBsGDtL8bPsxLNGN6n27vres3kNvGlcHqsQl0M=; b=ZnwbjQfQ5Gl6dVzYTB++/g+oHu/2/JoKY0TN6txlef+NFP6fL3THLdw61zqwl0xBXpYWBOjGXj5WATi7iJBf2T951K1i4uNP9dFB0KvmF/U6kdeC3M/NTzWTsvI1ajkoLYffB1OzQzk1RUr8HtBpSTCedN8PokjFKHM0LrPMfuI= Received: from DM5PR2101MB1128.namprd21.prod.outlook.com (52.132.133.20) by DM5PR2101MB0998.namprd21.prod.outlook.com (52.132.133.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.930.4; Wed, 27 Jun 2018 20:03:09 +0000 Received: from DM5PR2101MB1128.namprd21.prod.outlook.com ([fe80::28cb:9380:49e8:e0d0]) by DM5PR2101MB1128.namprd21.prod.outlook.com ([fe80::28cb:9380:49e8:e0d0%2]) with mapi id 15.20.0930.005; Wed, 27 Jun 2018 20:03:09 +0000 From: Chris Co To: Evan Lloyd , "edk2-devel@lists.01.org" , Liming Gao Thread-Topic: [PATCH v1 1/1] BaseTools/Trim: Canonicalize filepaths to fix comparison Thread-Index: AQHUDcsNZUVBqOxBWkWwqrDKFPQJj6Rz8L2wgABoEeCAABL1AIAAGzbg Date: Wed, 27 Jun 2018 20:03:09 +0000 Message-ID: References: <20180627035753.49848-1-christopher.co@microsoft.com> <20180627035753.49848-2-christopher.co@microsoft.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=True; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Owner=chrco@microsoft.com; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2018-06-27T18:13:24.3213231Z; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=General; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Application=Microsoft Azure Information Protection; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Extended_MSFT_Method=Automatic; Sensitivity=General x-originating-ip: [2001:4898:80e8:a:ac56:341b:8c69:467b] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DM5PR2101MB0998; 7:Wsn6sl81LBX925IbPWn+kJqQ0bSMtv2HonqqQ6aFxlx9sfvk/N4sLOLoHRIiw8z2d0rg/PmgB45rKsXaUdM65Q5c+8xIdgeV4moSKcPuI1TmuOf7DttCMYx4vpr2loBMN1Dk9iqxk9MX1PgJYX+fc6RDbDk0+bsaudU64nrJCIkXnwYAWuPysdV0fdbUlSPVgFQ4WyK7y5opLWVPETn/OkOG+WK9mhA6NFDMDg4ZJBYTc0yuiaip8bHkbAjej0Q6 x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: 0b9a4fe1-9807-4ad6-8ecc-08d5dc69016a x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:(223705240517415); BCL:0; PCL:0; RULEID:(7020095)(4652020)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600026)(711020)(48565401081)(2017052603328)(7193020); SRVR:DM5PR2101MB0998; x-ms-traffictypediagnostic: DM5PR2101MB0998: x-ld-processed: 72f988bf-86f1-41af-91ab-2d7cd011db47,ExtAddr x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(180628864354917)(89211679590171)(166708455590820)(189930954265078)(223705240517415)(788757137089)(162533806227266)(219752817060721)(228905959029699); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(3231254)(2018427008)(944501410)(52105095)(3002001)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(20161123564045)(20161123562045)(6072148)(201708071742011)(7699016); SRVR:DM5PR2101MB0998; BCL:0; PCL:0; RULEID:; SRVR:DM5PR2101MB0998; x-forefront-prvs: 0716E70AB6 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(396003)(136003)(366004)(376002)(346002)(39860400002)(13464003)(189003)(199004)(33656002)(14454004)(68736007)(8676002)(6436002)(53546011)(6506007)(478600001)(10090500001)(72206003)(10290500003)(486006)(55016002)(9686003)(8936002)(102836004)(81156014)(81166006)(97736004)(476003)(966005)(86362001)(74316002)(446003)(86612001)(575784001)(2900100001)(11346002)(229853002)(53936002)(76176011)(6306002)(7696005)(2906002)(105586002)(6246003)(6346003)(106356001)(46003)(25786009)(5250100002)(2501003)(7736002)(4326008)(305945005)(5660300001)(54906003)(93886005)(99286004)(6116002)(8990500004)(2940100002)(316002)(22452003)(110136005)(256004)(14444005)(5024004)(186003)(460985005); DIR:OUT; SFP:1102; SCL:1; SRVR:DM5PR2101MB0998; H:DM5PR2101MB1128.namprd21.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Christopher.Co@microsoft.com; x-microsoft-antispam-message-info: Zrh7BsJyR8XOmAjPsFnM5+k2qUoPL5Qr9JWsYq6fRwgyctJ6EXB1CxMhXAB0Q/11OgL1JaJcPfUVGp29JbRZ+IXdPwPlmPVvXC/aOqsZotYhEEI6tnJMxiQLxWeWmBhlhkbzKmJTkDsHjfiAjtxOUzl41hHoQ4x2SSWLEme8Q8s12y9FnL0yJDfknXrr3SrAn5pADqiVfxU8R39Y3Xc8dJF8RfKo78/d0GjHVfb4Bez/9iOiEMKDpx7+Kgz69SLai2A+yZVAeborvO07YA2WbgjSbrYZUy7QnJdpJiT0deySQ9MP2dmDopK+DJJdE4cz1zdUnXJqD2W9/6kth4G+CNonG0T9VOP629t4fiJQ24M= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0b9a4fe1-9807-4ad6-8ecc-08d5dc69016a X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Jun 2018 20:03:09.5159 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0998 Subject: Re: [PATCH v1 1/1] BaseTools/Trim: Canonicalize filepaths to fix comparison X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Jun 2018 20:03:12 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable > -----Original Message----- > From: Chris Co > Sent: Wednesday, June 27, 2018 11:23 AM > To: 'Evan Lloyd' ; 'edk2-devel@lists.01.org' devel@lists.01.org>; 'Liming Gao' > Cc: 'Leif Lindholm' ; Sami Mujawar > > Subject: RE: [PATCH v1 1/1] BaseTools/Trim: Canonicalize filepaths to fix > comparison >=20 > Forgot to add that I'll try out the os.path.normpath/normcase to see if t= his > will work. >=20 Just tried out os.path.normpath and os.path.normcase and together, these ca= lls do achieve the desired result. Initial filepath string =3D "e:\\rebase\\Build\\HUMMINGBOARD_EDGE_IMX6Q_2GB= \\RELEASE_GCC49xASL\\ARM\\Platform\\SolidRun\\HUMMINGBOARD_EDGE_IMX6Q_2GB\\= AcpiTables\\AcpiTables\\OUTPUT\\.\\DSDT.i" After normpath =3D "e:\rebase\Build\HUMMINGBOARD_EDGE_IMX6Q_2GB\RELEASE_GCC= 49xASL\ARM\Platform\SolidRun\HUMMINGBOARD_EDGE_IMX6Q_2GB\AcpiTables\AcpiTab= les\OUTPUT\DSDT.i" After normcase =3D "e:\rebase\build\hummingboard_edge_imx6q_2gb\release_gcc= 49xasl\arm\platform\solidrun\hummingboard_edge_imx6q_2gb\acpitables\acpitab= les\output\dsdt.i" I would prefer to use the os module instead of my direct string manipulatio= n approach so let me know if this change is acceptable and I can submit a v= 2 using these functions instead. > > -----Original Message----- > > From: Chris Co > > Sent: Wednesday, June 27, 2018 11:13 AM > > To: 'Evan Lloyd' ; edk2-devel@lists.01.org; Liming > > Gao > > Cc: Leif Lindholm ; Sami Mujawar > > > > Subject: RE: [PATCH v1 1/1] BaseTools/Trim: Canonicalize filepaths to > > fix comparison > > > > Hi Liming, Evan, > > > > I have attached an example of a generated DSDT.iii file which gets > > processed using Trim. It will give us a concrete example of what these > changes do. > > > > The first line has its #line directive stripped and the filepath saved > > as the PreProcessedFile. In GCC49, the filepath was: > > > "e:\\rebase\\Build\\HUMMINGBOARD_EDGE_IMX6Q_2GB\\RELEASE_GCC4 > > > 9xASL\\ARM\\Platform\\SolidRun\\HUMMINGBOARD_EDGE_IMX6Q_2GB\\ > > AcpiTables\\AcpiTables\\OUTPUT\\.\\DSDT.i" > > > > while in GCC5+ it is: > > > "e:\\rebase\\build\\hummingboard_edge_imx6q_2gb\\release_gcc5\\arm\ > > > \platform\\solidrun\\hummingboard_edge_imx6q_2gb\\acpitables\\acpitab > > les\\output\\dsdt.i" > > > > So there is a difference in both lowercase as well as \\.\\ before dsdt= .i. > > > > As the Trim function goes through each line, it strips the #line > > directive and saves the filepath as InjectedFile, which is then > > compared against PreProcessedFile > > > (https://github.com/tianocore/edk2/blob/975478f6bb22668efae311eb3f740 > > 6e1f18411c2/BaseTools/Source/Python/Trim/Trim.py#L174) > > If it is not a match, skip to next line. When using GCC5+, DSDT.iii's > > #line directives after the first keeps the old GCC49 filepath syntax > > so the string comparison always fails. An example of a line which > > should match line 602 in DSDT.iii. > > > > So my changes target these two cases directly, but admittedly I'm more > > of a kernel dev than a python dev so if there is a better way to > > address this, I'm all for it. > > > > > -----Original Message----- > > > From: Evan Lloyd > > > Sent: Wednesday, June 27, 2018 4:35 AM > > > To: Chris Co ; edk2-devel@lists.01.org > > > Cc: Liming Gao ; Leif Lindholm > > > ; Sami Mujawar > > > Subject: RE: [PATCH v1 1/1] BaseTools/Trim: Canonicalize filepaths > > > to fix comparison > > > > > > Hi Chris. > > > Firstly, thank you: this is a useful, pragmatic solution to an major > > annoyance. > > > I personally think it unfortunate that the GCC guys can't be > > > bothered to fix their compiler, but ... > > > > > > > -----Original Message----- > > > > From: edk2-devel On Behalf Of > > > > Chris Co > > > > Sent: 27 June 2018 04:58 > > > > To: edk2-devel@lists.01.org > > > > Cc: Liming Gao > > > > Subject: [edk2] [PATCH v1 1/1] BaseTools/Trim: Canonicalize > > > > filepaths to fix comparison > > > > > > > > When using Linaro GCC5+ arm-eabi toolchain on Windows, the > > > > generated DSDT.iii contains a canonicalized ("\.\" removed and > > > > lower case) filepath for the preprocessed DSDT.i file in the first = line. > > > > Due to this, when Trim.exe is called to generate DSDT.iiii, future > > > > filepath comparisons against this canonicalized filepath, which > > > > should match, actually fail the comparison which results in an > > > > empty > > DSDT.iiii. > > > > > > > > Issue was first reported to Linaro here: > > > > > > > > > > https://na01.safelinks.protection.outlook.com/?url=3Dhttps%3A%2F%2Fbugs. > > > > > > > > > > linaro.org%2Fshow_bug.cgi%3Fid%3D2909&data=3D02%7C01%7CChristop > > > her.C > > > > > > > > > > o%40microsoft.com%7C2abbef5e0163411f08e708d5dc220678%7C72f988bf86 > > > f141a > > > > > > > > > > f91ab2d7cd011db47%7C1%7C0%7C636656961074375810&sdata=3D%2FvFv > > > maBD0ul > > > > z89CY%2BMaOpwvpTvK9%2FxXjeZeSiXUCYH0%3D&reserved=3D0 > > > > where the recommendation was to address the issue in Trim.exe. > > > > > > > > This patch canonicalizes and lower cases all file paths > > > > encountered during trim execution on preprocessed files. Since > > > > file paths are standarized, the comparison succeeds for files that > > > > should match regardless of the presence of upper case or "\.\" > > > > characters in the file > > path. > > > > > > > > Contributed-under: TianoCore Contribution Agreement 1.1 > > > > Signed-off-by: Christopher Co > > > > Cc: Leif Lindholm > > > > Cc: Yonghong Zhu > > > > Cc: Liming Gao > > > > --- > > > > BaseTools/Source/Python/Trim/Trim.py | 2 ++ > > > > 1 file changed, 2 insertions(+) > > > > > > > > diff --git a/BaseTools/Source/Python/Trim/Trim.py > > > > b/BaseTools/Source/Python/Trim/Trim.py > > > > index a74075859148..cca4e5c9694a 100644 > > > > --- a/BaseTools/Source/Python/Trim/Trim.py > > > > +++ b/BaseTools/Source/Python/Trim/Trim.py > > > > @@ -166,6 +166,8 @@ def TrimPreprocessedFile(Source, Target, > > > > ConvertHex, > > > > TrimLong): > > > > if len(MatchList) =3D=3D 2: > > > > LineNumber =3D int(MatchList[0], 0) > > > > InjectedFile =3D MatchList[1] > > > > + InjectedFile =3D InjectedFile.replace("\\.\\","") > > > > > > [[Evan Lloyd]] I've not actually tried this yet, but it looks > > > surprizing. I'd have expected InjectedFile.replace("\\.\\","\\"). > > > Can I ask how it works, please? Have I missed something? > > > [[Evan Lloyd]] Would it be possible to achieve the same effect with > > > os.path.normpath (see Common/LongFilePathOsPath.py imported via > line > > > 17)? > > > > > > > + InjectedFile =3D InjectedFile.lower() > > > [[Evan Lloyd]] Similarly, there is "os.path.normcase" - but that may > > > not get the comparison working (because it converts '/' to '\' on > Windows). > > > > > > > # The first injetcted file must be the preprocesse= d file itself > > > > if PreprocessedFile =3D=3D "": > > > > PreprocessedFile =3D InjectedFile > > > > -- > > > > 2.16.2.gvfs.1.33.gf5370f1 > > > > > > > > _______________________________________________ > > > > edk2-devel mailing list > > > > edk2-devel@lists.01.org > > > > https://na01.safelinks.protection.outlook.com/?url=3Dhttps%3A%2F%2F= l > > > > is > > > > ts > > > > .01.org%2Fmailman%2Flistinfo%2Fedk2- > > > devel&data=3D02%7C01%7CChristoph > > > > > > > > > > er.Co%40microsoft.com%7C2abbef5e0163411f08e708d5dc220678%7C72f988 > > > bf86f > > > > > > > > > > 141af91ab2d7cd011db47%7C1%7C0%7C636656961074385815&sdata=3Duu > > > S9M90lN > > > > ewzqS6ScNwbSm8xC9wpdzAFVZhjEu8w2kk%3D&reserved=3D0 > > > IMPORTANT NOTICE: The contents of this email and any attachments are > > > confidential and may also be privileged. If you are not the intended > > > recipient, please notify the sender immediately and do not disclose > > > the contents to any other person, use it for any purpose, or store > > > or copy the information in any medium. Thank you.