summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2024-05-23 17:17:30 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2024-06-04 12:04:52 +0100
commit652e3028d9763aef318ff4587f2c21a8b280003f (patch)
tree11c7b5c4156795f83b87ffa7c7c5fc918c9a1c03 /meta/lib
parent56c578f6643c09e6d9274bb21381978deb1f4af1 (diff)
downloadpoky-652e3028d9763aef318ff4587f2c21a8b280003f.tar.gz
sstatesig/populate_sdk_ext: Improve unihash cache handling
Copying in the bb_unihashes cache file was at best a hack and creates a number of challenges. One is staying in sync with bitbake since it may not have saved the most recent version of the file. A second is a determinism problem since there may be more entries in the file than the SDK should have had access to. To improve the situation, add code to write the data into the locked-sigs.inc file such that even when locked-sigs aren't used, the right hash mappings are injected by the get_cached_unihash call. The functions in copy_buildsystem need to be updated to preserve data they're not editting. (From OE-Core rev: 11373def3171e75b3b74ef694da213dd21f3064c) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oe/copy_buildsystem.py10
-rw-r--r--meta/lib/oe/sstatesig.py33
2 files changed, 40 insertions, 3 deletions
diff --git a/meta/lib/oe/copy_buildsystem.py b/meta/lib/oe/copy_buildsystem.py
index 81abfbf9e2..ced751b835 100644
--- a/meta/lib/oe/copy_buildsystem.py
+++ b/meta/lib/oe/copy_buildsystem.py
@@ -193,13 +193,17 @@ def prune_lockedsigs(excluded_tasks, excluded_targets, lockedsigs, onlynative, p
193 else: 193 else:
194 f.write(line) 194 f.write(line)
195 invalue = False 195 invalue = False
196 elif line.startswith('SIGGEN_LOCKEDSIGS'): 196 elif line.startswith('SIGGEN_LOCKEDSIGS_t'):
197 invalue = True 197 invalue = True
198 f.write(line) 198 f.write(line)
199 else:
200 invalue = False
201 f.write(line)
199 202
200def merge_lockedsigs(copy_tasks, lockedsigs_main, lockedsigs_extra, merged_output, copy_output=None): 203def merge_lockedsigs(copy_tasks, lockedsigs_main, lockedsigs_extra, merged_output, copy_output=None):
201 merged = {} 204 merged = {}
202 arch_order = [] 205 arch_order = []
206 otherdata = []
203 with open(lockedsigs_main, 'r') as f: 207 with open(lockedsigs_main, 'r') as f:
204 invalue = None 208 invalue = None
205 for line in f: 209 for line in f:
@@ -212,6 +216,9 @@ def merge_lockedsigs(copy_tasks, lockedsigs_main, lockedsigs_extra, merged_outpu
212 invalue = line[18:].split('=', 1)[0].rstrip() 216 invalue = line[18:].split('=', 1)[0].rstrip()
213 merged[invalue] = [] 217 merged[invalue] = []
214 arch_order.append(invalue) 218 arch_order.append(invalue)
219 else:
220 invalue = None
221 otherdata.append(line)
215 222
216 with open(lockedsigs_extra, 'r') as f: 223 with open(lockedsigs_extra, 'r') as f:
217 invalue = None 224 invalue = None
@@ -246,6 +253,7 @@ def merge_lockedsigs(copy_tasks, lockedsigs_main, lockedsigs_extra, merged_outpu
246 f.write(' "\n') 253 f.write(' "\n')
247 fulltypes.append(typename) 254 fulltypes.append(typename)
248 f.write('SIGGEN_LOCKEDSIGS_TYPES = "%s"\n' % ' '.join(fulltypes)) 255 f.write('SIGGEN_LOCKEDSIGS_TYPES = "%s"\n' % ' '.join(fulltypes))
256 f.write('\n' + ''.join(otherdata))
249 257
250 if copy_output: 258 if copy_output:
251 write_sigs_file(copy_output, list(tocopy.keys()), tocopy) 259 write_sigs_file(copy_output, list(tocopy.keys()), tocopy)
diff --git a/meta/lib/oe/sstatesig.py b/meta/lib/oe/sstatesig.py
index db3c409216..b6f8ab92cb 100644
--- a/meta/lib/oe/sstatesig.py
+++ b/meta/lib/oe/sstatesig.py
@@ -93,6 +93,14 @@ def sstate_lockedsigs(d):
93 sigs[pn][task] = [h, siggen_lockedsigs_var] 93 sigs[pn][task] = [h, siggen_lockedsigs_var]
94 return sigs 94 return sigs
95 95
96def lockedsigs_unihashmap(d):
97 unihashmap = {}
98 data = (d.getVar("SIGGEN_UNIHASHMAP") or "").split()
99 for entry in data:
100 pn, task, taskhash, unihash = entry.split(":")
101 unihashmap[(pn, task)] = (taskhash, unihash)
102 return unihashmap
103
96class SignatureGeneratorOEBasicHashMixIn(object): 104class SignatureGeneratorOEBasicHashMixIn(object):
97 supports_multiconfig_datacaches = True 105 supports_multiconfig_datacaches = True
98 106
@@ -100,6 +108,7 @@ class SignatureGeneratorOEBasicHashMixIn(object):
100 self.abisaferecipes = (data.getVar("SIGGEN_EXCLUDERECIPES_ABISAFE") or "").split() 108 self.abisaferecipes = (data.getVar("SIGGEN_EXCLUDERECIPES_ABISAFE") or "").split()
101 self.saferecipedeps = (data.getVar("SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS") or "").split() 109 self.saferecipedeps = (data.getVar("SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS") or "").split()
102 self.lockedsigs = sstate_lockedsigs(data) 110 self.lockedsigs = sstate_lockedsigs(data)
111 self.unihashmap = lockedsigs_unihashmap(data)
103 self.lockedhashes = {} 112 self.lockedhashes = {}
104 self.lockedpnmap = {} 113 self.lockedpnmap = {}
105 self.lockedhashfn = {} 114 self.lockedhashfn = {}
@@ -209,6 +218,15 @@ class SignatureGeneratorOEBasicHashMixIn(object):
209 def get_cached_unihash(self, tid): 218 def get_cached_unihash(self, tid):
210 if tid in self.lockedhashes and self.lockedhashes[tid] and not self._internal: 219 if tid in self.lockedhashes and self.lockedhashes[tid] and not self._internal:
211 return self.lockedhashes[tid] 220 return self.lockedhashes[tid]
221
222 (mc, _, task, fn) = bb.runqueue.split_tid_mcfn(tid)
223 recipename = self.lockedpnmap[fn]
224
225 if (recipename, task) in self.unihashmap:
226 taskhash, unihash = self.unihashmap[(recipename, task)]
227 if taskhash == self.taskhash[tid]:
228 return unihash
229
212 return super().get_cached_unihash(tid) 230 return super().get_cached_unihash(tid)
213 231
214 def dump_sigtask(self, fn, task, stampbase, runtime): 232 def dump_sigtask(self, fn, task, stampbase, runtime):
@@ -219,6 +237,7 @@ class SignatureGeneratorOEBasicHashMixIn(object):
219 237
220 def dump_lockedsigs(self, sigfile, taskfilter=None): 238 def dump_lockedsigs(self, sigfile, taskfilter=None):
221 types = {} 239 types = {}
240 unihashmap = {}
222 for tid in self.runtaskdeps: 241 for tid in self.runtaskdeps:
223 # Bitbake changed this to a tuple in newer versions 242 # Bitbake changed this to a tuple in newer versions
224 if isinstance(tid, tuple): 243 if isinstance(tid, tuple):
@@ -226,13 +245,18 @@ class SignatureGeneratorOEBasicHashMixIn(object):
226 if taskfilter: 245 if taskfilter:
227 if not tid in taskfilter: 246 if not tid in taskfilter:
228 continue 247 continue
229 fn = bb.runqueue.fn_from_tid(tid) 248 (_, _, task, fn) = bb.runqueue.split_tid_mcfn(tid)
230 t = self.lockedhashfn[fn].split(" ")[1].split(":")[5] 249 t = self.lockedhashfn[fn].split(" ")[1].split(":")[5]
231 t = 't-' + t.replace('_', '-') 250 t = 't-' + t.replace('_', '-')
232 if t not in types: 251 if t not in types:
233 types[t] = [] 252 types[t] = []
234 types[t].append(tid) 253 types[t].append(tid)
235 254
255 taskhash = self.taskhash[tid]
256 unihash = self.get_unihash(tid)
257 if taskhash != unihash:
258 unihashmap[tid] = " " + self.lockedpnmap[fn] + ":" + task + ":" + taskhash + ":" + unihash
259
236 with open(sigfile, "w") as f: 260 with open(sigfile, "w") as f:
237 l = sorted(types) 261 l = sorted(types)
238 for t in l: 262 for t in l:
@@ -245,7 +269,12 @@ class SignatureGeneratorOEBasicHashMixIn(object):
245 continue 269 continue
246 f.write(" " + self.lockedpnmap[fn] + ":" + task + ":" + self.get_unihash(tid) + " \\\n") 270 f.write(" " + self.lockedpnmap[fn] + ":" + task + ":" + self.get_unihash(tid) + " \\\n")
247 f.write(' "\n') 271 f.write(' "\n')
248 f.write('SIGGEN_LOCKEDSIGS_TYPES:%s = "%s"' % (self.machine, " ".join(l))) 272 f.write('SIGGEN_LOCKEDSIGS_TYPES:%s = "%s"\n' % (self.machine, " ".join(l)))
273 f.write('SIGGEN_UNIHASHMAP += "\\\n')
274 sortedtid = sorted(unihashmap, key=lambda tid: self.lockedpnmap[bb.runqueue.fn_from_tid(tid)])
275 for tid in sortedtid:
276 f.write(unihashmap[tid] + " \\\n")
277 f.write(' "\n')
249 278
250 def dump_siglist(self, sigfile, path_prefix_strip=None): 279 def dump_siglist(self, sigfile, path_prefix_strip=None):
251 def strip_fn(fn): 280 def strip_fn(fn):