Skip to content

Stabilize constant expressions, std installation and platform boundaries - #804

Merged
LunaStev merged 2 commits into
wavefnd:masterfrom
LunaStev:fix/release-constant-stabilization
Sep 27, 2026
Merged

LunaStev merged 2 commits into
wavefnd:masterfrom
LunaStev:fix/release-constant-stabilization

Conversation

@LunaStev

@LunaStev LunaStev commented Sep 27, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Evaluate supported global constant and static initializer expressions in HIR using ordered conversions and exact utils integer arithmetic. Preserve short-circuiting, diagnose invalid operations during check, and share integer-literal floating conversion with runtime lowering.

  • Record an immutable std revision in the compiler. Make install std and update std use that revision by default, with an explicit --ref override that still validates compatibility and preserves the existing installation on failure.

  • Convert Windows environment blocks from UTF-16 to UTF-8, validate Windows access modes and probe permissions without modifying files, reject unsupported wasm64 mmap requests before allocation, and preserve Unix child signal exit codes.

  • Gate RISC-V CRT and networking checks on successful release compiler creation, including after unrelated test failures.

Motivation

const N: i32 = 1 + 2 previously passed check but failed during LLVM emission. Installing a moving std branch could select a tree unrelated to the compiler. Platform providers also silently accepted unsupported access/mmap requests or lost environment encoding and child termination information.

Fixes #750
Fixes #768
Fixes #526
Fixes #528
Fixes #705
Fixes #785
Fixes #650

Target and compatibility impact

  • Global constants support numeric arithmetic, comparisons, bitwise/shift/logical operations, casts and constant references. Existing literal/aggregate/variant construction remains supported. Unsupported calls and memory accesses fail in the frontend. Integer division/remainder by zero and signed MIN/-1 division are diagnosed; unexecuted logical operands do not produce evaluation errors. Addition, subtraction and multiplication retain width-based wrapping.
  • Source archive builds can provide WAVE_STD_REVISION; without Git metadata or that setting, installation requires an explicit --ref. CLI help and errors describe the new behavior.
  • Windows F_OK checks existence; R_OK/W_OK use non-destructive native opens, with readonly regular files rejecting writes. X_OK returns -95; unknown mode bits return -22. Environment conversion preserves embedded separators, the final double NUL and special drive entries.
  • wasm64 mmap accepts only null address, positive length, READ|WRITE, PRIVATE|ANONYMOUS, fd -1 and offset 0. Other requests preserve allocator state.
  • Unix child signal termination returns 128 + signal. Ordinary exit codes and Windows exit handling remain unchanged.
  • No external numeric dependencies or libc FFI were added to the implementation. Native Windows execution remains for CI; the Windows ARM64 and WASM jobs include the new regression suite.

Validation

Commands used LLVM_SYS_211_PREFIX=/usr/lib64/llvm21 locally.

  • cargo test --locked --workspace --no-default-features --features llvm-target-core64 --jobs 2 --no-fail-fast: 320 tests exercised. Three socket-dependent failures passed when rerun outside the network sandbox. A new fixture was adjusted to avoid requiring external native i128 runtime helpers; its final regression suite passed.

  • WAVE_RUN_WASM_RUNTIME_TESTS=1 cargo test --locked --jobs 2 --test release_constants --test frontend_regressions --test io_constant_regressions: all 29 tests passed, including O0/O2 constant/runtime comparisons and real wasm64 mmap execution in Node memory64.

  • Focused native_boundaries (8), stabilization_17 (9), and driver library (11) tests passed. Windows amd64/ARM64 objects and mocked native API failure/cleanup paths were covered.

  • Local Git installation tests covered pinned older revisions, explicit refs, incompatible manifests, missing refs/repositories, validation failure, replacement and rollback.

  • cargo clippy --locked --workspace --all-targets --jobs 2 -- -D warnings, cargo fmt --all --check, and git diff --check passed.

  • With the CI-pinned Rust 1.89 toolchain: cargo +1.89 clippy --locked --all-targets --jobs 2 -- -D warnings, cargo +1.89 test --locked --jobs 2 --lib std::tests (4 tests), and cargo +1.89 fmt --all --check passed. The std revision tests exercise both recorded and missing revisions without build-time-constant conditionals. Workflow YAML and dependent-step success/failure/skipped/cancelled conditions were checked.

Native wide-division helper provisioning is outside this change: wide constant quotients are checked against exact expected values; runtime wrapping and bitwise tests cover every integer width.

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 648ade2 into wavefnd:master Sep 27, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment