WIP: feat(builder)!: the builder in Rust (longshot-builder) replaces the old one: lift, compile, game files, assets; the game reads its RomFS from the .nup; supersedes #2272 #2286
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2286
Loading…
Reference in a new issue
No description provided.
Delete branch "HumanBean/Longshot:lifter-m0-decoder"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
The whole builder in Rust, replacing the old one:
longshot-builder, one command that turns the player's own.nupinto a game folder (read the game files, lift, compile, assets, shaders). The old builder (
nx2/make_game.py,nx2/build.py, the Python lift,third_party/a64-kit) is deleted, and so are the standalone builders (the AppImage,the Windows LongshotBuilder app and its setup): a release ships one self-contained
longshot-builderper platform(the builder, the sources it compiles, the assets, the prebuilt objects and the build tools packed inside), with small
deltas between releases and a manifest listed in the signed
SHA256SUMS.dev.py, the release and CI run it. Noplayer's build needs Python. It started as the lifter rewrite (a native lifter with a typed SSA mid IR, writing LLVM
IR for the pinned clang); it is now every stage.
The names. The workspace is
builder/(it wasrust/), and the command islongshot-builder(it waslongshot-build; the developers'longshot-liftis folded in aslongshot-builder dev discover|sites|lift|profile|words|decode). Its release files arelongshot-builder-<v>-<platform>, its per-user cache~/.cache/longshot-builderor%LOCALAPPDATA%\Longshot\Builder, its data folder (the licences a player accepted)~/.local/share/longshot-builderor%LOCALAPPDATA%\Longshot\Builder-data, its game folder recordlongshot_builder.json. TheLONGSHOT_*variables keep their names.It supersedes #2272, which is closed: #2272's last
version (the player features on hook sites, Skip title screen on the game's own load) is folded in whole, its Python
machinery ported to the Rust
sitesandeditscrates: anchors'of,HOS_SITE_OUTCOME, the site chain kept perguest context, Skip title screen stopping its presses once the game loads. This pull request merges alone.
Players build with it once this merges: LongshotLauncher
#259 installs
longshot-builderfrom a release(by a delta from the one it has, or the full file) and runs
checkandbuild --json; it passes its settings as thispull request's flags (
--cache,--builder-exe), so the two ship together. RecompLauncher installs the release'slongshot-builder-<v>-<platform>-recomplauncher.zipand startsLongshot.exe/Longshot.x86_64. The Test Farmbuilds with it after Beanstalk #143, which waits on this
one:
mainhas nobuilder/until it merges.A clean break in what the builder looks like from outside: no
make_game.pyoptions, no@@lines. With--jsonit writes versioned JSON Lines events (stage, progress, the compile's plan and units, the time left, warnings, errors
with stable codes, done), documented in
docs/dev/reference/build-events.md, with a test that keeps that list ofcodes and the code in step; caches are keyed by content anew.
What is here (
builder/, a README per crate; one Cargo workspace at the repository's root):a64,cfg,image,mir,sem,llvm,lift,passes,profile): the decoder (checkedagainst llvm-mc), discovery (the same 294,518 functions as the old lifter), the mid IR with every integer, memory,
atomic, system, float and SIMD form the game uses, the LLVM IR writer, the passes (shared page marks, dead state,
giant functions split), the guest profile (branch weights, hot and never-run functions, keyed by guest code,
committed in
assets/profiles/guest.profile.xz), and a runtime of its own (builder/rt). An instruction thesemantics do not cover is a trap where it is, never a failed build.
sites,edits): no C text, nothing left tothe old lifter. Each function's edits have a stable key, so one site's change lifts one unit again. The site tests
run each hook as the lift lowers it (
longshot-builder dev site-hooks), andtests/sitetable.py, the old C emitter'scopy, is retired.
lift::whole): discovery, sites, the units cut by compile cost, the function table, the imageconstants and import stubs, a per-unit cache; byte for byte the same on a second lift. The units' texts are not kept:
the compile makes each when it needs it and gives it to clang on stdin (gen/ is 26 MB, not 5.7 GB).
build-compile): object keys by content only (the compiler's identity, the flags, the source, theheaders its depfile names), an object store outside the game folder, a scheduler under the memory gate, the links
skipped when nothing they read changed, the prebuilt third-party objects. Never-run functions at
-O0, hot ones at-O2; the game's link orders its functions with lld's hfsort.game-files,image): the.nupread, checked and indexed, the modules unpacked(LZ4, ZBIC), the mods' ExeFS patches, the image.
.nup(host/romfs.{c,h},host/romfs_index.c): the game folderholds a 16 MB index, not a 26 GB copy; zstd-stored files are decoded when opened and the closed copies kept (256 MB
at most). One RomFS API in the host, with a romfs folder as its second back end, and every host and renderer reader
moved to it.
longshot-builder index --game <new.nup> --out <folder>points a built folder at its.nupmoved.build-assets): the button prompts (font, textures with an ASTC encoder of our own), the texts, theshader list, the pipeline lists, the icon; made beside the lift and the compile, each cached by its inputs.
build-driver,longshot-builder):build,update,check,index,share,stamps,perf-report,prepare,sources, and one command per stage; a launcher's settings as flags (--cache,--ngx-sdk,--builder-exe; the variables still read for one release); the upscalers' runtimes (DLSS, FSR 4, XeSS)fetched by the builder with their licences accepted on the command line; the finish swaps every file in at once, or
none.
as it goes at the shader step; the built game's
--prepare-shadersruns again only when the renderer, the shaderlist, the shipped pipeline states, the level or the drivers changed (
cache/longshot_prepared_key.txt; the driversread with no Vulkan call). A game folder's program cache begins from the one the last preparation left.
Measurements).
src/play.rs,recomplauncher.json): the zip holdslongshot-builderonce, asLongshot.exe(a windowed program: no console) orLongshot.x86_64. Started by that name with no command (or aslongshot-builder play), it updatesLongshot/beside it quietly and starts the game with every argument; a failedupdate starts the game the folder had. RecompLauncher's setup step builds with
--progress-lines, its own lineprotocol.
longshot-builder dev release,build-linux.yml,build-windows.yml,release.yml): one file perplatform, its pack unpacked into the builder's cache on first use;
zstd --patch-fromdeltas from thechannel's last 5 releases, a manifest, and the RecompLauncher zip, made in the build
jobs.
scripts/longshot_builder.pykeeps only what runs before there is a builder (building it, llvm-mingw, thebuilt program's check).
longshot-builder dev toolsistools.lock's one implementation (check, install, make,publish);
scripts/tools.pyis gone, andmise run toolsinstalls this system's into the checkout.dev.py packsasks the builder for itskeys); dev builds keep their cache, data and work folders in the development folder and go through the job queue,
except the Test Farm's;
dev.py bases --prunelists and removes old dev data. CI checks the workspace and builds thesynthetic game end to end (
builder/crates/synthetic-game: a small AArch64 program of its own through every stage,run, then one instruction changed and only its unit compiled again).
builder's crates and
longshot-rs, the game's one Rust staticlib (empty for now), share oneCargo.tomland oneCargo.lockat the root; Cargo's target folder is the root'starget/.docs/dev/reference/builder.md(with diagrams of the stages, the lift and the cache keys),build.md(every variable the builder reads, by kind),
build-events.md,releases.md,architecture.md,hooks.md,using-mods.md, and every page that named the old builder.Tried and taken out:
callee's summary reads or writes): slower or the same in every scene (Kokiri Forest -8.4 %, Hyrule Field about -4 %,
the Market the same, the 1 % lows worse) and 20 % more compile time, measured during development on an earlier
head. All of it is gone; builder.md's "Still to come"
keeps the numbers.
image.binmapped copy-on-write (HOS_IMAGE_MAP): file-backed pages in the guest window kept a GPU pool over theimage from being imported as a dma-buf or a userptr on AMD, for a start-up saving too small to keep it. The image is read
into the window again, and
HOS_IMAGE_MAPis a GONE row.the code and its notes are not in this pull request.
The first two review rounds' fixes, in brief: an untrusted
.nup's and the assets' sizes, tables and offsetsbounded before use (BNTX, MSBT, fonts, PNG and JPEG, zstd frames), overflow checks on in release builds; no write
through a link, and the player's dump never deleted; the finish's swap all or nothing, and a stopped swap made whole;
one build at a time per game folder too; a panic is an
internal_errorevent; Windows renames retried on sharingerrors; discovery's jump table bounds, setjmp slots per guest context; the lifter's key holds its compiler, its crates
and discovery's sources; the release's signing key removed however its step ends, and no CI cache holds anything
compiled.
The third review round (82 commits,
lpxlqvzx..xnrvuytn):devirtualised
BLRcompares the register with its usual address and calls the function it leads to; a vcall anchortakes the call's nearest write of its register; a relocation outside its own module is refused; a branch's weights
fit LLVM's 32 bits;
recomp_sj_push's context iscaptures(address); a setjmp owner with more than four setjmp callsstops the lift, naming it, instead of losing the rest; instrumentation is in each unit's key; the lifter's key reads
the root
Cargo.lock. The lifts' store keepsLONGSHOT_LIFT_STORE_KEEPlifts (3) under a lock. The semantics checkalso runs fixed edge states and random sequences of words against Unicorn.
list and the title staged); a romfs folder is removed only when it is the builder's own; licence notes move to a data
folder (
LONGSHOT_DATA), keyed by the record's id, the old cache notes read and moved; an update whose upscaler'slicence is not accepted here builds without it and warns (
upscaler_dropped); the cache prunes old pins, notes,layouts and the old builders' leftovers; a full drive is
disk_fullfrom any file's error; files installed from aread-only source come out writable.
PR_SET_PDEATHSIGon Linux, a job object andCREATE_NO_WINDOWon Windows); clang runs without the variables no key holds; a unit's compile has an hour; a failedcompile keeps the compiler's first error; the early shader preparation shares the build's memory gate, stops with a
failed build and moves its caches across drives; a failed link drops only the objects at fault.
prepared; the preparation's key holds no cache place; three translators' program cache copies are kept in the shader
store, read and written under its lock; the program cache is locked across users on Windows with
LockFileEx.%APPDATA%\Longshot, the old<game>\usermoved there once (as on Linux), andrecomplauncher.jsonlists that folder so RecompLauncher's backups follow; the game's path and its folder's bufferspast 260 bytes (
longPathAware); a headless game ends on SIGTERM again (SDL's signal handlers off before anysubsystem starts); a refused setjmp push gets its thread's own buffer; RomFS reads: a file head that fails says -1,
a
.zsframe with no dictionary id falls back to its reader's, a prompts lookup near 2^64 does not wrap, a romfsfolder is listed once a start; the builder refuses at build time the romfs index the game refuses.
--useris recorded absolute, a non-Unicode HOMEstill finds the cache; the tools store's answer is there, missing or unreached.
dist/before theirchecks;
publishandtools-publishcompile no Rust (tools-publishuploads withscripts/ci_tools_publish.py,Python's standard library) and get their secrets in their steps only; the tools' licence downloads pinned by SHA-256;
dev release fetch-basesgoes throughRELEASE_UPLOAD_APIfirst; the rust jobs install clang, lld and llvm-mc, andthe tests that need them fail without them; a Cargo-only change runs the Rust jobs on CircleCI.
the job queue (but the Test Farm's, which runs directly), and
dev.py bases --pruneremoves old dev data.the docs' nits.
Read first:
builder/README.md, thenbuilder/crates/build-driver/src/build.rs,builder/crates/lift/src/whole/,builder/crates/mir/src/lib.rs,host/romfs.h,builder/crates/longshot-builder/src/play.rs.Testing
Tested: CachyOS Linux 7.3, this PC (Ryzen 9 7900X, 24 threads, RTX 3090), the release build; and the lab (RX 580,
a hard drive).
On the head after the third review round (
xnrvuytn97e3f4ee, one batched queue run, this PC; the head is nowmvtuxnow02386f32onmain8aa5ab87, with the second review's fixes, and Measurements are at it):cargo fmt --check, clippy with warnings as errors on Linux and for Windows (x86_64-pc-windows-gnu), theworkspace's tests, and the synthetic game end to end: all pass.
tests/run_all.py --strict: 719 passed, 109 failed, 8 skipped.not found: vulkan_headers/spirv_headers).main's known failures:test_crt_options,test_guest_holes,test_menu_save_atomic,test_menu_text_field,test_pipeline_share,test_rdna2_mesh_only,test_readback_timeout_source,test_target_image_reuse,test_vibration_menu.main's and are believed to fail onmain:test_amd_subgroup_profiles,test_shader_profile_caps,test_flat_map,test_wb_spans,test_vram_compact,test_rumble_menu.test_mise_build,test_dev_packs,test_log_redact), were fixed, and pass on the head..nup, a new cache, data folder, store and shader store; no upscaler): 318 s wallclock, 145 s of it the builder's stages and 171 s the wait for the shaders prepared beside the compile (shared mode;
the timed numbers are in Measurements). The lift took 4.6 s for 294,518 functions; 903 units compiled. The early
shader progress streamed through the wait.
dev sites, no diff).At
02386f32(2026-11-24, Measurements): this PC's folders, from a cold build with and without the shaders, playedall five scenes in 15 timed runs and started to the title 3 times; the lab's folder from a cold build played the five
scenes once each, and its
3ca9b9d8folder 15 more times: every run on the 1080p rule, no pipeline waits, no errorin the game's logs.
Earlier, on heads before this round:
the RomFS read from the
.nupthrough the index (those numbers are replaced by Measurements).27b6fbcd: a first build (741.5 s: 486 s the builder's stages, 248 s thewait for the shaders), an update (12.5 s) and a smoke run to play.
image.binandimage.jsonbyte for byte the oldbuilder's; every RomFS file read through the index the same as the old builder's extraction; the lift's
294,518 functions, two lifts byte for byte the same, one site changed lifting one unit; the assets against the old
builder's (the shader list, the pipeline list, the prompts' layouts byte for byte; the textures within the
rasteriser's hinting).
Still to test:
(
@Beanstalkonce Beanstalk #143 is in; until thismerges the farm cannot build main's side, so by hand until then).
Longshot.exeopens no console window, the setup's progressstreams, a failed update still starts the game), the saves moved once from
<game>\userto%APPDATA%\Longshot,a game folder past 260 characters, and two users on one shader store (
LockFileEx).main, expecting them to fail there too (by hand).This is the gate before it leaves WIP.
Measurements
Verdict: on this PC a first build from nothing takes 124 s instead of 554 s without the shaders and 332 s instead of
669 s with them, with 6.1 GB of peak RAM instead of 15.6 GB and a 1.65 GB game folder instead of 28 GB; a second game
folder on the same caches takes 26 s instead of 70 s (59 s instead of 117 s with the shaders), a mod's ExeFS code patch
15 s instead of 123 s. In play fps is higher in all five scenes, clearly in three of them (Kakariko +5.5 %, Kokiri Forest
+7.6 %, Fire Temple +16 %; Hyrule Field +1.4 % and the Market +4.2 % within the runs' spread), the game's own CPU time per
frame 14 to 44 % lower and every 1 % low higher. On the AMD lab the build is 3.5 times faster (844 s instead of 2,987 s);
its play is GPU-bound and the same within the spread. The first start after a build is the same, and memory in play within 5 %.
Setup: this PC: CachyOS (Linux 7.3.3), Ryzen 9 7900X (24 threads), 31 GB of RAM (12 to 13 GB of swap in use the
whole time), RTX 3090 on NVIDIA 620.70.06, an NVMe drive (btrfs on LUKS). The lab: the same OS and kernel,
i7-9700K (8 threads, its clock swinging 0.8 to 4.7 GHz), 15 GB, RX 580 on RADV (Mesa 26.2.6), a drive the system reports as rotational (the builders warn of a hard drive).
main@8aa5ab87(built from90fae88c, the same tree but.tooling-rev) with its ownnx2/make_game.py, against thispull request @
02386f32(the head after the second review's fixes), 2026-11-24, unless a table says otherwise.else running). Cold: every cache new for the run (main: work, lift store, object store, XDG cache, shader store;
#2286: work, store, builder cache, data folder, shader store; both: new NVIDIA and Mesa cache folders, so the
drivers' caches were cold); the OS page cache was not dropped (no root), so the
.nup(25 GB) may have been partlyin RAM. Hot: the same build again into a new game folder and work folder with every cache of a cold run kept
(what a second game folder or a reinstall costs). DLSS in both sides' builds here (
--upscaler dlss; main throughLONGSHOT_NGX_SDK), none on the lab. Wall clock, CPU time (user + system of the whole process tree), peak RAM (thePC's used memory above where it stood at the start), bytes written to disk, from a wrapper sampling every 0.5 s; the
stages from main's "where the time went" and #2286's
build_times.jsonand events. Median (min-max).generation Off, preset Custom, a fresh options file each run; every run's option read-back and log checked: 30 of 30
here and every lab run on the rule). Headless, the repository's Kokiri save, the scene's teleport, warmed until 5 s
pass with no pipeline made or waited for (at least 20 s), then 50 s measured from the frame trace. 3 interleaved pairs
per scene (main, #2286), the timing queue (the game on CPUs 0-5,12-17; the queue's noise check: no build outside it,
CPU pressure at most 6 %), each side's folder its cold build with the shaders, with its own driver cache. 1 % low =
1000 / the 99th percentile frame time, 0.1 % low the same at the 99.9th. Game CPU = the game process's CPU time over
the stretch, in cores; GPU busy and memory from
nvidia-smieach second (the lab: amdgpu'sgpu_busy_percent, VRAMfrom the process's DRM fdinfo); CPU clock the mean of every core's, each second. Each cell main → #2286.
The headline numbers (medians; the tables below give each run count and spread):
8aa5ab8702386f323ca9b9d8)This PC (RTX 3090): main @
8aa5ab87against #2286 @02386f32, 2026-11-24First builds and hot builds (main's cold runs without the shaders: two in a job at 01:37 and one at 03:00, the
same code; everything else in one job per row group, main and #2286 interleaved where both ran):
LONGSHOT_PREPARE_EARLY=0#2286's lift is 4.5 s for all 294,518 functions (discovery 2.1 s of it: 17.6 million instructions, 1,474 jump tables),
about 65,000 functions a second; 386 lift units, 903 compile units, 132 hook sites placed, 99 functions edited. The
compilers' CPU time summed: #2286 2,001 to 2,065 s for the host and game and 328 to 376 s for the renderer; main 3,118 to
5,402 s and 255 to 419 s. The executable is 817 MB (.text 760 MB) against main's 612 MB (.text 548 MB); the renderer
18.5 MB on both. Caches after a cold build with the shaders: #2286 6.3 GB (store 1.1 GB, shader store 3.9 GB, NVIDIA's
1.3 GB), main 7.7 GB (lift store 1.8 GB, object store 0.9 GB, shader store 3.7 GB, NVIDIA's 1.3 GB). A hot build with
the shaders: #2286 translates no shader program again (its program cache comes from the shader store) and builds the
38,396 noted pipelines in 15 s; main translates all 46,667 again (42 s). main's cold runs spread widely (428 to 687 s):
its compile used up to 15.9 GB more RAM on a PC with 16 GB available.
What a change rebuilds (an update after each change, the run-2 folder of the cold builds without the shaders, 3
runs where the row says so; wall clock, median (min-max)):
host/hos_main.c(3)The first start after a build (headless 1080p, to the title screen's first frame; the timing queue's 12 CPUs):
fps (3 interleaved pairs per scene; each cell main → #2286, median (min-max)):
Memory in play (at the end of each measured stretch: the game's RSS, its video memory from
nvidia-smi), with thestretch's long frames and pipeline waits:
Hyrule Field's and the Market's first pair ran slower on both sides (the first game runs of the job); the medians and
the other two pairs agree. The game ms falls 14 to 44 %; fps follows it where the frame waits on the game's threads
(Fire Temple, Kokiri Forest, Kakariko); in Hyrule Field and the Market the GPU and the renderer's side hold the frame and
fps moves within the spread.
The AMD lab (RX 580, RADV): main @
90fae88c(=8aa5ab87but.tooling-rev) against #2286, 2026-11-24Builds at
02386f32, the lab alone (main's "read the game files" is its RomFS copy onto the drive):An update with nothing changed (3 runs, with the shaders kept by their key): main 114 s (112-141), #2286 16 s (14-26).
fps at
3ca9b9d8(the head before the second review's fixes; its play-side changes since are small: the setjmp slot,the program cache's lock and copy), 3 interleaved pairs per scene (Hyrule Field's and the Market's first #2286 run lost
to a teleport limit since fixed, run again as a fourth pair), main's folder the one ~/lb-2286 built at
90fae88c(with theshaders), #2286's a build at
3ca9b9d8with the shaders:One confirming pair per scene at
02386f32(its cold build's folder; single runs, the CPU's clock main → #2286 in thelast column):
The lab is GPU-bound in Hyrule Field, the Market and Kakariko (77 to 93 % busy): at
3ca9b9d8fps there is +2 %, -1 % and+3 %, within the spread, and the 1 % lows higher in all three. The confirming pairs at
02386f32land in the samespread (fps within 1 % in Hyrule Field and Kakariko; the Market's #2286 run had the CPU at 2.6 GHz against main's 3.5 GHz,
and its 1 % low and Kakariko's are lower in this one pair). In the Fire Temple and Kokiri Forest the CPU's clock fell to
0.9 to 2 GHz on either side (the GPU 30 to 78 % busy), so those two scenes measure the lab's clock more than the build;
#2286 had far fewer frames of 50 ms or more there. The lab's game ms reads much lower for #2286 than for main (the frame trace's
game_ms), alarger gap than this PC shows; it is reported as logged.
Numbers measured on earlier heads (07b2046a/f14c2d29 and
0fc27a42on this PC,27b6fbcdand1b0e298bon the lab) arereplaced by the tables above.
Risks
For players:
every game: RomFS reads go through
host/romfs.c, the prompts throughprompts/*.base, the renderer's host API isversion 47. A revert is the way back.
build, the shaders included.
.nupmust stay where it is: a game built bylongshot-builderreads its RomFS from it. Moved or deleted, thegame says so (
nup_moved);longshot-builder index --game <new.nup> --out <folder>points the folder at a movedone (the same
.nuponly), and the launcher builds again.LONGSHOT_DATA, else~/.local/share/longshot-builderor%LOCALAPPDATA%\Longshot\Builder-data), out of the cache a launcher or a player empties. The old notes in the cacheare read and moved at the next build. An update whose upscaler's licence is not found builds without it and warns.
<game>\userto%APPDATA%\Longshot(the Longshot Launcher's place), by the samerules as Linux: an entry already there, or one that cannot move, keeps the old place whole.
longshot_options.inistays in the game folder. RecompLauncher's save list (recomplauncher.json) names the newfolder.
longshot_mods.txt: The game no longer readslongshot_mods.txt, where much older builds kept the mods' orderand switches. A game folder that still has one and never made a
mods.jsonfrom it (nolongshot_mods.txt.importedbeside it) starts with every mod on, in path order; set the order and switches again once on the Mods tab.
rest; the game has none.
-Werror) and passes clippy for Windows,but has not run there: the job objects and
CREATE_NO_WINDOWfor the build's children, the saves move, the widepaths past 260 characters (
longPathAware),LockFileExon the program cache, and the windowedLongshot.exe(its hidden console and message boxes).
game-files/src/zstd.rsdecodes it in Rust, written from the format's description (no code copied; itstable generated and checked against Atmosphere-NX's).
HOS_*switches the description check names (HOS_DISCORD, HOS_FPS_MAX, ...) came with #2272'shook sites and keep their defaults.
HOS_IMAGE_MAPis gone (a GONE row). The new builder's own environment variables(
LONGSHOT_CACHE,LONGSHOT_DATA,LONGSHOT_STORE,LONGSHOT_JOBS,LONGSHOT_MEM_*,LONGSHOT_LIFT_STORE_KEEP)are the command's;
HOS_GUEST_PROFILE(unset: nothing) records a profile.For whoever merges:
passes this pull request's flags, and the Test Farm builds it after Beanstalk
#143.
build jobs and only checked by
publish;publishandtools-publishcompile no Rust on the deploy runner(
tools-publishuploads withscripts/ci_tools_publish.py, Python's standard library), their secrets given to theirsteps only. The first nightly after the merge is their first real run. CircleCI's release stage makes no
RecompLauncher zips yet (a TODO there).
compile_linkandllvm_mcfail without them.target/, andCargo.toml,Cargo.lockandlongshot-rs/are build inputs; a checkout that built inbuilder/targetbuilds again.What still waits:
#143).
the build needs (builder.md, "Still to come").
Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named). On this head: 719 passed; 91 could notrun here (no Vulkan or SPIR-V headers on this PC), 9 are
main's and named, and 6 renderer fixture tests are believedto fail on
mainbut not yet run there (Testing).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.(
third_party/only losesa64-kit, the old lifter's, with it, and somePROVENANCE.mdnotes name the new builder;no upstream code changed.)
When it applies
gpu/vk/switches.def.tests/that reads changed source is updated, not weakened.MKWVK_API_VERSIONbumped (MkwVkHostorMkwVkRendereringpu/vk/vk_api.hchanged).Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
Possibly related, for context:
7b3d609aaffb5cc44d3aWIP: feat(lifter): the new lifter's Rust workspace and its A64 decoder, checked word for word against llvm-mcto feat(lifter): the new lifter's Rust workspace and its A64 decoder, checked word for word against llvm-mc76e0011d334b72605c0afeat(lifter): the new lifter's Rust workspace and its A64 decoder, checked word for word against llvm-mcto feat(lifter): the new lifter in Rust, writing LLVM IR beside the old one (LONGSHOT_LIFTER=mix): decoder, discovery, sites, mid IR, integer and float semanticsPushed the rest of the lifter work onto this branch, rebased on main at
0e32bc10(the head was76e0011d, M0 alone; it is4b72605c). It now holds M1 (discovery), the hook sites in Rust, M2 (mid IR, integer semantics, LLVM IR writer,LONGSHOT_LIFTER=mix), M3 (floating point and SIMD with fast paths), the speed-ups and the guest profile. It sits on #2272's squash and merges after it, so it is WIP again: the description says what has run and what is still to run (the profiled A/B andrun_all.py --stricton this head).feat(lifter): the new lifter in Rust, writing LLVM IR beside the old one (LONGSHOT_LIFTER=mix): decoder, discovery, sites, mid IR, integer and float semanticsto WIP: feat(lifter): the new lifter in Rust, writing LLVM IR beside the old one (LONGSHOT_LIFTER=mix): decoder, discovery, sites, mid IR, integer and float semanticslift::Program takes the edits (edits::plan_edits) and writes them in as each function is built: before, after or in place of an instruction, at a conditional branch, at the entry in a block of its own; a wrapped function is lifted as its body f_1<entry> and its wrapper f_<entry> (lift::Lifted), both in its unit. lift::whole plans the edits from the placed sites, host/'s entry hooks (with their size gate) and the patches' Rust data, and keys each function by its edits' key (FunctionEdits::key); EDITS_SOURCES (the edits and sites crates) is in the whole lift's key, LIFTER_SOURCES holds only the edits' lowering, so one patch's or site's change lifts again only the units it lands in. The held mechanism is gone (held.txt, --allow-held, --patched, LiftOptions::patched, LiftOutcome::{held, complete}): an instruction the lifter does not cover stops the lift. gen/edits.txt lists each edited function, its key and what changes it; LiftOutcome::edited counts them. The plan's old records are no longer read, and --check-plan compares the discovery alone. On the supported image: 294518 functions in 495 units, 99 edited, none held; two lifts give the same bytes; one site's table entry changed rewrites one unit. Tests: each form on synthetic functions, verified, through the passes and compiled by clang; the forms run against a C harness of the host's side; the whole lift's cache over a site added and its form changed. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017vw8e2TsN4jgNUFQPfkAq8Pushed
e24b41de(was4b72605c): the pull request is now the whole builder in Rust,longshot-build, beside the old one.LONGSHOT_LIFTER=mix,nx2/lift_plan.py) is gone:nx2/is the old builder alone again..nupthrough a 16 MB index..nupto a linked folder in 7 min at 6 jobs, and an updatewith nothing changed takes 2.2 s. No game run of this head yet; the description's Testing and Risks say what is left.
WIP: feat(lifter): the new lifter in Rust, writing LLVM IR beside the old one (LONGSHOT_LIFTER=mix): decoder, discovery, sites, mid IR, integer and float semanticsto WIP: feat(builder): the whole builder in Rust beside the old one (longshot-build): lift, compile, game files, assets; the game reads its RomFS from the .nupPushed
2c2fa8ca: the old builder is deleted and every caller runslongshot-build.nx2/'s builder andthird_party/a64-kitare gone (114 old tests with them; the site-table checks ported to Rust).dev.py, the Windows builder, the AppImage, the release and CI run the new builder; no player's build needs Python.docs/dev/reference/builder.md,architecture.md).WIP: feat(builder): the whole builder in Rust beside the old one (longshot-build): lift, compile, game files, assets; the game reads its RomFS from the .nupto WIP: feat(builder)!: the builder in Rust (longshot-build) replaces the old one: lift, compile, game files, assets; the game reads its RomFS from the .nupPushed
f26faa32: one self-containedlongshot-buildper platform, and the first game runs.longshot-build-<v>-linux-x64(162 MB) and
-windows-x64.exe(99 MB) with everything packed inside, zstd deltas (760 KB for a one-file change)and a signed manifest; LongshotLauncher #259 installs from them.
longshot-buildreached gameplay four times on this PC with no trap or crash.image.binis mapped on Linux; the docs follow.For the Direct3D 12 back end (#2040, WIP, Windows only): two things it needs from the new builder. I'm raising them now so they can be planned rather than added afterwards.
longshot_d3d12.dll, built fromgpu/d3d12/besidelongshot_vk.dll. It uses the same Eden and Sirit sources plus SPIRV-Cross, with its own shader stamp (gpu/d3d12/build.py). On #2040,nx2/build.pybuilds it andmake_game.pyplaces it. This PR deletes both files.spirv_to_dxil.dlland its license file beside the game: Mesa 26.2.6, pinned by size and SHA-256 inthird_party/mesa-spirv-to-dxil/PROVENANCE.md. The builder would fetch and place it the way this PR does with the DLSS, FSR 4 and XeSS runtimes. #2362 adds it to today's third-party archive. With #2295 and this PR that archive goes away, so the builder is where it would end up.On #2040's side, the D3D12 menu will read its fonts through
romfs_read, the wayvk_imgui.cppdoes here, once it is rebased onto this PR. I can write the builder side for both items once this builds on Windows, or hand over what the old path does.- hos_romfs_head of a zstd-stored file decodes its frame's first blocks (hos_zs_frame_head), not the whole file. - A decoded zstd-stored file is kept after its last close, 256 MB of closed copies at most, the least recently used let go first; the most held at once is logged as it grows. - hos_romfs_case finds folders too (mods.c's mod-only listing listed a mod folder the game also has twice), and the very spelling first (of two names that differ in case only, the other could be found). - hos_romfs_ready says whether a RomFS is there: an index open, or a folder that exists (the beside path was set always). - The index is checked at open: every entry within the .nup, sizes sane, the names in strict order (lookups are binary searches); else romfs_index_bad. - Windows: the .nup's handle is overlapped, each read waiting on its thread's event (one synchronous handle served every thread's reads one at a time); a long path is made whole by GetFullPathNameW ("..", a relative path) and extended as \\?\ or \\?\UNC\; the index's path beside image.bin takes either separator and refuses one that does not fit. tests/romfs_test.c checks each (they fail on the code before), with two names that differ in case only and damaged indexes from the Rust side. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017vw8e2TsN4jgNUFQPfkAq8WIP: feat(builder)!: the builder in Rust (longshot-build) replaces the old one: lift, compile, game files, assets; the game reads its RomFS from the .nupto WIP: feat(builder)!: the builder in Rust (longshot-builder) replaces the old one: lift, compile, game files, assets; the game reads its RomFS from the .nup; supersedes #2272901cd29d4ce651934e88193b44c2cf266f1fb0e6tests/sitehooks.py's line(x) is the C at a site's place in a fixture, calling a wrapper of its own that longshot-builder dev site-hooks lowers; objects() links the IR clang made of the wrappers a fixture names. A replaced call with no callee (a blr) is now a spec of its own (<site>@<pc>:). tests/sitecheck.py reads the tables (sitetable.py's reader moved there). run_all gains {clang}: clang on every OS, for the checks that link that object (its TLS is native, which mingw's gcc does not link with). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016o1k1SkKpc592GgxftLP8oEach fixture puts tests/sitehooks.py's line(x) at the site, links the wrappers' object and is compiled by clang ({clang}, {cargo} from run_all); fixtures' flags and slots have external linkage. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016o1k1SkKpc592GgxftLP8oEvery site test runs its hooks as the lift lowers them now (tests/sitehooks.py), and the tables' reader is tests/sitecheck.py's, so the frozen line()/RULES/call_replaced copy is gone. The docs say how a hook site's callback is tested, what dev site-hooks makes, and list run_all's {clang}. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016o1k1SkKpc592GgxftLP8o- A .nup's romfs index, its note (.longshot_romfs.json), the damaged files' list and the game's name and icon are written into the work folder's finish/ and go into the game folder with folder::install, in the swap; the assets read the staged index. The first build that stages them takes the game folder's own index (romfs::reuse), so it indexes nothing again. - A romfs/ folder in a .nup's game folder is removed after the swap, and only when it is the builder's: the installed note names it ('romfs/', written when a build links a dump's in), or every file in it is a hard link of the dump the folder's record names. A player's own stays, and the build says so (romfs_folder_kept): the game reads it before the .nup (host/hos_main.c), so a stale dump's folder would win. - After the swap the builder's own files this build has none of go (an old damaged list; a dump's build's index and note), and so do the old builders' leftovers: bin/'s game files (bin/ once empty), .longshot_exefs/, .longshot_romfs* but the index's note. - The installed note's names are checked with fsx::relative_ok: one naming a place outside the game folder is not read. - 'longshot-builder index --game <new.nup> --out <folder>' points a built folder at its .nup moved: the .nup's size and TOC hash must be the ones its index names (not_the_same_nup otherwise), then the index is made again and the record names the new place. The nup_moved message names the command. Docs: builder.md, build.md, build-events.md. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016o1k1SkKpc592GgxftLP8ostore::exists returns InStore (There, Missing, Unreached), asking up to three times as store::json does: a 404 or a list without the file is missing, anything else (not reached, a server error, a body that is not the list) is unreached. 'dev tools missing' exits 1 when a line is unreached (it printed it as missing, so the release would remake and upload it), and when the sysroot is missing ('upload it by hand': tools.lock and deps.sh say it can't be made the same twice). 'dev tools check --require' says which lines it could not ask about. The store's curl runs start with runtimes::CURL_SAFE (download takes the whole of runtimes::CURL), one option set. Docs: releases.md. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016o1k1SkKpc592GgxftLP8oSaves: a Windows game started without --user (RecompLauncher, a shortcut) kept them in <game>\user, so a rebuilt folder or the Longshot Launcher's builds did not see them. saves_dir now runs on Windows too: %APPDATA%\Longshot, the launcher's --user (LongshotLauncher Core/Saves.cs LongshotRoot), with the old user\ moved there once by the same rules as Linux (an entry already there, or one that cannot go, keeps the old place whole). A link or junction is not made again on Windows: user\ that is one is used as it is, and one inside keeps the old place. longshot_options.ini stays in the game folder (RecompLauncher writes it). recomplauncher.json lists {config}/Longshot/save (RecompLauncher's AppData\Roaming) too, so its backups and cloud saves follow the move. Paths: hos_game_path_a was GetModuleFileNameA into MAX_PATH (260) bytes; it is now hos_game_path_w converted to UTF-8, and the game folder's buffers in hos_paths.h, hos_main.c, options_path.c and game_layout.c hold HOS_PATH_CAP (4096) bytes. The manifest adds longPathAware (test_utf8_paths.py checks it). The Windows saves code is built with llvm-mingw, -Werror; not run on Windows. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016o1k1SkKpc592GgxftLP8oShader store: program_cache_publish wrote one spirv.{pack,idx}.programs- <stamp> pair per translator, hundreds of MB each, and never removed one. spirv_pack::prune_program_copies, run under the store's lock after the copy, keeps this stamp's pair and the two newest others and removes the rest (spirv_pack_test.cpp). spirv.pack itself is still append-only: a TODO there says why compacting it is not done here. Program cache lock: Windows used a Local\ named mutex, the session's, so another user or session (or another spelling of the folder) took the same cache under the first. It is now LockFileEx on longshot_programs.bin.lock beside the cache, as Linux's flock; the handle is held until the process ends. Built with llvm-mingw, not run on Windows. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016o1k1SkKpc592GgxftLP8otest_mods_list and test_log_redact skipped their build half when cargo was missing and passed; run_all now passes --cargo {cargo} (skipped, or a failure with --strict, without it). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016o1k1SkKpc592GgxftLP8otest_guest_profile_write skips Windows by RUN_ALL_SKIP (and takes {cc}) instead of passing there with a SKIP line. test_lifter runs the same three steps as CI's rust job and `mise run rust`; its docstring now says so, and why it is kept: tests/run_all.py runs it with llvm-mc named (the decoder's llvm-mc check runs, not skips) and in release. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016o1k1SkKpc592GgxftLP8oReviewed
97e3f4eeas a draft: thea64decoder,game-files(.nup, NSO, ZBIC/zstd, romfs index),image, and the panic path.Untrusted input: no memory-unsafety, and no defect in
decode(w).decode(u32) -> Option<Insn>is total over all 2^32 words, every shift and table index taken from the word is masked or bounded by its field width, and the parsers contain nounsafe(the builder's only two aredisk.rs'sstatvfsandbuild-core/src/sys.rs). Two holes remain on the exefs path, both in the "sizes bounded before use" family the description says is closed:image/src/build.rs:89—eden_sizeadds the NSO header'sbss_size(nso.rs:268), the only module-size field with noMAX_MODULEcheck;:101then resizes to it, ~4 GiB a module. That is an allocation abort, whichmain.rs:466's hook cannot report asinternal_error.game-files/src/nso.rs:357and:394—(start..start + size)fromDT_RELA(SZ),DT_JMPREL(SZ)andDT_RELR(SZ), unchecked, sooverflow-checks = trueturns a damaged module into a panic andinternal_errorrather thanbad_data;:296(start + 8 * ioverDT_INIT_ARRAYSZ / 8) is the same shape, and unbounded in length.The gap that matters most before leaving draft: CI's Rust job is red on this head (run 52346, job 90210) —
a64'smatches_llvm_mcfails 2206 of 1 800 000 words:ldapr/ldaprb/ldaprhaccepted where llvm-mc-mcpu=cortex-a78csays(invalid)(614), andprfm/prfumnamed (pldslckeep) where-M no-aliasesprints#6. Testing says the workspace's tests pass, so either the local LLVM differs (CI apt-installs an unpinnedllvm) or RCpc is decoded without feature gating; the oracle needs pinning either way.To leave draft: that job green, the Still-to-test runs (Windows, Test Farm), the six renderer fixtures actually run on
main, and an answer to the #2040 builder question already raised above beforenx2/build.pygoes.97e3f4eed73ca9b9d875put used CURL_SAFE's --proto =https, so curl refused an http:// upload API before asking ("HTTP 000"). An http target now gets --proto =http,https --proto-redir =https, as dev release's plain_curl does; the store keeps HTTPS alone. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016o1k1SkKpc592GgxftLP8oRe-checked the three holes at this head (
02386f32, pushed after the review above read97e3f4ee); all three are still open at the current code:builder/crates/game-files/src/nso.rs:268still takesbss_sizefrom the header (u32_at(raw, 0x3C)) with noMAX_MODULEbound — still the one module-size field without one.builder/crates/image/src/build.rs:90adds it ineden_sizeand:104resizes to it, so a header can still ask for ~4 GiB and abort on allocation rather than be refused asbad_data.nso.rs:357andnso.rs:394still walk(start..start + size)over DT_RELA(SZ) / DT_JMPREL(DT_PLTRELSZ) and DT_RELR(SZ) unchecked, andnso.rs:296still buildsstart + 8 * ioverDT_INIT_ARRAYSZ / 8unbounded: withoverflow-checks = truea damaged module panics instead of being refused.CI at this head is unchanged in kind:
Rust (rustfmt, clippy, cargo test)fails ona64 --test llvm_mcalone — 2206 of 1 800 000 words,ldapr309 /ldaprb143 /ldaprh162 printed where llvm-mc says(invalid), andprfm1586 /prfum6 under alias names where-M no-aliasesprints#N.Website build and checksandGuide screenshotsalso fail.Nothing was changed here: this only records that the three holes and the oracle question are still open at
02386f32, rather than fixed by the commits since97e3f4ee.Bounds fix ready to cherry-pick onto
lifter-m0-decoderbuilder/crates/does not exist onmain, so this is a branch rather than a PR:fix/nso-untrusted-boundsindazemc/Longshot, head2dd1a976a4f708af3a74f219fecf54d3eae7ca37(two commits: test76ce7a8aa50ba00f6e4b786dfeaa04a05effeddb, fix2dd1a976a4f708af3a74f219fecf54d3eae7ca37).I could not open a PR against
HumanBean/Longshot:lifter-m0-decoder:HumanBean/Longshotrefusesdazemcwrite access, and Forgejo refuses the cross-fork PR becausedazemc/Longshotis a fork ofMagicBeanDev/Longshot, not ofHumanBean/Longshot.git diff --stat(base02386f32)The four holes, each refused instead of a panic or an allocation
bss_size) ischecked_added and refused overMAX_MODULE, beforeimage/build.rsallocates it.DT_RELA/DT_RELASZ,DT_JMPREL/DT_PLTRELSZ):checked_addplus insideimage.len().relr_offsets):e + 8,cursor + 8 * iandcursor += 63 * 8arechecked_added; the table range is bounded byimage.len().init_array_offsets): returnsResult, boundsstart + sizebyimage.len(), andimage/build.rspropagates it with?.No new error type or constant:
Error::format/Err(String),MAX_MODULEfor the image,image.len()for table ranges.Tests
nso::tests::an_untrusted_bss_size_is_boundednso::tests::an_untrusted_relocation_table_range_is_refusednso::tests::an_untrusted_relr_entry_is_refusednso::tests::an_untrusted_init_array_is_refusedRed on the test commit: all four fail for the bug's reason (an assertion that parse wrongly succeeded, and overflow panics at
nso.rs:296:58,:357:31,:398:26). Green after the fix:cargo test -p image:test result: ok. 9 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s.cargo clippy -p game-files -p image --all-targets -- -D warningsclean.cargo fmt -- --checkclean.Not run in game — N/A, Rust decoder bounds and its unit tests only, no game behaviour change.
Refs #2286
scripts/linux/deps.sh and scripts/windows/deps.sh (and dav1d.sh, docker.sh, the Dockerfile) made every tools.lock archive in two scripts that read each other's pins. They are now builder/tools/: pins.sh holds every upstream pin, lib.sh the checked downloads and the pinned zstd and nasm, one recipe per tool (linux-x64/{llvm,sysroot,ffmpeg,sdl2,cpm}.sh, windows-x64/{llvm-mingw,cpm,sdl}.sh, with dav1d.sh), and make.sh runs them and packs each with `dev tools make` (<out>/<system>/<name>.tar.zst, its version beside it, add.sh's lines; --check makes each twice). The recipes keep the same commands, flags and work folders, so the archives are the same bytes: linux-x64/cpm and windows-x64/sdl, made twice here, are tools.lock's (5e930ba1..., ea35e9e0...). Using the tools is unchanged and needs none of this: mise run tools. scripts/longshot_builder.py reads llvm-mingw's Linux pin from pins.sh; run_all.py looks for headers, dav1d and llvm-mingw in the checkout's tools/ (mise run tools), not deps.sh's old folders. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016o1k1SkKpc592GgxftLP8oThe builder is the program players start. A version folder holds it (Longshot.exe, Longshot.x86_64), its game folders (builds/default, or builds/<the Mod API's code mods stamp>) and, for a release's program, its cache (cache/: portable by default; --cache, LONGSHOT_CACHE and a developer's build keep theirs). A profile (--profile, else profile/ beside it) holds the player's copy and upscalers in profile.json (two keys of the Mod API's file, every other key kept) and the saves (saves/); the game is given LONGSHOT_PROFILE alone. Started with no arguments in a version folder, by a play name, or as play, it reads the profile, runs the fast check (a stamp each build for a profile writes in the record: the builder, the profile's copy and upscalers, the copy's size/time/inode, the mods stamp hook, then the shaders' key), updates only when it says so, starts the game and waits for it; the game's 122 is an update and a new start, three times in a row at most. A first run takes --game. Earlier saves are copied into an empty profile once. build/update --profile write the profile and build for it; --launcher is kept in the record. --output json|text|user|recomplauncher replaces --json and --progress-lines: user shows the build to a person through one seam (UserUi: stderr and error boxes for now, the builder's own windows later); without it, user only when no terminal, a display and no job, CI, headless or Big Picture. dev.py passes --output text, or json where it reads the events. RecompLauncher: prepare is build --game --profile {config}/Longshot --output recomplauncher, start passes the same --profile, the game folder is builds/default. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016o1k1SkKpc592GgxftLP8oThe profile crate from the Mod API stack's zrtukyzp ("feat(profile): launcher-profile, a launcher profile's folder"), its profile basics only, as builder/crates/launcher-profile (builder/crates/profile is the guest profile's): - profile.json v1 read and written (src/file.rs): one JSON object, its keys in the file's order, each value kept as its text, so every key it does not know (the launcher's, the Mod API's "mods", a newer one's) is written back as it was, in its place; no key twice; "v" 1 or none, a newer one refused and never written over; written whole (profile.json.new, flushed, moved over). The known keys: name, color, version, game, upscalers, start_slot (slot_NN, "N" or N, 0-99), last_played, copy_of; put/remove for a key of another's. - The folder's layout (src/lib.rs): LONGSHOT_PROFILE, profile.json, settings.ini, saves/. - Dependencies: serde and serde_json alone (thiserror dropped), so the game may link it later. - Moved tests: the_known_keys_are_read, a_round_trip_keeps_unknown_keys_and_their_order, not_a_profile, start_slots, written_whole_and_read_back, the_layout (minus mods and trust); their scratch under the target folder, never the system's temporary one. Left to the Mod API's layer on top: ModEntry, the strict "mods" rules, mods()/set_mods(), the trust file, the stamp, expand and the switches it sets. build_driver::play::Profile reads and writes the file through it alone: the copy and the upscalers typed, the file as read beside them, put in only when they changed, so a profile written again keeps every other key as it was written (the serde_json::Map before sorted them). Two profiles are equal when they would write the same file. Ported from zrtukyzp (061f315dd); the Mod API stack drops the crate from it on rebase. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016o1k1PPtvLKUijhrMa4pueThe profile's layout as decided with the Mod API, and its game side in C (the Mod API does it in Rust, zqxvvuzy): <profile>/profile.json which profile it is (launcher-profile) <profile>/settings.ini the game's settings (longshot_options.ini's lines) <profile>/saves/ the saves alone: save/, save-work/ (the Mod API adds modstore/) Before, <profile>/saves was the game's whole user folder (its settings, recordings, mouse sensitivity and cache storage beside the saves). Now: - host/longshot_profile.h: LONGSHOT_PROFILE and the profile's paths (longshot_profile_saves, _settings, _file, moved out of longshot_exit.h, which includes it), and profile.json's start_slot read by launcher_profile's rule without a JSON library (longshot_profile_start_slot). The Mod API's sandbox takes the same paths from it. - The saves: the profile's saves/ is the run's save folder (host/nn_fs.c, host/save_dir.h: made, checked, refused as save_dir_unusable when unusable), unless HOS_SAVE_DIR is set or --user names a folder (hos_user_named). - The settings: the profile's settings.ini (host/options_path.c), unless HOS_OPTIONS_FILE or --user; mods.json is beside it, and the builder's ExeFS patches read it there (play::options). - The start slot: start_slot handed on as HOS_START_SLOT (0-99) right after longshot_env.txt, unless set already; a value that is no slot, or a file it can't read, is a log line and no slot. The pressing is the Mod API's Skip title mod's. - The rest stays where it is without a profile: the logs and caches in the game folder (builds/<build>/logs/, cache/), the recordings, mouse sensitivity and cache storage in the per-user user folder. --user still wins over the profile (a developer's run). - play.rs: carry_saves copies an earlier save/ into saves/ and its longshot_options.ini as settings.ini when the profile has none (no more mouse_sens.txt: it stays in the user folder); SAVES and SETTINGS are launcher-profile's. - The crash files (longshot-builder after.rs): the run's options file is the profile's settings.ini. - recomplauncher.json: config is {config}/Longshot/settings.ini, and saves/mouse_sens.txt left the saves. - switches.def: HOS_START_SLOT, and LONGSHOT_PROFILE's and LONGSHOT_STARTED_BY's rows reworded for the layout; hos_main.c's env_line_allowed refuses LONGSHOT_PROFILE from longshot_env.txt (zqxvvuzy). - Docs: profiles.md (sqqtokxm's, minus its mods, trust, sandbox, stamp and cheats sections, rewritten for the C host, with the refused start's line), the index link, switches.md's LONGSHOT_PROFILE and HOS_START_SLOT rows, build.md's play, releases.md, the dev and user saves pages, updates-and-saves. Tests: test_longshot_exit (the paths, start_slot by launcher_profile's cases, the sources), test_options_path (the profile's settings.ini, --user and HOS_OPTIONS_FILE over it, the copy), test_fs_save_commit (the profile's saves/, refused when unwritable, a --user named keeps the user folder's), test_recomplauncher_json, play.rs's carry. Ports the profile basics of zqxvvuzy (249ae3edf: the switch's row, env_line_allowed) and sqqtokxm (c7007ee68: profiles.md, the index link, the LONGSHOT_PROFILE row), and vukowssp's (b890ec8f8) HOS_START_SLOT row reworded for what this side does; the Mod API stack drops those hunks on rebase. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016o1k1PPtvLKUijhrMa4pueView command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.