Bug 14578

Summary: sstate sigs with hash equiv are different on aarch64 vs x86_64
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Richard Purdie <richard.purdie>
Component: coreAssignee: Richard Purdie <richard.purdie>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium+ CC: JPEWhacker, meta.mr.watcher, meta.watcher, ross.burton
Version: 0.0.0   
Target Milestone: 3.4 M4   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)

Description Richard Purdie 2021-09-28 10:10:34 UTC
We have sstate and hash equivalence from the autobuilder. The sstate signatures of native are host independent, the idea being that regardless of which host you build upon, the target output should be the same. This means that the sstate for MACHINE=qemux86-64 should be reusable regardless of whether you're on an x86_64 or aarch64 host. Without hash equivalence, that is true and works.

Taking a checkout of master (which recently built on the autobuilder) and adding the following config:

BB_HASHSERVE_UPSTREAM = "typhoon.yocto.io:8687"
SSTATE_MIRRORS ?= "file://.* http://sstate.yoctoproject.org/dev/PATH;downloadfilename=PATH"

then on two different autobuilder workers, ubuntu2004-ty-1 and ubuntu2004-arm-1,  running MACHINE=qemux86-64 bitbake core-image-sato does not reuse much sstate in the aarch64 case. Note that qemux86-64 is not built on an aarch64 system on the autobuilder.

To debug further, I ran "bitbake bash -S none" which generates stamp files for each build.

rpurdie@ubuntu2004-ty-1:~/poky/build$ ls tmp/stamps/x86_64-linux/m4-native
1.4.19-r0.do_compile.sigdata.9a4d15cb2230011a640f895c64287f44c6ccce3de98493bd75436f52004e32bc
1.4.19-r0.do_configure.sigdata.5edf66241b4568b18f83da34f4176c215e439d02ad3f8b4b4d43eb17e1b8bdc7
1.4.19-r0.do_deploy_source_date_epoch.sigdata.75367a886aa30fa30bbd8246324689071b5ea7b54f05badc13ba63638dde5a2a
1.4.19-r0.do_fetch.sigdata.e78b6e3ed1a72c1986284a382db5bc80279d19848f997bab7154b8f9e37eaebc
1.4.19-r0.do_install.sigdata.a1f6486bd2f3f1b166a37ede6eab3ba9c0d4a68f1428ff6b3ed3d7d89b6f3195
1.4.19-r0.do_patch.sigdata.015db7748057a788c67d45f5b311d9234ae106891148176484e0bfa2049dd364
1.4.19-r0.do_populate_sysroot.sigdata.5324e7d5ff2bd74f4a31734f440222ff647046464718c82532c8159d7e8ba17d
1.4.19-r0.do_prepare_recipe_sysroot.sigdata.e0dd3cf31df044942294a33a0a0b9b264afcbe27750430014586a54150518ffb
1.4.19-r0.do_unpack.sigdata.814cf06b1e9618cd7f9a3963888c4c9d3db99c1bbd1f220f6ea8e8352e294a21

rpurdie@ubuntu2004-arm-1:~/poky/build$ ls tmp/stamps/aarch64-linux/m4-native/
1.4.19-r0.do_compile.sigdata.9a4d15cb2230011a640f895c64287f44c6ccce3de98493bd75436f52004e32bc
1.4.19-r0.do_configure.sigdata.5edf66241b4568b18f83da34f4176c215e439d02ad3f8b4b4d43eb17e1b8bdc7
1.4.19-r0.do_deploy_source_date_epoch.sigdata.75367a886aa30fa30bbd8246324689071b5ea7b54f05badc13ba63638dde5a2a
1.4.19-r0.do_fetch.sigdata.e78b6e3ed1a72c1986284a382db5bc80279d19848f997bab7154b8f9e37eaebc
1.4.19-r0.do_install.sigdata.a1f6486bd2f3f1b166a37ede6eab3ba9c0d4a68f1428ff6b3ed3d7d89b6f3195
1.4.19-r0.do_patch.sigdata.015db7748057a788c67d45f5b311d9234ae106891148176484e0bfa2049dd364
1.4.19-r0.do_populate_sysroot.sigdata.4492b11fff63e8a1b55e6fee0d68196a6848ffb9cac9c18831613ec75a093b35
1.4.19-r0.do_prepare_recipe_sysroot.sigdata.e0dd3cf31df044942294a33a0a0b9b264afcbe27750430014586a54150518ffb
1.4.19-r0.do_unpack.sigdata.814cf06b1e9618cd7f9a3963888c4c9d3db99c1bbd1f220f6ea8e8352e294a21

i.e. the do_populate_sysroot hash differs depending on whether it an arm or x86 host system.

Comparing between the two systems, the sig files are in fact identical and the data is different hash equiv feedback. Adding:

diff --git a/bitbake/lib/bb/siggen.py b/bitbake/lib/bb/siggen.py
index 625a9cf3bb..a01ea740e6 100644
--- a/bitbake/lib/bb/siggen.py
+++ b/bitbake/lib/bb/siggen.py
@@ -534,6 +534,9 @@ class SignatureGeneratorUniHashMixIn(object):
             if tid in self.extramethod:
                 method = method + self.extramethod[tid]
             data = self.client().get_unihash(method, self.taskhash[tid])
+            if "m4-native" in tid:
+                bb.warn("%s: %s->%s" % (tid, self.taskhash[tid], data))
+
             if data:
                 unihash = data
                 # A unique hash equal to the taskhash is not very interesting,

gives:

WARNING: /home/rpurdie/poky/meta/recipes-devtools/m4/m4-native_1.4.19.bb:do_populate_sysroot: 06573e1e82c31d0dfe03732a6dc5259f2ce77b7170f0e742011e3474b5e62353->4492b11fff63e8a1b55e6fee0d68196a6848ffb9cac9c18831613ec75a093b35WARNING: /home/rpurdie/poky/meta/recipes-devtools/m4/m4-

WARNING: /home/rpurdie/poky/meta/recipes-devtools/m4/m4-native_1.4.19.bb:do_populate_sysroot: 06573e1e82c31d0dfe03732a6dc5259f2ce77b7170f0e742011e3474b5e62353->5324e7d5ff2bd74f4a31734f440222ff647046464718c82532c8159d7e8ba17d

i.e. the same submitted hash gives a different has in return. The reason for that is this change:

http://git.yoctoproject.org/cgit.cgi/poky/commit/meta/lib/oe/sstatesig.py?id=7538be0a50106f61b59b1d2cb830273d73700931

That change hints the reason for the issue is that the outhash for aarch64 native is never going to match the outhash of x86_64. The outhash even for x86_64 could vary a lot depending on the host compiler version for example though. I'm not sure if we need to revert that change.
Comment 1 Richard Purdie 2021-09-28 10:58:43 UTC
I've run a version of this patch reverted on the autobuilder to see what happens (I used a fixed extramethod namespace so we can easily isolate and ignore this data).

I'm not convinced this is enough to fix issues though. If the builds qre sequential, i.e. aarch64 builds after x86_64, I think this will work but consider what happens if two builds start in parallel and both aarch64 and x86_64 workers both build the same thing, e.g. m4-native.

In the sequential case, the hash would be mapped to the same thing in both cases so the hash would match. The build would run anyway in both cases but the hashes would stay the same.

In the parallel case, the outhashes would be different, leading to two different end task hashes.

I suspect there is some kind of bug we need to resolve here where we map to any existing mapping even if the outhash is different. I'm explaining this badly and still not sure if that is possible or not.
Comment 2 Richard Purdie 2021-10-13 09:02:52 UTC
Hash Equiv:
http://git.yoctoproject.org/cgit.cgi/poky/commit/?id=c7c47bb0d2c2263c4668c4269c669b282d6168d9
http://git.yoctoproject.org/cgit.cgi/poky/commit/?id=02bc1b422b82b7972686307acb69640a50553fb1
RPM vendor from build host issue:
http://git.yoctoproject.org/cgit.cgi/poky/commit/?id=d441b484ebb4cdde228cedb3378019ffbdc391ac
umask contamination:
http://git.yoctoproject.org/cgit.cgi/poky/commit/?id=58c97902933cced2981dfc7480fc0a458b4fb900
sysroot taskhash issues:
http://git.yoctoproject.org/cgit.cgi/poky/commit/?id=86c7d3e0310f1602327365a360199efe5ea05fc8
useradd task ordering issue:
http://git.yoctoproject.org/cgit.cgi/poky/commit/?id=75b79d5c056b5abb44c546af773e3431d4c09476
kernel do_deploy mismatch
http://git.yoctoproject.org/cgit.cgi/poky/commit/?id=830059cdeb6396dd2e6766f6053ce3b39dc0b7bb
gobject-introspection issue:
http://git.yoctoproject.org/cgit.cgi/poky/commit/?id=089b8d3e7e36a01c85eeeb0456ec3bb42feced5a
libtool-cross issue:
http://git.yoctoproject.org/cgit.cgi/poky/commit/?id=0e7806771e8195b086ae1e3ae3a5c5154d48f898
util-linux issue:
http://git.yoctoproject.org/cgit.cgi/poky/commit/?id=3539c214dd657dce97eb32a1536b051c7cfbe3e2
mesa issue:
http://git.yoctoproject.org/cgit.cgi/poky/commit/?id=86125379b2a348f5eff1b9731ab1906c466cf0c6
gnupg issue:
http://git.yoctoproject.org/cgit.cgi/poky/commit/?id=9f0b69e91c51bad8722e765df95b545e3ecec9b1
package outhash issue:
http://git.yoctoproject.org/cgit.cgi/poky/commit/?id=a543230b342cfc900caeb2703a314b7cbbb2eacc
rpm compression option corrupting rpms:
http://git.yoctoproject.org/cgit.cgi/poky/commit/?id=b6e74ba64ebc5d18e40fd01ef87ca3fde6f33249
python3 issue:
http://git.yoctoproject.org/cgit.cgi/poky/commit/?id=3115aa157de4df5a2e32bd54c8552d8b7a757925