Skip to content

Fix bundled std discovery and float literal/output handling - #932

Open
LunaStev wants to merge 4 commits into
wavefnd:masterfrom
LunaStev:fix/std-discovery-and-literal-ranges
Open

LunaStev wants to merge 4 commits into
wavefnd:masterfrom
LunaStev:fix/std-discovery-and-literal-ranges

Conversation

@LunaStev

@LunaStev LunaStev commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

Summary

Fresh installations and relocated compilers now find the std/ shipped beside wavec, so importing std no longer requires an extra --std-root flag. Floating literals are range-checked at their resolved HIR width, and print/println support fixed fractional float output with {:.N}.

  • Select an explicit std root first, then the actual executable's sibling std, then the legacy per-user installation. Validate the selected tree without silently falling back from an invalid installation; keep install/update destinations unchanged. Package smoke checks now exercise ordinary discovery.
  • Diagnose default-f32 literals such as 1e39 before output emission, while preserving contextual f64, finite rounding, signed zero, underflow, explicit conversion order, and arithmetic short-circuiting.
  • Accept static decimal precision for f32/f64 output, with checked bounds and matching native/WebAssembly rounding. Retain existing placeholders, literal percent handling, source-order single evaluation, and six fractional digits for default float output.
  • Explain f32 literal defaults and rounding, default -O0 and explicit -O2, and a verified --dep=pkg=. layout for sibling src/ and tests/ directories.

Motivation

Closes #927 through the documented f32 default/rounding policy and the missing representation-range check. Ordinary finite rounding remains allowed.

Closes #928 by using the std included in the compiler's installation or extracted archive.

Closes #930 through README/help documentation of the existing O0 default and explicit optimization usage. This does not change the default or claim a benchmark speedup.

Closes #931 through its documented-layout alternative: sibling tests can import public source modules with --dep, without a library entry or re-export. Parent-directory imports remain unsupported.

Related to #929: implements the requested float-precision subset {:.N}. Width, fill, alignment, dynamic precision, and additional radix syntax are outside this PR; existing {x} hexadecimal output remains available.

Target and compatibility impact

LLVM remains the default backend, optimization defaults remain O0, and local import containment is unchanged. The Whale dependency and adapter execution scope are unchanged. No dependencies, targets, native ABI contracts, or releases are added or removed.

Fixed precision uses a nonnegative decimal integer in 0..=2147483647; incompatible types, malformed precision, and input precision receive source diagnostics before backend lowering. Existing explicit std-root overrides retain their no-fallback behavior.

Validation

Using Rust 1.89.0, LLVM 21.1.8, and Cargo jobs=2:

  • LLVM_SYS_211_PREFIX=/usr/lib64/llvm21 cargo +1.89 test --offline --locked --jobs 2 --workspace --all-targets: 439 passed across 50 suites. Local socket regressions ran with the required local permission.
  • LLVM_SYS_211_PREFIX=/usr/lib64/llvm21 cargo +1.89 clippy --offline --locked --jobs 2 --workspace --all-targets -- -D warnings.
  • python3 -m unittest tools.test_ci tools.test_release_gates tools.test_release_publish tools.test_windows_package: 68 passed.
  • node tools/test_wasm_host.mjs: 8 passed.
  • cargo +1.89 fmt --all --check, touched Rust function-spacing checks, python3 tools/check_std_policy.py, and git diff --check.
  • Native Linux amd64 and wasm32, wasm32-WASI, and wasm64 output execution at O0/O2, including ties, negative zero, subnormals, evaluation order, diagnostics, and existing-output preservation.
  • O0/O2 IR and object generation for Linux amd64/arm64/riscv64/loongarch64, macOS amd64/arm64, Windows MSVC amd64/arm64, FreeBSD amd64, and wasm64. This is cross-target emission, not native execution on those other platforms.
  • Executed the README numeric/precision and sibling-test examples, and the reported allocation example using a relocated compiler plus bundled std without --std-root.

CI follow-up validation for the regression tests:

  • Serialize relocated-compiler fixtures so a child cannot inherit another case's writable executable descriptor before exec. All six discovery cases passed in 50 consecutive runs (300 checks) with six test threads.
  • Compile precision execution fixtures only when a matching execution test is enabled, and select an enabled target for frontend-only diagnostics. This resolves the unused-constant errors in Windows Clippy without suppressing warnings or dropping diagnostic coverage.
  • The two focused suites pass with default features (10 tests) and an AArch64-only compiler configuration (8 tests). Clippy passes for that restricted configuration and the complete default-feature workspace/all-targets set; rustfmt, function-spacing and whitespace checks pass.

The initial CI run reported four failures in these test harnesses (Linux arm64/riscv64 and Windows amd64/arm64). Remote validation of this follow-up remains pending; local checks do not establish native Windows execution.

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/.

Resolve imports from an explicit std root, the actual executable's sibling
std tree, then the legacy per-user installation. Preserve compatibility
validation and fail on an invalid selected tree without silent fallback.
Keep install/update destinations unchanged and exercise discovery in package
smoke checks and relocated-compiler regressions.

Refs wavefnd#928

Signed-off-by: LunaStev <luna@lunastev.org>
Check floating literals at their resolved HIR evaluation width while retaining
contextual f64, explicit conversion order, finite rounding and short-circuit
arithmetic behavior. Add float-only {:.N} output with checked precision,
matching native and WebAssembly rounding, source diagnostics and regressions.

Refs wavefnd#927, wavefnd#929

Signed-off-by: LunaStev <luna@lunastev.org>
Document f32 literal contexts and rounding, fixed fractional output, std lookup
precedence, the default O0 optimization level, and explicit O2 usage. Explain
the supported --dep sibling-test layout while preserving local import bounds.

Refs wavefnd#927, wavefnd#928, wavefnd#929, wavefnd#930, wavefnd#931

Signed-off-by: LunaStev <luna@lunastev.org>
Serialize relocated-compiler test cases to keep writable executable copies
from overlapping child process creation. Gate precision execution fixtures
with their consumers, and choose an enabled target for frontend diagnostics
when the compiler has a restricted LLVM feature set.

Refs wavefnd#928, wavefnd#929

Signed-off-by: LunaStev <luna@lunastev.org>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment