Builds and runs both halves of the project -- Canary as the oracle, Reborn as
the port -- plus the dynamic-RE toolkit. Claude Code runs with
--dangerously-skip-permissions as an unprivileged `agent` user, because that
flag is refused under root.
Capped at half the machine, computed at launch: --cpus nproc/2, --memory half
of MemTotal with --memory-swap equal to it (no swap escape hatch -- a swapping
build thrashes the host, which is the failure the cap exists to prevent), and
build parallelism derived INSIDE the container from available memory rather
than core count, since a full-parallel build of this tree has OOM-killed the
host outright.
Three things the old box got wrong are fixed rather than reproduced: a real
toolchain (so rebuild_canary.sh's hand-relinking is obsolete), numpy and Pillow
(whose absence silently disabled every image oracle and looked like a logic
bug), and a display owned by PID 1 (so Xvfb no longer "dies on its own every
few minutes" -- it was being reaped because nothing owned it).
Verified end to end, not by inspection: the image builds, sylph-doctor is green,
`build-canary` links xenia_canary inside the container, and that binary then
runs -- guest memory and the JIT code cache appear in /dev/shm within 4 s,
1 205 log lines, gmem.py reads guest RAM, pad.py drives the file pad, and
screenshot captures the display.
Five environment defects found and fixed on the way, each of which fails in a
way that points somewhere else entirely:
* /dev/shm is `noexec` under Docker. Xenia maps its JIT code cache out of an
shm file, so it died with "Unable to allocate code cache generated code
storage / Cannot initalize processor" -- which reads as an address-space
clash, not a mount flag. Now `--tmpfs /dev/shm:rw,exec`.
* An unknown xenia flag HANGS rather than errors: ParseLaunchArguments calls
ShowSimpleMessageBox before logging is initialised, and that SDL dialog
blocks on XIfEvent forever. `--audio` (which the RE notes recommend) is not
a cvar in this tree; the symptom was a 10x10 window and an empty log.
* Named volumes come up root-owned unless their mount point exists in the
image, so the first cmake configure failed on pkgRedirects.
* Ubuntu 24.04 ships its own uid-1000 account, colliding with the host user.
* Ubuntu's spirv-opt has no --canonicalize-ids, so the shader step dies ~500
objects in; the launcher mounts the host's LunarG SDK instead of baking one
in, which also keeps shader output byte-identical to a host build.
Known limits, stated rather than papered over: on an NVIDIA host without the
NVIDIA Container Toolkit there is no hardware Vulkan (/dev/dri alone does
nothing for NVIDIA), and under lavapipe the emulator runs correctly but was not
observed to reach a rendered frame within a couple of minutes. gdb needs `sudo`
inside the container because the host's yama ptrace_scope outranks SYS_PTRACE.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
100 lines
4.4 KiB
Bash
Executable File
100 lines
4.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Launch Xenia Canary with the settings this title actually needs.
|
|
#
|
|
# Four of these are not preferences — they are measured requirements, and every
|
|
# one of them cost a debugging session before it was pinned down:
|
|
#
|
|
# --apu=sdl + SDL_AUDIODRIVER=dummy
|
|
# There is no PulseAudio here, so `--apu=nop` looks like the safe muted
|
|
# choice. It is not: the log then fills with "CreateDriver failed for
|
|
# index=0", the guest never gets past the intro movie, and the window
|
|
# stays black for 8+ minutes. The SDL driver against a dummy device is
|
|
# both silent AND lets the title advance.
|
|
#
|
|
# NO --audio flag
|
|
# The RE notes say "--audio --apu=sdl". `--audio` is NOT a cvar in this
|
|
# tree, and an unknown argument is not a friendly error: xenia calls
|
|
# ShowSimpleMessageBox from ParseLaunchArguments, BEFORE logging is
|
|
# initialised, and that SDL dialog blocks on XIfEvent forever. Headless,
|
|
# the symptom is a 10x10 window, an empty log, and no guest memory —
|
|
# which reads like a hang deep in the emulator rather than a typo.
|
|
# If this ever appears to hang at startup, suspect a bad flag first.
|
|
#
|
|
# --hid=file --pad_file=...
|
|
# The old vgamepad path made its device through /dev/uinput, which is NOT
|
|
# namespaced — a pad created inside a container registers with the HOST's
|
|
# input stack and every scripted press leaks to the user's desktop. This
|
|
# driver reads a text file instead. Drive it with tools/re-capture/pad.py.
|
|
# Trap worth remembering: 360 menus poll XamInputGetKeystrokeEx, not
|
|
# GetState, so a stubbed GetKeystroke looks like a completely dead pad.
|
|
#
|
|
# one instance at a time
|
|
# Two emulators (or ours + canary) at once perturbs both and the box.
|
|
# Enforced with a lockfile rather than left to discipline.
|
|
#
|
|
# Usage: run-canary [extra xenia flags...]
|
|
# ISO from $SYLPH_ISO, else the first *.iso under $PROJECT_DIR.
|
|
# Binary from $XENIA_BIN, else the container build, else the repo build.
|
|
set -u
|
|
|
|
LOCK=/tmp/xenia-canary.lock
|
|
exec 9>"$LOCK"
|
|
if ! flock -n 9; then
|
|
echo "run-canary: an emulator is already running (lock $LOCK)." >&2
|
|
echo " Only one at a time — kill it first: pkill -x xenia_canary" >&2
|
|
exit 1
|
|
fi
|
|
|
|
PROJECT_DIR="${PROJECT_DIR:-/work}"
|
|
|
|
# ── Binary ───────────────────────────────────────────────────────────────────
|
|
pick_bin() {
|
|
[ -n "${XENIA_BIN:-}" ] && { echo "$XENIA_BIN"; return; }
|
|
for c in \
|
|
"${XENIA_BUILD_DIR:-/sylph-home/re/canary-build}/bin/Linux/Release/xenia_canary" \
|
|
"${XENIA_BUILD_DIR:-/sylph-home/re/canary-build}/bin/Linux/Debug/xenia_canary" \
|
|
"$PROJECT_DIR/xenia-canary/build/bin/Linux/Release/xenia_canary" \
|
|
"$PROJECT_DIR/xenia-canary/build/bin/Linux/Debug/xenia_canary"; do
|
|
[ -x "$c" ] && { echo "$c"; return; }
|
|
done
|
|
}
|
|
BIN="$(pick_bin)"
|
|
if [ -z "${BIN:-}" ]; then
|
|
echo "run-canary: no xenia_canary binary found. Build one with: build-canary" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# ── ISO ──────────────────────────────────────────────────────────────────────
|
|
ISO="${SYLPH_ISO:-}"
|
|
if [ -z "$ISO" ]; then
|
|
# Prefer a REAL file over a symlink and take the largest: the tree carries
|
|
# `xenia-rs/sylpheed.iso` as a symlink to the retail image, and a symlink has
|
|
# already cost a session once (Wine could not resolve it -> "path invalid").
|
|
ISO="$(find "$PROJECT_DIR" -maxdepth 2 -type f -iname '*.iso' -printf '%s\t%p\n' 2>/dev/null \
|
|
| sort -rn | head -1 | cut -f2-)"
|
|
fi
|
|
if [ -z "$ISO" ] || [ ! -f "$ISO" ]; then
|
|
echo "run-canary: no ISO. Set SYLPH_ISO=/path/to/game.iso" >&2
|
|
exit 1
|
|
fi
|
|
ISO="$(readlink -f "$ISO")"
|
|
|
|
export SDL_AUDIODRIVER="${SDL_AUDIODRIVER:-dummy}"
|
|
export DISPLAY="${DISPLAY:-:98}"
|
|
PAD="${XENIA_PAD_FILE:-/tmp/xenia_pad.txt}"
|
|
: > "$PAD"
|
|
|
|
# Guest memory is backed by /dev/shm; a stale file from a killed run confuses
|
|
# the memory readers (gmem.py finds two candidates and picks the dead one).
|
|
rm -f /dev/shm/xenia_memory_* /dev/shm/xenia_code_cache_* 2>/dev/null || true
|
|
|
|
echo "run-canary: $BIN" >&2
|
|
echo " iso: $ISO" >&2
|
|
echo " pad: $PAD display: $DISPLAY shm: $(df -h /dev/shm | awk 'NR==2{print $2}')" >&2
|
|
|
|
exec "$BIN" "$ISO" \
|
|
--apu=sdl \
|
|
--hid=file --pad_file="$PAD" \
|
|
--mute=true \
|
|
"$@"
|