Skip to content

Harden toolchain validation and preserve O0 IR - #216

Merged
LunaStev merged 4 commits into
wavefnd:masterfrom
LunaStev:fix/toolchain-foundations
Sep 23, 2026
Merged

LunaStev merged 4 commits into
wavefnd:masterfrom
LunaStev:fix/toolchain-foundations

Conversation

@LunaStev

Copy link
Copy Markdown
Member

Summary

Reject malformed toolchain inputs and preserve the original O0 program during verification and AST lowering. CLI output publication now preserves input files and existing artifacts on failure; the assembler and object/linker components validate expressions, relocations, symbols, and BSS content.

  • Check scalar operand categories, switch keys, memory operands and typed element/field GEP; verify SSA dominance independently of block storage order and validate phi inputs on predecessor edges. Reject every incoming edge to the function entry block.
  • Keep unused computations, disconnected statements after terminators, and typed compile-time initializer expressions with their evaluated results. Validate constant references, cycles, types, and cached values without rewriting the module.
  • Resolve forward equ dependencies with overflow/cycle diagnostics; distinguish branch relocations from data references, reject invalid ELF symbol extents and nonzero BSS payloads, scope local symbols to input objects, and reset symbol-resolution state between attempts.
  • Publish CLI artifacts through temporary files with same-file checks, return meaningful command errors, preserve split UTF-8 output in CI, and repair contribution links and component instructions.

Motivation

These checks address accepted invalid programs, lost O0 source computations, destructive output failures, and incorrect object metadata in the foundation backlog.

Closes #16, closes #22, closes #23, closes #32, closes #36, closes #37, closes #38, closes #56, closes #62, closes #63, closes #64, closes #80, closes #81, closes #96, closes #142, closes #163, closes #211, closes #214.

Related: #95, #103, #215. The typed namespace/link-name migration across the complete object/linker pipeline remains separate work.

Target and compatibility impact

  • Experimental IR APIs add GlobalId, preserved ConstExpr values and local ConstDecl instructions. Printed IR includes preserved initializers. Consumers constructing globals directly must supply identity and expression fields.
  • Function entry blocks may no longer have predecessor edges; valid loops use separate headers. Previously accepted malformed IR and assembly inputs now produce errors.
  • Undefined branch targets use branch relocation intent; external data/address references retain data relocation intent. Symbol table keys distinguish object-local from global names.
  • Add same-file and tempfile dependencies for safe artifact publication. MSRV remains Rust 1.86. No external assembler is introduced.
  • This PR does not implement the complete runtime no-UB contract, memory tracking, interpreter, native code generator, DWARF emission, or full static linking. undef removal and exact floating-point semantics remain follow-up work.

Validation

Linux, Rust 1.96.0; Cargo dependencies resolved from the local cache:

  • cargo test --offline --workspace --locked: 104 passed.
  • cargo test --offline --workspace --all-features: 123 passed.
  • cargo clippy --offline --workspace --all-targets --locked -- -D warnings: passed.
  • cargo clippy --offline --workspace --all-targets --all-features --locked -- -D warnings: passed.
  • cargo fmt --all -- --check and git diff --check: passed.
  • Workspace builds and tools/ci_smoke.py passed with socket disabled and enabled.
  • python3 -m unittest discover -s tools -p 'test_*.py' -v: 8 passed.
  • Regression coverage includes original failure cases, valid neighboring inputs, unchanged IR after verification, loop/block-order cases, injected partial-write failures, symbol ownership, and relocation records without an external assembler.

Windows/macOS execution and CI results are not claimed by these local checks. Complete native IR execution is not available and was not tested.

Checklist

  • Commits include DCO sign-offs and preserve existing attribution.
  • Regression tests cover changed behavior.
  • User-facing behavior is reflected in diagnostics and README/contribution guidance.
  • Final diff reviewed; commits separate pipeline, IR, CI helper, and contribution changes.
  • Existing licenses and repository policies preserved.

@LunaStev
LunaStev merged commit 578b885 into wavefnd:master Sep 23, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment