public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Steven Shi" <steven.shi@intel.com>
To: devel@edk2.groups.io
Cc: liming.gao@intel.com, bob.c.feng@intel.com,
	christian.rodriguez@intel.com, michael.johnson@intel.com, "Shi,
	Steven" <steven.shi@intel.com>
Subject: [PATCH v3 3/5] BaseTools: Change the [Arch][Name] module key in Build cache
Date: Tue, 13 Aug 2019 16:50:53 +0800	[thread overview]
Message-ID: <20190813085055.23208-4-steven.shi@intel.com> (raw)
In-Reply-To: <20190813085055.23208-1-steven.shi@intel.com>

From: "Shi, Steven" <steven.shi@intel.com>

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1951

Current build cache use the module's [self.Arch][self.Name]
info as the ModuleAutoGen object key in hash list and dictionary.
The [self.Arch][self.Name] is not safe as the module key because
there could be two modules with same module name and arch name in
one platform. E.g. A platform can override a module or library
instance in another different path, the overriding module can has
the same module name and arch name as the original one.
Directly use the ModuleAutoGen obj self as the key, because
the obj __hash__ and __repr__ attributes already contain the
full path and arch name.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Bob Feng <bob.c.feng@intel.com>
Signed-off-by: Steven Shi <steven.shi@intel.com>
---
 BaseTools/Source/Python/AutoGen/GenMake.py |  6 +-----
 BaseTools/Source/Python/build/build.py     | 49 +++++++++++++++++++++----------------------------
 2 files changed, 22 insertions(+), 33 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/Python/AutoGen/GenMake.py
index 79387856bd..de820eeb2f 100755
--- a/BaseTools/Source/Python/AutoGen/GenMake.py
+++ b/BaseTools/Source/Python/AutoGen/GenMake.py
@@ -940,16 +940,12 @@ cleanlib:
                     continue
                 headerFileDependencySet.add(aFileName)
 
-        # Ensure that gModuleBuildTracking has been initialized per architecture
-        if self._AutoGenObject.Arch not in GlobalData.gModuleBuildTracking:
-            GlobalData.gModuleBuildTracking[self._AutoGenObject.Arch] = dict()
-
         # Check if a module dependency header file is missing from the module's MetaFile
         for aFile in headerFileDependencySet:
             if aFile in headerFilesInMetaFileSet:
                 continue
             if GlobalData.gUseHashCache:
-                GlobalData.gModuleBuildTracking[self._AutoGenObject.Arch][self._AutoGenObject] = 'FAIL_METAFILE'
+                GlobalData.gModuleBuildTracking[self._AutoGenObject] = 'FAIL_METAFILE'
             EdkLogger.warn("build","Module MetaFile [Sources] is missing local header!",
                         ExtraData = "Local Header: " + aFile + " not found in " + self._AutoGenObject.MetaFile.Path
                         )
diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/build/build.py
index a35a29b150..3e6cfd9faf 100755
--- a/BaseTools/Source/Python/build/build.py
+++ b/BaseTools/Source/Python/build/build.py
@@ -630,12 +630,11 @@ class BuildTask:
 
         # Set the value used by hash invalidation flow in GlobalData.gModuleBuildTracking to 'SUCCESS'
         # If Module or Lib is being tracked, it did not fail header check test, and built successfully
-        if (self.BuildItem.BuildObject.Arch in GlobalData.gModuleBuildTracking and
-           self.BuildItem.BuildObject in GlobalData.gModuleBuildTracking[self.BuildItem.BuildObject.Arch] and
-           GlobalData.gModuleBuildTracking[self.BuildItem.BuildObject.Arch][self.BuildItem.BuildObject] != 'FAIL_METAFILE' and
+        if (self.BuildItem.BuildObject in GlobalData.gModuleBuildTracking and
+           GlobalData.gModuleBuildTracking[self.BuildItem.BuildObject] != 'FAIL_METAFILE' and
            not BuildTask._ErrorFlag.isSet()
            ):
-            GlobalData.gModuleBuildTracking[self.BuildItem.BuildObject.Arch][self.BuildItem.BuildObject] = 'SUCCESS'
+            GlobalData.gModuleBuildTracking[self.BuildItem.BuildObject] = 'SUCCESS'
 
         # indicate there's a thread is available for another build task
         BuildTask._RunningQueueLock.acquire()
@@ -1171,25 +1170,24 @@ class Build():
             return
 
         # GlobalData.gModuleBuildTracking contains only modules or libs that cannot be skipped by hash
-        for moduleAutoGenObjArch in GlobalData.gModuleBuildTracking.keys():
-            for moduleAutoGenObj in GlobalData.gModuleBuildTracking[moduleAutoGenObjArch].keys():
-                # Skip invalidating for Successful Module/Lib builds
-                if GlobalData.gModuleBuildTracking[moduleAutoGenObjArch][moduleAutoGenObj] == 'SUCCESS':
-                    continue
+        for Ma in GlobalData.gModuleBuildTracking:
+            # Skip invalidating for Successful Module/Lib builds
+            if GlobalData.gModuleBuildTracking[Ma] == 'SUCCESS':
+                continue
 
-                # The module failed to build, failed to start building, or failed the header check test from this point on
+            # The module failed to build, failed to start building, or failed the header check test from this point on
 
-                # Remove .hash from build
-                ModuleHashFile = os.path.join(moduleAutoGenObj.BuildDir, moduleAutoGenObj.Name + ".hash")
-                if os.path.exists(ModuleHashFile):
-                    os.remove(ModuleHashFile)
+            # Remove .hash from build
+            ModuleHashFile = os.path.join(Ma.BuildDir, Ma.Name + ".hash")
+            if os.path.exists(ModuleHashFile):
+                os.remove(ModuleHashFile)
 
-                # Remove .hash file from cache
-                if GlobalData.gBinCacheDest:
-                    FileDir = os.path.join(GlobalData.gBinCacheDest, moduleAutoGenObj.Arch, moduleAutoGenObj.SourceDir, moduleAutoGenObj.MetaFile.BaseName)
-                    HashFile = os.path.join(FileDir, moduleAutoGenObj.Name + '.hash')
-                    if os.path.exists(HashFile):
-                        os.remove(HashFile)
+            # Remove .hash file from cache
+            if GlobalData.gBinCacheDest:
+                FileDir = os.path.join(GlobalData.gBinCacheDest, Ma.PlatformInfo.OutputDir, Ma.BuildTarget + "_" + Ma.ToolChain, Ma.Arch, Ma.SourceDir, Ma.MetaFile.BaseName)
+                HashFile = os.path.join(FileDir, Ma.Name + '.hash')
+                if os.path.exists(HashFile):
+                    os.remove(HashFile)
 
     ## Build a module or platform
     #
@@ -1889,10 +1887,7 @@ class Build():
 
                             self.BuildModules.append(Ma)
                             # Initialize all modules in tracking to 'FAIL'
-                            if Ma.Arch not in GlobalData.gModuleBuildTracking:
-                                GlobalData.gModuleBuildTracking[Ma.Arch] = dict()
-                            if Ma not in GlobalData.gModuleBuildTracking[Ma.Arch]:
-                                GlobalData.gModuleBuildTracking[Ma.Arch][Ma] = 'FAIL'
+                            GlobalData.gModuleBuildTracking[Ma] = 'FAIL'
                     self.AutoGenTime += int(round((time.time() - AutoGenStart)))
                     MakeStart = time.time()
                     for Ma in self.BuildModules:
@@ -2075,10 +2070,8 @@ class Build():
                             PcdMaList.append(Ma)
                         TotalModules.append(Ma)
                         # Initialize all modules in tracking to 'FAIL'
-                        if Ma.Arch not in GlobalData.gModuleBuildTracking:
-                            GlobalData.gModuleBuildTracking[Ma.Arch] = dict()
-                        if Ma not in GlobalData.gModuleBuildTracking[Ma.Arch]:
-                            GlobalData.gModuleBuildTracking[Ma.Arch][Ma] = 'FAIL'
+                        GlobalData.gModuleBuildTracking[Ma] = 'FAIL'
+
                     mqueue = mp.Queue()
                     for m in Pa.GetAllModuleInfo:
                         mqueue.put(m)
-- 
2.17.1


  parent reply	other threads:[~2019-08-13  8:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-13  8:50 [PATCH v3 0/5] Build cache enhancement Steven Shi
2019-08-13  8:50 ` [PATCH v3 1/5] BaseTools: Improve the cache hit in the edk2 build cache Steven Shi
2019-08-13  8:50 ` [PATCH v3 2/5] BaseTools: Print first cache missing file for build cachle Steven Shi
2019-08-13  8:50 ` Steven Shi [this message]
2019-08-13  8:50 ` [PATCH v3 4/5] BaseTools: Add GenFds multi-thread support in build cache Steven Shi
2019-08-13  8:50 ` [PATCH v3 5/5] BaseTools: Improve the file saving and copying reliability Steven Shi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190813085055.23208-4-steven.shi@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox