/xce-build now takes a build PROFILE: asan (default, debug+ASAN -> xce.build, backward-compatible), debug (non-ASAN -O0 -g3 -fno-inline -fno-omit-frame-pointer -> build.dbg, for gdb/cores), release (-O3 -> build.release). Each profile uses its own default build dir so variants don't clobber each other; arg2 may still be a legacy build_dir. asan runs the unit suites; debug/release are build-only (the suites are ASAN-oriented and the meson test harness is overlay-fs fragile, bug-924) and print how to run a suite directly. Why: bug-1282/bug-1286 are heisenbugs ASAN perturbs away (no SIGSEGV) and that gdb-on-release turns into a hang/timeout. The non-ASAN -O0 -g3 build reproduces them AND yields a symbolized backtrace under gdb. It immediately paid off: the debug profile ROOT-CAUSED bug-1286 (the round-4 segfault) — myreq_handler (cluster.c:251) does `c = ep->owner` then `ha_dispatch_gate(&c->ha,…)`; on chaotic restart a walCatchupEntry (op 37) vtask runs with ep->owner==NULL, so &c->ha = 0x3ff0 -> deref crash at ha.c:3194. Fix is a NULL-guard in myreq_handler (+ owner-lifecycle). 7.2 now has one remaining blocker (bug-1286, root-caused); bug-1282 deadlock is fixed. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019dbTHR9CsEYK9RsqmQpQpC
137 lines
5.1 KiB
Bash
Executable file
137 lines
5.1 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
COMPONENT="${1:-all}"
|
|
|
|
# Build PROFILE controls the meson buildtype + sanitizer (and the default build
|
|
# dir, so the variants never clobber each other):
|
|
# asan (default) debug + AddressSanitizer → xce.build (unit-test CI)
|
|
# debug debug, NO sanitizer (-O0 -g3 -fno-inline -fno-omit-frame-
|
|
# pointer) → build.dbg (gdb / core dumps)
|
|
# release release -O3, no sanitizer → build.release (soak / perf)
|
|
#
|
|
# Why `debug` exists (bug-1286): some crashes are heisenbugs that ASAN perturbs
|
|
# away (different allocator/layout → no SIGSEGV) and that gdb-on-release turns
|
|
# into a timeout/hang. The non-ASAN -O0 -g3 build reproduces them AND yields a
|
|
# fully symbolized backtrace under gdb — the only way to root-cause that class.
|
|
#
|
|
# Arg parsing is backward-compatible: arg2 may be a profile keyword OR a legacy
|
|
# build_dir; arg3 is an optional explicit build_dir override.
|
|
case "${2:-}" in
|
|
asan|debug|release) PROFILE="$2"; BUILD_DIR="${3:-}" ;;
|
|
"") PROFILE="asan"; BUILD_DIR="" ;;
|
|
*) PROFILE="asan"; BUILD_DIR="$2" ;; # legacy: arg2 = build_dir
|
|
esac
|
|
|
|
if [ -z "${BUILD_DIR:-}" ]; then
|
|
case "$PROFILE" in
|
|
asan) BUILD_DIR="xce.build" ;;
|
|
debug) BUILD_DIR="build.dbg" ;;
|
|
release) BUILD_DIR="build.release" ;;
|
|
esac
|
|
fi
|
|
|
|
# RUN_TESTS: the unit suites are ASAN-oriented (leak detection) and the meson
|
|
# test harness is fragile on this sandbox's overlay fs (bug-924 fdatasync). Only
|
|
# the `asan` profile runs them; `debug`/`release` are BUILD-ONLY — their purpose
|
|
# is a binary to drive under gdb / a soak, not a test run. Run a suite directly
|
|
# against those binaries when you want it (it is overlay-fs sensitive).
|
|
case "$PROFILE" in
|
|
asan) MESON_OPTS=(--buildtype=debug -Db_sanitize=address); RUN_TESTS=1 ;;
|
|
debug) MESON_OPTS=(--buildtype=debug -Db_sanitize=none); RUN_TESTS=0 ;;
|
|
release) MESON_OPTS=(--buildtype=release -Db_sanitize=none); RUN_TESTS=0 ;;
|
|
esac
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
SRC_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
|
|
cd "$SRC_DIR"
|
|
|
|
usage() {
|
|
echo "Usage: $0 [component] [profile|build_dir] [build_dir]"
|
|
echo "Components: all (default), lib, controller, scheduler, worker, apiserver, xcecli"
|
|
echo "Profiles: asan (default), debug (non-ASAN -O0 -g3, for gdb/cores), release"
|
|
exit 1
|
|
}
|
|
|
|
setup_build() {
|
|
echo "=== Clean build: $BUILD_DIR (profile=$PROFILE) ==="
|
|
rm -rf "$BUILD_DIR"
|
|
meson setup "$BUILD_DIR" "${MESON_OPTS[@]}"
|
|
}
|
|
|
|
case "$COMPONENT" in
|
|
lib)
|
|
setup_build
|
|
echo "=== Building lib + tests ==="
|
|
meson compile -C "$BUILD_DIR" xcelib_test
|
|
if [ "$RUN_TESTS" = 1 ]; then
|
|
echo "=== Running lib tests ==="
|
|
meson test -C "$BUILD_DIR" "libxce test" --print-errorlogs
|
|
fi
|
|
;;
|
|
controller)
|
|
setup_build
|
|
echo "=== Building lib + controller + tests ==="
|
|
meson compile -C "$BUILD_DIR" xce_controller controller_unit_test
|
|
if [ "$RUN_TESTS" = 1 ]; then
|
|
echo "=== Running controller tests ==="
|
|
meson test -C "$BUILD_DIR" --suite controller --print-errorlogs
|
|
fi
|
|
;;
|
|
scheduler)
|
|
setup_build
|
|
echo "=== Building lib + scheduler + tests ==="
|
|
meson compile -C "$BUILD_DIR" xce_scheduler sched_test
|
|
if [ "$RUN_TESTS" = 1 ]; then
|
|
echo "=== Running scheduler tests ==="
|
|
"./$BUILD_DIR/scheduler/testsuite/sched_test"
|
|
fi
|
|
;;
|
|
worker)
|
|
setup_build
|
|
echo "=== Building lib + worker ==="
|
|
meson compile -C "$BUILD_DIR" xcecd xcecd_worker xrun
|
|
echo "=== Worker built (no unit tests registered) ==="
|
|
;;
|
|
apiserver)
|
|
setup_build
|
|
echo "=== Building lib + apiserver + xcecli ==="
|
|
meson compile -C "$BUILD_DIR" apiserver xcecli
|
|
if [ "$RUN_TESTS" = 1 ]; then
|
|
echo "=== Running frontend Go unit tests ==="
|
|
cd frontend && make test
|
|
fi
|
|
;;
|
|
xcecli)
|
|
setup_build
|
|
echo "=== Building xcecli ==="
|
|
meson compile -C "$BUILD_DIR" xcecli
|
|
if [ "$RUN_TESTS" = 1 ]; then
|
|
echo "=== Running xcecli Go unit tests ==="
|
|
cd frontend/xcecli && CGO_ENABLED=0 go test ./... -count=1
|
|
fi
|
|
;;
|
|
all)
|
|
setup_build
|
|
echo "=== Building all components ==="
|
|
meson compile -C "$BUILD_DIR"
|
|
if [ "$RUN_TESTS" = 1 ]; then
|
|
echo "=== Running all C tests ==="
|
|
meson test -C "$BUILD_DIR" --print-errorlogs
|
|
echo "=== Running scheduler test (manual) ==="
|
|
"./$BUILD_DIR/scheduler/testsuite/sched_test"
|
|
echo "=== Running frontend Go unit tests ==="
|
|
cd frontend && make test
|
|
fi
|
|
;;
|
|
*)
|
|
usage
|
|
;;
|
|
esac
|
|
|
|
if [ "$RUN_TESTS" != 1 ]; then
|
|
echo "=== Skipped tests (profile=$PROFILE — build only). Binary in $BUILD_DIR; run a suite directly, e.g. ASAN_OPTIONS=detect_leaks=0 ./$BUILD_DIR/controller/controller_unit_test ==="
|
|
fi
|
|
|
|
echo "=== Done: $COMPONENT (profile=$PROFILE, dir=$BUILD_DIR) ==="
|