wasm-tier-2-phase-B-and-C #28
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "wasm-tier-2-phase-B-and-C"
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?
Review — #28 Phase B+C: codegen reactor target + link/build/CLI
Clean target addition. The
Workervariant slots into the existingTargetmachinery without disturbing the native/Tier-1 paths, and the factoring is good: the sharedinit_callstring means both entry shapes build the Machine identically and only diverge on what they do with it;llvm_tools()is extracted as the common toolchain locator sowasm_toolchain(Tier 1, needs wasi-libc) andlink_wasm_reactor(Tier 2, needs no libc) don't duplicate the sysroot/rust-llddiscovery; andembed_wasm_archivededups the build.rs panic+env-var logic across the two archives. The "onewasmfeature embeds both archives" call (D5) keeps the install story to a singlejust install-wasm, andWORKER_RUNTIME_LIBbeingSomeexactly whenWASM_RUNTIME_LIBis means a--target workerrequest on a non-wasm build fails with the same actionable message. I verified the fourREACTOR_EXPORTSnames match the runtime's actual#[no_mangle]symbols (plg_initfrom codegen;plg_rt_run_query/plg_rt_alloc/plg_rt_freein reactor.rs), and thatplg_rt_set_machineis correctly not exported (it's reached only throughplg_init).-mattr=+tail-callis carried into the reactorllcinvocation with the rationale comment — the load-bearing flag.Real concerns
1. The doc comment references a "reactor smoke test" that doesn't exist.
link_wasm_reactor:There is no reactor smoke test in the repo. The only smoke recipe is
wasm-smoke, which is Tier 1 (wasm32-wasi, driven bywasmtime) and is itself marked "LOCAL only — not in CI yet" — it never touches the reactor ABI. So the comment promises coverage that isn't there. Either add the test or drop the clause.2. The entire
link_wasm_reactorpath has zero automated coverage, and--allow-undefinedhides the worst failure mode. The two new golden_ir tests are good, but they only exercise codegen —compile_to_ir_target(..., Worker)stops before linking. Nothing in the PR links a Worker module and asserts that (a) it instantiates and (b) the fourREACTOR_EXPORTSare actually present as wasm exports. That matters specifically because of the flag combination: with--allow-undefined, a missing or misnamed export degrades to a wasm import rather than a link error — so "the host can't findplg_rt_run_query" is exactly the failure that won't surface at build time. CI doesn't run wasm at all, so a regression in the link flags, an export rename, or a stray undefined import that workerd doesn't provide would all ship green. The gate spike proved workerd works, but that was the throwawaywasm-t2branch; nothing here keeps it from regressing. Areactor-smokerecipe — even local-only, mirroringwasm-smoke, that compiles--target worker, instantiates under Node/workerd, and round-trips one query while asserting the four exports exist — would close both #1 and #2 at once.Small observations
3. Both wasm targets default
-otostem.wasm.Target::Wasm | Target::Worker => stem.with_extension("wasm"), so compiling the same source to both targets without an explicit-osilently overwrites. Minor (users pass-o), but a distinct default (e.g..worker.wasm) would remove the footgun.4. No golden test pins the Tier-1
wasm32-wasientry. The new tests cover native (@main) and worker (@plg_init), but the__main_argc_argventry for Tier 1 now lives in a nested arm of the restructuredmatch. Since this PR reshaped that match, a third assertion locking the Tier-1 entry would pin all three entry shapes against future drift. Pre-existing gap, cheap to close while you're here.Net: #2 is the one I'd want addressed before merge — the reactor link path is the substance of this PR and currently the only thing exercising it is a comment pointing at a test that doesn't exist. The codegen/CLI/build plumbing itself looks correct.