From: Adrian Freihofer Date: Fri, 30 Jan 2026 07:52:31 +0000 (+0100) Subject: build-sysroots: Serialize native and target sysroot population X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=acc84167443026012ffc5a79bbd907be72b6a03c;p=thirdparty%2Fopenembedded%2Fopenembedded-core.git build-sysroots: Serialize native and target sysroot population Calling (what devtool ide-sdk --mode shared does internally): bitbake meta-ide-support:do_build cmake-example:do_populate_sysroot bitbake build-sysroots:do_build_target_sysroot \ build-sysroots:do_build_native_sysroot can fail with errors like: Exception: subprocess.CalledProcessError: Command '.../tmp/sysroots/qemux86-64/usr/bin/postinst-base-passwd' returned non-zero exit status 1. Subprocess output: .../tmp/sysroots/x86_64/usr/sbin/useradd Running groupadd commands... NOTE: cmake-example: Performing groupadd with [--root ../tmp/sysroots/qemux86-64 --system cmake-example] awk: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory ERROR: cmake-example: groupadd command did not succeed. The root cause is a race condition between do_build_target_sysroot and do_build_native_sysroot. When run in parallel, do_build_target_sysroot executes postinstall scripts (e.g., useradd) that invoke awk, while do_build_native_sysroot is concurrently installing gawk-native into the shared native sysroot (which is in PATH for do_build_target_sysroot). Since sstate artifact installation is not atomic, awk binaries can be installed before their dependent libraries. If do_build_target_sysroot picks up the newly installed but incomplete awk, it fails with missing library errors. The situation is created by a mix of: - gawk-native in ASSUME_PROVIDED (use host awk) - glibc depending on gawk-replacement-native (builds gawk-native) - Both tasks populating the same shared native sysroot directory Fix this by adding a lockfile to both tasks, ensuring they cannot run concurrently and avoiding the race condition where partially installed native tools are accessed. While lockfiles are generally avoided in BitBake due to performance concerns, this is acceptable here since these tasks are not on a critical performance path. [YOCTO #16135] Signed-off-by: Adrian Freihofer Signed-off-by: Mathieu Dubois-Briand Signed-off-by: Richard Purdie --- diff --git a/meta/recipes-core/meta/build-sysroots.bb b/meta/recipes-core/meta/build-sysroots.bb index b0b8fb3c79..3ee9565862 100644 --- a/meta/recipes-core/meta/build-sysroots.bb +++ b/meta/recipes-core/meta/build-sysroots.bb @@ -36,6 +36,7 @@ python do_build_native_sysroot () { } do_build_native_sysroot[cleandirs] = "${STANDALONE_SYSROOT_NATIVE}" do_build_native_sysroot[nostamp] = "1" +do_build_native_sysroot[lockfiles] = "${WORKDIR}/build-sysroots.lock" addtask do_build_native_sysroot python do_build_target_sysroot () { @@ -47,6 +48,7 @@ python do_build_target_sysroot () { } do_build_target_sysroot[cleandirs] = "${STANDALONE_SYSROOT}" do_build_target_sysroot[nostamp] = "1" +do_build_target_sysroot[lockfiles] = "${WORKDIR}/build-sysroots.lock" addtask do_build_target_sysroot do_clean[cleandirs] += "${STANDALONE_SYSROOT} ${STANDALONE_SYSROOT_NATIVE}"