fix(tools): one xce-build.sh run per build dir at a time (bug-1604)

Two xce-build.sh runs against the same build dir raced: one run's
setup_build rm -rf hit files the other was writing ('Directory not
empty'), or deleted a binary the other had just built and tested.

xce-build.sh now takes an exclusive per-build-dir lock right after cd-ing
into src/ and holds it until it exits; a second run against the same dir
waits, runs against different dirs are unaffected. The lock
(src/tools/build-lock.sh) is an mkdir lock holding the owner PID, outside
the build dir, keyed by a hash of its absolute path; it needs only
coreutils (the nix dev shell has no flock) and takes over a lock whose
owner died. src/tools/test-build-lock.sh tests it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Rongsong Shen 2026-09-30 03:43:48 +00:00
parent e9698c3f54
commit 980a0054d1
Signed by untrusted user: rshen
GPG key ID: 80533536B0EB651C
3 changed files with 183 additions and 0 deletions

View file

@ -168,6 +168,14 @@ esac
cd "$SRC_DIR"
# bug-1604: one xce-build.sh run per build dir at a time. A concurrent run
# against the same dir raced on setup_build's rm -rf ("Directory not empty")
# or deleted a binary the other run had just built; it now waits here until
# this run exits. Runs against different build dirs are not affected.
. "$SCRIPT_DIR/build-lock.sh"
build_lock_acquire "$BUILD_DIR"
trap build_lock_release EXIT
# build-time-versioning task 2.1: compute commit_id/build_time once, common to
# every profile, and append to MESON_OPTS below (before either `meson setup`
# call in setup_build() runs). This feeds src/meson.options' commit_id/