🐛 Build QEMU of another commit in an empty directory

An update to f378a38f8 stopped in QEMU's build on the owner's laptop:
"qemu-version.h: No such file or directory". QEMU of 2026-11-13 writes
that header at configure (configure_file) wherever `git describe --match
'v*'` fails, as it does in every shallow vendor/qemu; the QEMU before made
it with a build step. meson, configuring in place, runs `ninja -t
cleandead` after writing build.ninja, which deletes each file .ninja_log
records as built that build.ninja does not name: the header it had just
written. Every later configure in that directory deletes it again.

install-ctl.sh and `make qemu` now record the vendor/qemu commit a build
directory was configured from (qemu-source) and start the directory empty
when the commit differs; a directory without the record is started empty
once. The same commit keeps its directory, so edits not yet committed in
vendor/qemu rebuild as before.

Reproduced on ms01 (job m3-max-31803): the old QEMU's directory
configured in place for the new loses the header and the compile fails as
on the laptop, twice over; an empty directory keeps it and compiles, and
keeps it when configured again at the same commit.
This commit is contained in:
Anees Iqbal committed 2026-11-15 03:12:15 -08:00
1 parent f378a38f8d
commit 00c9346cc4
3 files changed
+23

No files matched your search

+12
View File
@@ -56,11 +56,22 @@ vendor/qemu/configure:
# 310 s for a clean build where ninja's default took 59 s (docs/qemu.md).
# ninja has meson regenerate build.ninja where a meson file changed, as
# install-ctl.sh's build relies on.
#
# vendor/qemu at another commit than the one build/qemu was configured from
# builds in an empty directory, as install-ctl.sh's does: meson, configuring
# or regenerating in place, deletes each file the last build made that the new
# build.ninja does not name, even one it has just written at configure
# (qemu-version.h of QEMU of 2026-11-13, docs/lessons.md). A clean build takes
# about a minute, and edits not yet committed keep the directory.
QEMU_PKG_CONFIG := $(RUST_DIST)/lib/pkgconfig
QEMU_PC_READ := $(QEMU_BUILD)/reims-vgpu.pc.configured
QEMU_CONFIGURE_INPUTS := configure scripts/meson-buildoptions.sh pythondeps.toml VERSION
qemu: all vendor/qemu/configure
@src=$$(git -C "$(QEMU_SRC)" rev-parse HEAD 2>/dev/null); \
if [ -n "$$src" ] && [ "$$(cat "$(QEMU_BUILD)/qemu-source" 2>/dev/null)" != "$$src" ]; then \
rm -rf "$(QEMU_BUILD)"; \
fi
@mkdir -p "$(QEMU_BUILD)"
@if [ ! -f "$(QEMU_BUILD)/build.ninja" ] || [ -n "$(QEMU_CONFIGURE)" ] \
|| ! grep -qF -- "exec '$(QEMU_SRC)/configure'" "$(QEMU_BUILD)/config.status" 2>/dev/null \
@@ -73,6 +84,7 @@ qemu: all vendor/qemu/configure
--disable-docs $(QEMU_CONFIGURE) \
&& cp "$(QEMU_PKG_CONFIG)/reims-vgpu.pc" "$(QEMU_PC_READ)"; \
fi
@git -C "$(QEMU_SRC)" rev-parse HEAD >"$(QEMU_BUILD)/qemu-source" 2>/dev/null || rm -f "$(QEMU_BUILD)/qemu-source"
ninja -C "$(QEMU_BUILD)" $(filter-out -j,$(filter -j%,$(MAKEFLAGS))) qemu-system-x86_64
clean:
+1
View File
@@ -64,6 +64,7 @@ one. A new trap found the same way goes here.
- A difference a boot already logs is a death on every boot once it is made one. A change that ended the process on two differences the Vulkan platform had logged passed `cargo xtask check`, and every macOS 26 boot then died early, at about 6 s on MoltenVK and 38 s on an NVIDIA driver, each at one of the two: the last good boot's log had counted 873 states with one and 20 with the other. No committed test runs the shaders a guest's boot draws. How to spot the next one: before a change ends the process on something the platform logged, look its code up in the last good boot's notice counts; any count there is a death every boot reaches.
- A hop to another thread that the caller waits for is a wakeup the caller depends on. `apple-gfx` made each MMIO access on a thread of its `ThreadPool` while the vCPU waited in `AIO_WAIT_WHILE`, holding the BQL, for the job to set `completed` and call `aio_wait_kick`. One vmapple boot hung 3 million accesses in, at a doorbell write: the access had completed and no thread was in the library, yet the vCPU slept in `aio_poll`'s `select` for good, and QEMU's main loop, its UI and the other vCPUs waited for the BQL it held. The wakeup was lost somewhere between the pool's job, `aio_wait_kick`'s BH and the event notifier, and no stress test of the pattern reproduced it. The hop bought nothing, since an access waits only on the library's threads, which never wait on QEMU, so QEMU called the library on the vCPU's thread from then on, as the reims-graphics device's MMIO handlers do. Before a host waits for its own job on another thread, ask what the job waits on: when it is nothing of the host's, call it directly. When a sampled thread sleeps in a poll inside a wait loop and no thread runs the job it waits for, suspect a lost wakeup, not a slow job.
- A build that reads a pkg-config package at configure keeps what it read. meson reads `reims-vgpu.pc` when QEMU is configured and keeps its flags, `Libs.private` among them, in its build files; a change to the package does not make it configure again. When the library came to need Carbon (the window's ISO keyboard check), a QEMU build configured before that linked the new `libreims_vgpu.a` with the old framework list and failed on two Carbon symbols. Neither `cargo xtask check` nor the suite links QEMU, and the smoke reads the package at each link. `make qemu` keeps a copy of the package it configured with (`build/qemu/reims-vgpu.pc.configured`) and configures again when the dist tree's differs. When a host that links the archive fails on a system framework's symbols after a library change, compare the dist tree's `Libs.private` with the flags the host's build recorded (for QEMU, the link line in `build/qemu/build.ninja`) before looking at the code.
- A build directory carried across a QEMU move can lose a file meson has just written. meson, configuring or regenerating in place, runs `ninja -t cleandead`, which deletes every file `.ninja_log` records as built that the new `build.ninja` does not name, and a `configure_file` output is in no `build.ninja`. QEMU before 2026-11-13 made `qemu-version.h` with a build step; the QEMU of 2026-11-13 writes it with `configure_file` wherever `git describe --match 'v*'` fails, as it does in every shallow `vendor/qemu` (the installer's fetch, and this checkout's). Configured in place over the old build, meson wrote the header and then deleted it, and the build stopped at `monitor/qmp-cmds-control.c` ("qemu-version.h: No such file or directory") on the owner's update, on every later run too, since the old log entry stays. The 5080 boot that checked the move built in a fresh workspace and never saw it. `install-ctl.sh` and `make qemu` now build QEMU of another commit in an empty directory (`qemu-source` records the commit a directory was configured from). When a QEMU build fails on a missing generated header after a move, compare `.ninja_log` with `build.ninja` for that file before looking at the source; a check of a QEMU move builds once over the previous QEMU's build directory, as users' updates do.
- An activity against App Nap can keep the host awake. `NSActivityUserInitiated` includes `NSActivityIdleSystemSleepDisabled`: the window's activity, begun with it for the process's life, kept the host from idle sleep for as long as QEMU ran. `NSActivityUserInitiatedAllowingIdleSystemSleep` keeps App Nap away and leaves sleep to the host's own settings (`reims-vgpu-window/src/native/macos/app.rs`). No test can see it: when a Mac stops sleeping while the library runs, read `pmset -g assertions` for the process first.
- A VM's timings depend on whether the person at the host sees QEMU's window. Under `-display cocoa`, macOS napped QEMU 30 to 50 s after it lost the focus: every QEMU thread (the vCPUs and the library's FIFO and display threads among them) ran at priority 4, and Metal's compiler service ran QEMU's compiles at 0 to 4. A 26.6.2 guest booted that way reached its desktop at 215 s, and at 53 s when QEMU was kept in front (**measured**); it looked like slow compiles and shader caches. The library's window holds an activity against App Nap for the process's life (`reims-vgpu-window/src/native/macos/app.rs`). Before trusting a boot's timings, read the host log's `Set AppNap state` lines for QEMU's pid (`log show --predicate 'process == "runningboardd" AND eventMessage CONTAINS ":<pid>]"'`): `active:Y` begins a napped stretch, and the next focus (`SETFRONT: pid=<pid>`) ends it. Or sample its threads' priorities with libproc's `PROC_PIDTHREADINFO`: a QEMU whose named threads all sit at 4 is napped.
- A system value that names the device last used is read at each use. HIToolbox's keyboard type (`LMGetKbdType`) follows the keyboard last typed on: the window read it once, when it opened, so a keyboard of the other layout plugged in afterwards (ISO in place of ANSI, or the reverse) swapped the key left of 1 with the key right of left Shift in the guest. `InputState` asks again at each key event (the window crate's `native::is_iso_keyboard`). When input maps right on one keyboard and wrong on another, look for a value read once that names a device.
+10
View File
@@ -412,6 +412,15 @@ if [[ $SKIP_QEMU == 0 ]]; then
# QEMU's install prefix: never used where it is, since QEMU finds its files
# relative to its binary; the build is staged with DESTDIR and moved.
PREFIX=/reims-ctl-qemu
# QEMU of another commit builds in an empty directory. meson, configuring
# or regenerating in place, deletes each file the directory's last build made
# that the new build.ninja does not name (ninja -t cleandead), even one it
# has just written at configure: QEMU of 2026-11-13 writes qemu-version.h
# there where its source has no version tag, as this shallow fetch's has
# none, where the QEMU before made it in the build, and the build then
# stopped on the missing header (docs/lessons.md).
QEMU_SOURCE=$(git -C "$ROOT/vendor/qemu" rev-parse HEAD) || die "could not read vendor/qemu's commit"
[[ "$(cat "$BUILD/qemu-source" 2>/dev/null)" == "$QEMU_SOURCE" ]] || rm -rf "$BUILD"
mkdir -p "$BUILD"
# No docs and no test suite: users run QEMU, not its tests.
CONFIGURE=("$ROOT/vendor/qemu/configure" --prefix="$PREFIX" "${QEMU_CONFIGURE[@]}"
@@ -429,6 +438,7 @@ if [[ $SKIP_QEMU == 0 ]]; then
(cd "$BUILD" && PKG_CONFIG_PATH="$PC" "${CONFIGURE[@]}")
cp "$PC/reims-vgpu.pc" "$BUILD/reims-vgpu.pc.configured"
printf '%s\n' "$CONFIGURED" >"$BUILD/configured-with"
printf '%s\n' "$QEMU_SOURCE" >"$BUILD/qemu-source"
fi
say "Building QEMU"
# A build that stops configures again on the next run: when ninja has meson