Skip to content

Fix ownership cleanup and native runtime packaging#20

Merged
loreste merged 5 commits into
mainfrom
agent/memory-safety-runtime-install
Jul 23, 2026
Merged

Fix ownership cleanup and native runtime packaging#20
loreste merged 5 commits into
mainfrom
agent/memory-safety-runtime-install

Conversation

@loreste

@loreste loreste commented Jul 23, 2026

Copy link
Copy Markdown
Owner

Summary

  • close C and native backend ownership gaps across strings, arrays, enums, structs, maps, slices, branches, and deferred cleanup
  • harden runtime path handling and add differential/allocator-guard coverage
  • ship native_runtime.c and native_bridge.c through Unix, Windows, DEB, and RPM packaging/install paths
  • require native memory-safety and LLVM correctness CI gates, and validate native builds from an installed prefix
  • update native compiler and release documentation

Validation

  • cargo build --release
  • cargo test --bin mako native_codegen (12 passed)
  • ./scripts/native-compiler-test.sh (full differential + GuardMalloc + leaks gate passed)
  • ./scripts/llvm-backend-test.sh (passed; compile 0.139x, runtime 0.940x, RSS 0.985x, binary 0.997x vs C)
  • ./scripts/install-smoke.sh
  • packaged release install followed by installed-prefix --backend native compile/run
  • shell syntax, workflow YAML parse, installer alias parity, and git diff --check

Summary by CodeRabbit

  • New Features

    • Native builds now work with packaged runtime support files, including native backend examples and installed-prefix workflows.
    • Added an if expression example for native compilation coverage.
  • Bug Fixes

    • Improved ownership handling for slices, arrays, strings, enums, and structs to prevent leaks, double frees, and dangling references.
    • Improved safe handling of length-delimited paths and native runtime resources.
  • Documentation

    • Clarified one-shot installation, runtime files, archive contents, verification, and release requirements.
  • Tests

    • Strengthened native memory-safety, leak detection, LLVM correctness, and installer smoke checks.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 0585ef47-8010-448c-8f74-4438876b990d

📥 Commits

Reviewing files that changed from the base of the PR and between aa98beb and d8cd5bd.

⛔ Files ignored due to path filters (2)
  • dist/install-linux.sh is excluded by !**/dist/**
  • dist/install-release.sh is excluded by !**/dist/**
📒 Files selected for processing (26)
  • .github/workflows/ci.yml
  • .github/workflows/release.yml
  • README.md
  • docs/NATIVE_COMPILER_PLAN.md
  • docs/RELEASE.md
  • docs/SOUNDNESS.md
  • examples/native/native_if_expr.mko
  • examples/testing/slice_alias_test.mko
  • runtime/mako_rt.h
  • runtime/native_runtime.c
  • scripts/file-io-regression.sh
  • scripts/install-linux.sh
  • scripts/install-release.sh
  • scripts/install-smoke.sh
  • scripts/install.ps1
  • scripts/install.sh
  • scripts/llvm-backend-test.sh
  • scripts/native-compiler-test.sh
  • scripts/package-deb.sh
  • scripts/package-release.ps1
  • scripts/package-release.sh
  • scripts/package-rpm.sh
  • src/codegen/mod.rs
  • src/dce.rs
  • src/main.rs
  • src/native_ir.rs

📝 Walkthrough

Walkthrough

The PR updates native ownership and slice handling, adds deep-clone and arena append runtime helpers, packages native runtime sources, improves native install smoke tests, and makes LLVM and macOS memory-safety checks required in CI.

Changes

Native ownership and backend behavior

Layer / File(s) Summary
Runtime ownership and arena operations
runtime/mako_rt.h, runtime/native_runtime.c, docs/SOUNDNESS.md, examples/testing/slice_alias_test.mko
Array cloning, owned-buffer growth, arena-backed appends, and bounded native path conversion are updated.
Ownership-aware code generation
src/codegen/mod.rs
Scope cleanup, deep cloning, enum helpers, string-view emission, arena append, defer ordering, and ownership tests are expanded.
Native slice lowering and reachability
src/native_ir.rs, src/dce.rs, src/main.rs
Slice headers are cloned or released according to ownership, append transfer tracking is refined, reachable enum declarations are retained, and runtime source lookup prefers the resolved runtime directory.
Runtime packaging and backend validation
scripts/*, .github/workflows/*, docs/*, README.md, examples/native/native_if_expr.mko
Native runtime sources are packaged and installed, installed-prefix native builds are smoke-tested, fixtures are refreshed, and LLVM/macOS validation gates are strengthened.

Estimated code review effort: 5 (Critical) | ~120 minutes

Possibly related PRs

  • loreste/mako#10: Updates overlapping installer scripts and environment/profile persistence behavior.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/memory-safety-runtime-install

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@loreste
loreste marked this pull request as ready for review July 23, 2026 17:51
@loreste
loreste merged commit cf5e37e into main Jul 23, 2026
12 of 14 checks passed
loreste added a commit that referenced this pull request Jul 25, 2026
Fix ownership cleanup and native runtime packaging
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant