Skip to content

aot: make precompiled modules run without libxls#962

Closed
dank-openai wants to merge 3 commits into
mainfrom
dank-spr/standalone-runtime-aot
Closed

aot: make precompiled modules run without libxls#962
dank-openai wants to merge 3 commits into
mainfrom
dank-spr/standalone-runtime-aot

Conversation

@dank-openai

@dank-openai dank-openai commented May 7, 2026

Copy link
Copy Markdown
Contributor

Generate standalone wrappers for precompiled AOT modules and move reusable execution support into
xlsynth-aot-runtime. That lets runtime consumers execute linked object code without carrying the
compiler/JIT stack or an accompanying libxls DSO.

Problem Solved

Runtime consumers that only execute precompiled XLS modules should not need to ship the compiler and JIT runtime after those modules have already been compiled. The existing generated wrappers still instantiate the heavyweight execution stack, so copied runtime artifacts retain an avoidable dependency on xlsynth, xlsynth-sys, libxls, and LLVM even when the AOT object code is already linked into the final binary.

Mental model

xlsynth remains the build-time compiler. At runtime, a precompiled module is represented by its linked object code, generated wrapper glue, and a small runtime-only support layer that knows how to marshal buffers and surface assertion events. Compiler and JIT-capable tools can continue to use the full runtime path when they need it.

Non-goals

  • This does not add standalone support for runtime trace or cover callbacks.
  • This does not promise cross-version compatibility for generated artifacts.
  • This does not remove the heavyweight runtime path from tools that genuinely need compiler or JIT features.

Tradeoffs

  • Runtime assertions remain part of the first standalone artifact contract because current shipped AOT inputs already depend on them.
  • Reachable trace and cover usage is rejected during generation instead of being accepted and failing later through unsupported callbacks.
  • Generated wrapper source is canonicalized by the generator so artifact bytes do not depend on whichever host rustfmt binary happened to run after emission.

Architecture

  • Add xlsynth-aot-runtime for artifact-agnostic runner support that can be linked directly into runtime consumers.
  • Make generated AOT wrappers standalone by default and keep their artifact-specific glue separate from reusable runtime support.
  • Carry explicit ABI metadata in each artifact, preserve assertion delivery, and scope feature legality checks to the selected top function closure rather than unrelated dead siblings.

Observability

Generated wrappers expose runtime-visible artifact metadata, including ABI version and supported feature flags, and keep assertion messages available through the standalone runner APIs. Unsupported callback-bearing artifacts now fail during generation with explicit errors instead of reaching a latent runtime abort path.

Tests

Validation covered standalone artifact generation, runtime execution, generated-source stability, and downstream integration behavior:

  • cargo test -p xlsynth-aot-standalone-test-crate --tests --no-fail-fast
  • cargo test -p xlsynth-aot-test-crate --tests --no-fail-fast
  • cargo test --manifest-path xlsynth/tests/aot-test-crate/Cargo.toml generated_wrappers_match_golden_references

Focused downstream integration validation passed on both macOS and Ubuntu 24.04. Copied-artifact validation on both platforms also confirmed that representative runtime carriers no longer had a runtime libxls dependency.

Stack:

⚠️ Part of a stack created by spr-multicommit. Do not merge manually using the UI - doing so may have unexpected results.

# Problem Solved

Runtime consumers that only execute precompiled XLS modules should not need to ship the compiler and JIT runtime after those modules have already been compiled. The existing generated wrappers still instantiate the heavyweight execution stack, so copied runtime artifacts retain an avoidable dependency on `xlsynth`, `xlsynth-sys`, `libxls`, and LLVM even when the AOT object code is already linked into the final binary.

# Mental model

`xlsynth` remains the build-time compiler. At runtime, a precompiled module is represented by its linked object code, generated wrapper glue, and a small runtime-only support layer that knows how to marshal buffers and surface assertion events. Compiler and JIT-capable tools can continue to use the full runtime path when they need it.

# Non-goals

- This does not add standalone support for runtime `trace` or `cover` callbacks.
- This does not promise cross-version compatibility for generated artifacts.
- This does not remove the heavyweight runtime path from tools that genuinely need compiler or JIT features.

# Tradeoffs

- Runtime assertions remain part of the first standalone artifact contract because current shipped AOT inputs already depend on them.
- Reachable `trace` and `cover` usage is rejected during generation instead of being accepted and failing later through unsupported callbacks.
- Generated wrapper source is canonicalized by the generator so artifact bytes do not depend on whichever host `rustfmt` binary happened to run after emission.

# Architecture

- Add `xlsynth-aot-runtime` for artifact-agnostic runner support that can be linked directly into runtime consumers.
- Make generated AOT wrappers standalone by default and keep their artifact-specific glue separate from reusable runtime support.
- Carry explicit ABI metadata in each artifact, preserve assertion delivery, and scope feature legality checks to the selected top function closure rather than unrelated dead siblings.

# Observability

Generated wrappers expose runtime-visible artifact metadata, including ABI version and supported feature flags, and keep assertion messages available through the standalone runner APIs. Unsupported callback-bearing artifacts now fail during generation with explicit errors instead of reaching a latent runtime abort path.

# Tests

Validation covered standalone artifact generation, runtime execution, generated-source stability, and downstream integration behavior:

- `cargo test -p xlsynth-aot-standalone-test-crate --tests --no-fail-fast`
- `cargo test -p xlsynth-aot-test-crate --tests --no-fail-fast`
- `cargo test --manifest-path xlsynth/tests/aot-test-crate/Cargo.toml generated_wrappers_match_golden_references`

Focused downstream integration validation passed on both macOS and Ubuntu 24.04. Copied-artifact validation on both platforms also confirmed that representative runtime carriers no longer had a runtime `libxls` dependency.

pr:standalone-runtime-aot

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5df7abff5f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread xlsynth-aot-runtime/src/lib.rs Outdated
@dank-openai dank-openai force-pushed the dank-spr/standalone-runtime-aot branch 2 times, most recently from acc6c7e to a28d4b2 Compare May 7, 2026 02:50
@dank-openai dank-openai requested a review from meheff May 7, 2026 03:18
Preserve the standalone allocator callback contract for generated heap allocas by routing over-aligned requests through posix_memalign while keeping the malloc fast path for ordinary alignments.
Cover heap-scratch allocator behavior directly, exercise a generated counted_for artifact above the LLVM stack-allocation cutoff, and compare standalone execution with the legacy runner for direct-call and assertion-bearing artifacts.
@dank-openai dank-openai force-pushed the dank-spr/standalone-runtime-aot branch from 9e14e19 to 42af3a5 Compare May 7, 2026 03:28
@dank-openai dank-openai changed the title aot: define standalone runtime artifacts for precompiled modules aot: make precompiled modules run without libxls May 7, 2026
@dank-openai dank-openai marked this pull request as draft May 7, 2026 17:10
@dank-openai

Copy link
Copy Markdown
Contributor Author

Closing as superseded by #964.

This draft was the initial standalone runtime-AOT prototype. The follow-up design moved runtime ABI ownership into XLS itself and replaced the Rust-owned shadow runtime with thin integration against the XLS-owned runtime archive. That successor path landed through #964 and the later rollout PRs.

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