Skip to content

Add watch mode and dev-shim hot reload#9739

Merged
rtfeldman merged 41 commits into
mainfrom
roc-watch
Jun 24, 2026
Merged

Add watch mode and dev-shim hot reload#9739
rtfeldman merged 41 commits into
mainfrom
roc-watch

Conversation

@rtfeldman

Copy link
Copy Markdown
Contributor

Adds watch-mode supervision for roc check --watch and roc test --watch, using explicit compiler-produced watch inputs so reruns track root files, transitive modules, file imports, and filesystem packages/platforms without source scanning. The same watch infrastructure now powers roc --watch for default dev-shim execution, where successful rebuilds send replacement RunImage bytes through shared memory while failed or cancelled rebuilds leave the currently running image intact.\n\nThis also records source-relative file-import dependencies in cached module state, rejects absolute file imports, keeps LIR out of the dev-shim shared-memory payload, and adds a tidy ban for anyerror under src/.

rtfeldman added 30 commits June 21, 2026 09:33
# Conflicts:
#	src/cli/main.zig
#	src/compile/cache_config.zig
#	src/compile/cache_module.zig
#	src/eval/test/lir_inline_test.zig
#	src/watch/watch.zig
…ng headerless apps

The default `roc <file>` command now hot reloads automatically on the dev
backend (no `--watch` flag needed); `roc check` and `roc test` still require
`--watch`. Adds `--watch` to `roc build`, which reruns the build on every source
change via the shared watch loop. Headerless default apps no longer hot reload —
they compile through throwaway synthetic source files, so they just run once on
every platform; the shared-memory shim is still their run mechanism where the
default platform runtime exists.

Also links CoreFoundation/CoreServices (macOS) and kernel32 (Windows) onto every
target that compiles the watch module via a shared `linkWatchPlatformLibs`
helper, fixing undefined-symbol link failures for the release binary and the
cli_test/watch_test test executables.
The seqlock in hot_reload.zig used `@atomicLoad/Store(u64, ...)`, which Zig
rejects on 32-bit targets (x86-linux-musl, arm-linux-musleabihf) lacking
lock-free 64-bit atomics. Route those accesses through `loadU64`/`storeU64`
helpers that `comptime`-branch to a plain load/store when `usize` is 32-bit.
Hot reload only runs on 64-bit hosts — the dev backend is unavailable on 32-bit,
so `HostLirCodeGen` is `void` and the control block is never driven there — so
the fallback is never executed; it only needs to compile. The u64 wire format
and 64-bit atomic behavior are unchanged. Also `@intCast` a u64 image_size to
usize in a RunImage test that failed the same 32-bit build.
Resolved conflicts: combined the LLVM-build target detection (narrowed error set
+ main's native-macOS guard); bumped cache version to 8 and regenerated the
ModuleEnv layout-version hash and serialized-size constant (1808) for the merged
struct; added the new `nominal_mapper` field to the punned single-field-record
parser state. Converted main's decoder platform-test helpers off `anyerror` to an
explicit `TestError` set to satisfy this branch's tidy rule.
# Conflicts:
#	src/compile/cache_module.zig
#	test/serialization_size_check.zig
@rtfeldman
rtfeldman marked this pull request as ready for review June 24, 2026 14:34
@rtfeldman
rtfeldman merged commit 3388623 into main Jun 24, 2026
35 of 40 checks passed
@rtfeldman
rtfeldman deleted the roc-watch branch June 24, 2026 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant