From fb728d63bcd0d80bd5161537e81c30d27eb4df7b Mon Sep 17 00:00:00 2001 From: root Date: Sun, 14 Jun 2026 18:50:31 +0000 Subject: [PATCH] W7e stage B: factor the .wasm artifact into unit compile-freshness inspect_shared_unit_filesystem() tracked only the .so mtime, so a missing or stale .wasm with a current .so never triggered a rebuild and the unit fell to native indefinitely (the in-process cache also never invalidated). Account for su->wasm_name when wasm unit compilation is enabled: a unit counts as compiled only as of the OLDER of the two artifacts; a missing .wasm forces a recompile. Closes the cached-vanished-.wasm gap noted in the stage A review. Verified independently on the build host: run_cli_tests --include-wasm-kill => 87 passed, 0 failed; delete-.wasm-then-request rebuilds the artifact. Co-Authored-By: Claude Opus 4.8 --- src/lib/compiler.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/lib/compiler.cpp b/src/lib/compiler.cpp index c131dd7..0009946 100644 --- a/src/lib/compiler.cpp +++ b/src/lib/compiler.cpp @@ -372,6 +372,16 @@ SharedUnitFilesystemState inspect_shared_unit_filesystem(Request* context, Share ); state.required_time = std::max({state.source_time, state.setup_template_time, state.compiler_abi_time}); state.compiled_time = file_mtime(su->so_name); + if(compiler_wasm_unit_compile_enabled(context)) + { + time_t wasm_time = file_mtime(su->wasm_name); + // The wasm backend serves the .wasm, so a missing/stale .wasm must + // trigger a rebuild even when the .so is current. Treat the unit as + // compiled only as of the OLDER artifact; a missing .wasm (mtime 0) + // forces recompile via the existing needs_compile == (compiled_time==0). + if(wasm_time == 0 || wasm_time < state.compiled_time) + state.compiled_time = wasm_time; + } return(state); }