Handle optimizer-generated strlen in supported wasm32 std execution
Problem
O2 introduces an env.strlen import while compiling std path code. The built-in wasm32 execution path cannot provide that import, so a case that runs at O0 stops running at O2.
Reproduction and evidence
Audited canonical master 69a67c6e0fb700f37ee6114f5a66d37ee13771a5 (0.0.1-alpha-dev). Matching checkout-built compiler/std were used for compiler probes on Linux amd64 with Rust 1.89.0 and LLVM 21.1.8. Artifact inspection, mocked/projection checks and foreign-target object emission are identified below and are not native execution on those operating systems.
target/debug/wavec --std-root "$PWD/std" build tests/cases/shared/test82.wave --target wasm32-unknown-unknown -O0 --run --out-dir out-O0
target/debug/wavec --std-root "$PWD/std" build tests/cases/shared/test82.wave --target wasm32-unknown-unknown -O2 --run --out-dir out-O2
Observed: first command passes; second fails with unresolved WebAssembly host imports: env.strlen. wasm32-wasip1 O2 also fails. wasm64-unknown-unknown O2 passes this control; the report does not generalize the failure to wasm64.
Scope
Preserve supported wasm32 execution when optimization creates a memory/string primitive dependency, by a target-appropriate primitive implementation or prevention of the unsupported transform.
Starting points: llvm/src/codegen/ir.rs:1, tests/std_data_boundaries.rs:101.
Completion criteria
- [ ] Run the real path case at O0/O2 for bare wasm32 and WASI.
- [ ] Retain wasm64 and missing-import diagnostics.
- [ ] Exercise memory boundaries without claiming general freestanding primitive parity.
Related: #918, #453. Related broad trackers or completed implementations are context, not claims that their entire scope is unfinished.