From patchwork Thu Nov 13 21:13:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jansa X-Patchwork-Id: 74471 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF19ACD98E2 for ; Thu, 13 Nov 2025 21:13:33 +0000 (UTC) Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.3609.1763068413004638606 for ; Thu, 13 Nov 2025 13:13:33 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20230601 header.b=aSaWg5j8; spf=pass (domain: gmail.com, ip: 209.85.218.43, mailfrom: martin.jansa@gmail.com) Received: by mail-ej1-f43.google.com with SMTP id a640c23a62f3a-b72bf7e703fso215971166b.2 for ; Thu, 13 Nov 2025 13:13:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763068411; x=1763673211; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=rkcjH+5q3ht4HeTX7rvQZEg5b9XBMZCAi0IcMv6v2Ew=; b=aSaWg5j8RVfBOpsSBAYO0hduXqitCHVxjh3drlqrUfU24M5b9MGhZMHyRyC2vUd4ol JyF01kNOrCBfdLk+yaJ/wZ53ajIA0iWPQkJVLofcdjAI0ymlEZMGwIF9hXEZfJ7+lVLR tZdKcOqqEYn+YbkY3+YMpYFCXhEY9cXpxp+2z73cJFNJ1KgXchQN4tLRNrhc/sKqG+Im sDmp9EeXeiNJ63yEo5PBMnxNhBewDVo/l+Wi1HjO4TlWNHhfG8nHtAXPfq95HUfAqITf Bz2xfjDTBe8g25UAs9ZUzomygKxapm+LB0WiTBasNik6AyeWFgx+CfbcgpAxEy1rWcZ4 h4JA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763068411; x=1763673211; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=rkcjH+5q3ht4HeTX7rvQZEg5b9XBMZCAi0IcMv6v2Ew=; b=qVE9gNUa4wIbnBa3tNUh+EfXV5QmjzyLUKcHlPFiTonA4TxbITNl/KcA7MnQ8if00H vGwQ//wvR2ARKLFxeIAM/4lmys5UMNCkIixvMOe8HliCEjjzuYL0Zho+/IaUnyGnhbSX OxY2YzUzBX2m+8aOu3DZJdMYSNfx7uWUdesbXFBfihPk9CbyyFpQQDSRK628G2aKrM7J HuLX9VxrPcNjC4AHVa69xah8G3vIhfBxECAfWor62xT+7IjeE23nd+abzuhbo2lXf6mP XxVU2Jw1kFadjazFf4dueW4+V6M1FFGrXz3xKvMdY4W9pDPjTcdYYnHE00Zw9PCEceWp 6Ttg== X-Gm-Message-State: AOJu0Yyy66K+HTqFhkO/H5wK3aW/MXZAuFqxyq+Fg9r1k5jzU+uC1L36 D/sKW5ft+D2L97AbC/KNtkxGbe7snk9HPW9w4pVYpEH+grtfQKdkMa5gcT+6bA== X-Gm-Gg: ASbGncvholLDHvmNXbf5VL2btQIcByP5XReUPFOQErtM1LJnMEedcyrA4k1bRs/K0b3 KD9pWQR7gOq8NE9KHUEQ87vPPXitnISEjyWJyhB0GiBz4QM3GFcKSjetV/E4pkTpg6BokuS2Q7P 5b5cxsrs/MI55FeL5wTeSwbw1PxeDu506vtF6pjudrUoMvO7Vxqukhu+KOYxTmCfba84X7XyFnr Jci1xz/6ChTD/HfoJsgriCYJgLEC71bU4F/Elv98qSYZuEIFpaKRGaj9WAUszi+h8gdGKTUZc5E FcbclUdOtjXdWUvIizrsrzAScrG6LC/W7FKJgSRpA23rZsoLouxUrxQEG7vatOLfGn0Cl5JBujq 5ElEexf+WkQVAcdOPLzYj7x6hh3OYwSu5CGz5QBTW/CrCqcwi/3g93Qp1Xnm1q9gD+uRLHyRkFw X3cNxc9bGxGrWsVg== X-Google-Smtp-Source: AGHT+IEUvkxj+K5HRZH33/thCTi7lTUz0dHZytAG40NWt6iNnJWAepwu49985Cocn9O1OQ6cqmu43w== X-Received: by 2002:a17:907:8688:b0:b72:6b3c:1f0d with SMTP id a640c23a62f3a-b7367983f00mr59105266b.35.1763068411263; Thu, 13 Nov 2025 13:13:31 -0800 (PST) Received: from localhost ([109.238.218.228]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b734fed6315sm237487866b.64.2025.11.13.13.13.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Nov 2025 13:13:30 -0800 (PST) From: martin.jansa@gmail.com To: openembedded-core@lists.openembedded.org Cc: Martin Jansa Subject: [RFC][PATCH] cross.bbclass: Propagate dependencies to outhash Date: Thu, 13 Nov 2025 22:13:23 +0100 Message-ID: <20251113211323.3490138-1-martin.jansa@gmail.com> X-Mailer: git-send-email 2.51.2 MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Thu, 13 Nov 2025 21:13:33 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/226267 From: Martin Jansa Similar to what native and staging is doing since: https://git.openembedded.org/openembedded-core/commit/meta/classes/native.bbclass?id=d6c7b9f4f0e61fa6546d3644e27abe3e96f597e2 https://git.openembedded.org/openembedded-core/commit/meta/classes/staging.bbclass?id=1cf62882bbac543960e4815d117ffce0e53bda07 Cross task outputs can call native dependencies and even when cross recipe output doesn't change it might produce different results when the called native dependency is changed, e.g. clang-cross-${TARGET_ARCH} contains symlink to clang binary from clang-native, but when clang-native outhash is changed, clang-cross-${TARGET_ARCH} will still be considered equivalent and target recipes aren't rebuilt with new clang binary, see work around in https://github.com/kraj/meta-clang/pull/1140 to make target recipes to depend directly not only on clang-cross-${TARGET_ARCH} but clang-native as well. I have added a small testcase in meta-selftest which demostrates this issue. Not included in this change, but will send it if useful. openembedded-core $ ls -1 meta-selftest/recipes-devtools/hashequiv-test/ print-datetime-link-cross.bb print-datetime-link-native.bb print-datetime-native.bb print-datetime-usecross.bb print-datetime-usenative.bb print-datetime-native provides script which prints defined PRINT_DATETIME variable. print-datetime-link-native and print-datetime-link-cross both provide a symlink to the script from print-datetime-native. print-datetime-usenative and print-datetime-usecross are target recipes using the native and cross versions of print-datetime-link-* recipe. # clean build all is rebuilt: $ bitbake -k print-datetime-usenative print-datetime-usecross WARNING: print-datetime-native-1.0-r0 do_install: print-datetime-native current DATETIME in script is 2025-11-13_20_05 WARNING: print-datetime-link-native-1.0-r0 do_install: print-datetime-link-native current DATETIME in symlink is 2025-11-13_20_05 WARNING: print-datetime-link-cross-x86_64-1.0-r0 do_install: print-datetime-link-cross-x86_64 current DATETIME in symlink is 2025-11-13_20_05 WARNING: print-datetime-usenative-1.0-r0 do_install: print-datetime-usenative current DATETIME from print-datetime-link is 2025-11-13_20_05 WARNING: print-datetime-usecross-1.0-r0 do_install: print-datetime-usecross current DATETIME from print-datetime-link is 2025-11-13_20_05 # keep sstate-cache and hashserv.db: # print-datetime-usenative is correctly rebuilt, because print-datetime-link-native has different hash (because print-datetime-native hash changed) # print-datetime-usecross wasn't rebuilt, because print-datetime-link-cross-x86_64 doesn't include the changed hash of print-datetime-native $ bitbake -k print-datetime-usenative print-datetime-usecross WARNING: print-datetime-native-1.0-r0 do_install: print-datetime-native current DATETIME in script is 2025-11-13_20_07 WARNING: print-datetime-link-native-1.0-r0 do_install: print-datetime-link-native current DATETIME in symlink is 2025-11-13_20_07 WARNING: print-datetime-link-cross-x86_64-1.0-r0 do_install: print-datetime-link-cross-x86_64 current DATETIME in symlink is 2025-11-13_20_07 WARNING: print-datetime-usenative-1.0-r0 do_install: print-datetime-usenative current DATETIME from print-datetime-link is 2025-11-13_20_07 It's because print-datetime-link-cross-x86_64 depsig doesn't include print-datetime-native signature: $ cat tmp/work/x86_64-linux/print-datetime-link-cross-x86_64/1.0/temp/depsig.do_populate_sysroot OEOuthashBasic 18 SSTATE_PKGSPEC=sstate:print-datetime-link-cross-x86_64:x86_64-oe-linux:1.0:r0:x86_64:14: task=populate_sysroot drwx . drwx ./recipe-sysroot-native drwx ./recipe-sysroot-native/sysroot-providers -rw- 32 19fbeb373f781c2504453c1ca04dab018a7bc8388c87f4bbc59589df31523d07 ./recipe-sysroot-native/sysroot-providers/print-datetime-link-cross-x86_64 drwx ./recipe-sysroot-native/usr drwx ./recipe-sysroot-native/usr/bin drwx ./recipe-sysroot-native/usr/bin/x86_64-oe-linux lrwx ./recipe-sysroot-native/usr/bin/x86_64-oe-linux/print-datetime-link -> ../print-datetime While print-datetime-link-native doesn't have this issue, because print-datetime-native signature is there: $ cat tmp/work/x86_64-linux/print-datetime-link-native/1.0/temp/depsig.do_populate_sysroot OEOuthashBasic 18 print-datetime-native: 60f2734a63d708489570ca719413b4662f8368abc9f4760a279a0a5481e4a17b quilt-native: 65d78a7a5b5cbbf0969798efe558ca28e7ef058f4232fcff266912d16f67a8b8 SSTATE_PKGSPEC=sstate:print-datetime-link-native:x86_64-linux:1.0:r0:x86_64:14: task=populate_sysroot drwx . drwx ./recipe-sysroot-native drwx ./recipe-sysroot-native/sysroot-providers -rw- 26 3d5458be834b2d0e4c65466b9b877d6028ae2210a56399284a23144818666f10 ./recipe-sysroot-native/sysroot-providers/print-datetime-link-native drwx ./recipe-sysroot-native/usr drwx ./recipe-sysroot-native/usr/bin lrwx ./recipe-sysroot-native/usr/bin/print-datetime-link -> print-datetime With the cross.bbclass fix the link-cross recipe has a checksum from native recipe as well: $ cat tmp/work/x86_64-linux/print-datetime-link-cross-x86_64/1.0/temp/depsig.do_populate_sysroot OEOuthashBasic 18 print-datetime-native: 9ceb6c27342eae6b8da86c84685af38fb8927ccc19979aae75b8b1e444b11c5c quilt-native: 65d78a7a5b5cbbf0969798efe558ca28e7ef058f4232fcff266912d16f67a8b8 SSTATE_PKGSPEC=sstate:print-datetime-link-cross-x86_64:x86_64-oe-linux:1.0:r0:x86_64:14: task=populate_sysroot drwx . drwx ./recipe-sysroot-native drwx ./recipe-sysroot-native/sysroot-providers -rw- 32 19fbeb373f781c2504453c1ca04dab018a7bc8388c87f4bbc59589df31523d07 ./recipe-sysroot-native/sysroot-providers/print-datetime-link-cross-x86_64 drwx ./recipe-sysroot-native/usr drwx ./recipe-sysroot-native/usr/bin drwx ./recipe-sysroot-native/usr/bin/x86_64-oe-linux lrwx ./recipe-sysroot-native/usr/bin/x86_64-oe-linux/print-datetime-link -> ../print-datetime And print-datetime-usecross is correctly rebuilt whenever print-datetime-native output is different. Signed-off-by: Martin Jansa --- meta/classes-recipe/cross.bbclass | 36 +++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/meta/classes-recipe/cross.bbclass b/meta/classes-recipe/cross.bbclass index 9abf166e50..c3eeade67b 100644 --- a/meta/classes-recipe/cross.bbclass +++ b/meta/classes-recipe/cross.bbclass @@ -101,3 +101,39 @@ addtask addto_recipe_sysroot after do_populate_sysroot do_addto_recipe_sysroot[deptask] = "do_populate_sysroot" PATH:prepend = "${COREBASE}/scripts/cross-intercept:" + +# +# Cross task outputs can call native dependencies and even when cross +# recipe output doesn't change it might produce different results when +# the called native dependency is changed, e.g. clang-cross-${TARGET_ARCH} +# contains symlink to clang binary from clang-native, but when clang-native +# outhash is changed, clang-cross-${TARGET_ARCH} will still be considered +# equivalent and target recipes aren't rebuilt with new clang binary, see +# work around in https://github.com/kraj/meta-clang/pull/1140 to make target +# recipes to depend directly not only on clang-cross-${TARGET_ARCH} but +# clang-native as well. +# +# This can cause poor interactions with hash equivalence, since this recipes +# output-changing dependency is "hidden" and downstream task only see that this +# recipe has the same outhash and therefore is equivalent. This can result in +# different output in different cases. +# +# To resolve this, unhide the output-changing dependency by adding its unihash +# to this tasks outhash calculation. Unfortunately, don't know specifically +# know which dependencies are output-changing, so we have to add all of them. +# +python cross_add_do_populate_sysroot_deps () { + current_task = "do_" + d.getVar("BB_CURRENTTASK") + if current_task != "do_populate_sysroot": + return + + taskdepdata = d.getVar("BB_TASKDEPDATA", False) + pn = d.getVar("PN") + deps = { + dep[0]:dep[6] for dep in taskdepdata.values() if + dep[1] == current_task and dep[0] != pn + } + + d.setVar("HASHEQUIV_EXTRA_SIGDATA", "\n".join("%s: %s" % (k, deps[k]) for k in sorted(deps.keys()))) +} +SSTATECREATEFUNCS += "cross_add_do_populate_sysroot_deps"