Skip to content

Fix arithmetic runtime, platform errors, diagnostics, and trig accuracy - #806

Merged
LunaStev merged 2 commits into
wavefnd:masterfrom
LunaStev:fix/runtime-and-numeric-stabilization
Sep 28, 2026
Merged

LunaStev merged 2 commits into
wavefnd:masterfrom
LunaStev:fix/runtime-and-numeric-stabilization

Conversation

@LunaStev

Copy link
Copy Markdown
Member

Summary

  • Provide compiler-owned, freestanding i128 arithmetic and conversion helpers on native targets. Keep native multiply, shift, and power-of-two division lowering; emit private helpers only when required.
  • Inspect ELF ABI metadata through GNU thin archives, including relative paths, long names, and references to members of regular archives. Diagnose missing, malformed, or cyclic references.
  • Classify network errors using the target OS's errno/Winsock values, preserving the original code.
  • Return observable success/error results from async sleep.
  • Align terminal diagnostic carets using four-column tab stops and pinned Unicode display widths in Utils.
  • Use high-precision trigonometric range reduction to retain the quadrant for large finite inputs, including signed-zero and pole-adjacent behavior.

Motivation

Valid native i128 programs currently fail to link because arithmetic runtime symbols are missing. Thin archives bypass ABI inspection, errno values collide between operating systems, async sleep discards duration errors, diagnostic carets drift on Unicode/tabbed source, and large trigonometric inputs lose their phase.

Closes #805
Closes #651
Closes #508
Closes #535
Closes #489
Closes #600

Target and compatibility impact

  • Native arithmetic support covers the supported Linux, macOS, Windows, and FreeBSD targets while retaining existing Wave semantics and C ABI. Existing WebAssembly arithmetic support is shared with the native lowering.
  • std::task::sleep_ms now returns Future<i32>: success is 0 (including a zero duration); negative durations and deadline overflow return -22. await and block_on expose the same result. Explicit Future<void> consumers must update. Compiler/std compatibility revision increases from 4 to 5.
  • Diagnostic JSON retains UTF-8 byte spans and Unicode scalar columns; only terminal layout changes. Width tables use Unicode 17.0.0 and introduce no frontend library dependency.
  • Trigonometric validation uses the approved f64/f32 tolerances and separate pole-adjacent checks. Reference generation uses mpmath only as an offline maintenance tool; builds and tests consume checked-in vectors.

Validation

Using Rust 1.89 and LLVM 21:

  • WAVE_RUN_WASM_RUNTIME_TESTS=1 cargo +1.89 test --locked --workspace --all-targets --no-fail-fast --jobs 2: 350 passed, 0 failed, including WASM execution.
  • Final archive follow-up: cargo +1.89 test --locked --jobs 2 --lib link_validation: 5 passed, including shared-suffix long-name offsets.
  • Final network follow-up: cargo +1.89 test --locked --jobs 2 --test native_providers network_error: 2 passed, including bare/WASI/freestanding target selection.
  • Linux amd64 O0/O2 execution: wide arithmetic/conversions, independent C ABI caller, async sleep, network error mapping, and 494 f64 plus 240 f32 high-precision trigonometric vectors.
  • O0/O2 arithmetic objects checked for missing runtime symbols across all nine supported native OS/architecture combinations. GNU ar and LLVM ar thin archives manually checked for pre-link ABI mismatch diagnostics.
  • cargo +1.89 clippy --locked --workspace --all-targets --jobs 2 -- -D warnings
  • cargo +1.89 fmt --all -- --check
  • git diff --check

Native execution outside Linux is covered by PR CI, not claimed as locally verified.

Checklist

  • Commits include a DCO Signed-off-by line.
  • Tests cover new behavior or the PR explains why no test is needed.
  • User-facing changes include documentation or diagnostics updates.
  • The change preserves the license boundary between the compiler and std/.

@LunaStev
LunaStev merged commit 286dad9 into wavefnd:master Sep 28, 2026
26 checks passed
@LunaStev LunaStev mentioned this pull request Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment