Skip to content

LLVM-AOT object mode + JIT-AOT test rail#3534

Merged
borisbat merged 4 commits into
masterfrom
llvm-aot-object
Jul 24, 2026
Merged

LLVM-AOT object mode + JIT-AOT test rail#3534
borisbat merged 4 commits into
masterfrom
llvm-aot-object

Conversation

@aleksisch

Copy link
Copy Markdown
Collaborator

Summary

Adds an LLVM-AOT object mode to the dasLLVM backend: the JIT emitter can now write self-registering native .o objects for static linking into a host binary, and a JIT-AOT test rail that binds those objects and runs the test bodies jitted.

Commits

  1. LLVM-AOT object mode: emit self-registering .o for static linking--aot-object emits native objects that self-register into the host binary (incl. an empty object for fully-no_aot modules). Adds the opt-in object-mode self-test target (not wired into CI).
  2. JIT-AOT host binding mode + green test_jit_aot suite — compile test bodies jit-aware + aot so emitted objects bind as SimNode_Jit with run_jit no-op'd; adds the test_jit_aot harness with AOT-object glob re-resolution, resolves Func-value and cross-module das call/ctor targets, and falls back to interpret-on-miss for anything unresolved. Brings test_jit_aot to a green 286/286.

Notes

  • New targets (test_jit_aot / run_tests_jit_aot, object-mode self-test) are opt-in, not wired into any CI lane.
  • Base is current origin/master (0 commits behind).

🤖 Generated with Claude Code

@aleksisch
aleksisch force-pushed the llvm-aot-object branch 7 times, most recently from 9905425 to 954edbc Compare July 21, 2026 14:46
@borisbat
borisbat requested a review from Copilot July 21, 2026 16:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds an LLVM-backed “offline AOT object” emission mode to the dasLLVM JIT pipeline, enabling generation of self-registering native .o files for static linking into a host binary, and introduces an opt-in test_jit_aot harness to exercise the object-binding path.

Changes:

  • Extend JIT CLI/policies to support --aot-object emission (portable/generic CPU by default, with --aot-object-generic=false for host-featured builds).
  • Add runtime plumbing to register LLVM-AOT objects into the AOT library and bind them as SimNode_Jit during Program::linkCppAot, plus a deferred “glob re-resolution” pass.
  • Add opt-in CMake targets and runners for test_jit_aot / run_tests_jit_aot.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
utils/jit/main.das Adds --aot-object flag wiring and output naming for .o emission.
tests/CMakeLists.txt Adds run_tests_jit_aot opt-in target to run the new harness.
tests/aot/CMakeLists.txt Defines LLVM-only test_jit_aot target and corpus selection/excludes.
src/builtin/module_jit.cpp Adds LLVM-AOT helpers (makeAotJitNode, das_aot_get_func_by_mnh) and improves null-target diagnostics in JIT call helpers.
src/builtin/module_builtin_rtti.cpp Exposes jit_emit_object in RTTI/bindings.
src/ast/ast.cpp Adds process-global registration for LLVM-AOT objects and deferred globinit callbacks.
src/ast/ast_simulate.cpp Extends linkCppAot to support LLVM-AOT partial binding and post-link glob re-resolution.
modules/dasLLVM/daslib/llvm_jit.das Adds emit_aot_object flag and object-mode ctor emission (function registration + globinit registration).
modules/dasLLVM/daslib/llvm_jit_run.das Implements object-emission path, target selection (aot_object_generic), and object-only teardown.
modules/dasLLVM/daslib/llvm_jit_common.das Adds object-only emitter, and object-mode behavior for builtin-accessor/table globals.
modules/dasLLVM/daslib/llvm_jit_cli.das Adds --aot-object-generic CLI option.
modules/dasLLVM/daslib/llvm_exe.das Adds object-mode globinit constructor generation and host-context Func-value resolution path.
include/daScript/simulate/aot_library.h Extends AotFactory to support JIT-backed AOT entries and declares LLVM-AOT helper hooks.
include/daScript/ast/ast.h Adds jit_emit_object policy flag.
doc/source/stdlib/handmade/structure_annotation-rtti-CodeOfPolicies.rst Documents the new JIT offline AOT object mode policy.
CMakeLists.txt Adds DAS_JIT_AOT_LIB macro and includes notes about the new LLVM-only test harness.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/ast/ast.cpp Outdated
Comment on lines +52 to +56
// Called from each object's static ctor (safe: just records the pointer). The
// callback runs later, from linkCppAot, with the linking Context.
extern "C" void das_aot_register_globinit ( void (*fn)(Context*) ) {
jitGlobInits().push_back(fn);
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This global was removed at all

Comment thread src/ast/ast_simulate.cpp
Comment on lines +4174 to +4178
if ( fn.code->rtti_node_isJit() ) {
// LLVM-AOT: interpret the SimNode_Jit wrapper (aot=false),
// mirroring das_instrument_jit; it has no aotFunction.
fn.jit = true;
} else {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

There's no way it will be true.

@aleksisch
aleksisch force-pushed the llvm-aot-object branch 20 times, most recently from 749063b to 1b99d4e Compare July 23, 2026 21:12
@aleksisch
aleksisch force-pushed the llvm-aot-object branch 4 times, most recently from a2c9db1 to 559875e Compare July 23, 2026 21:37
Replace the ~99 repeated line in tests/CMakeLists.txt
with loops (two over uniform suites, one data-driven over
the irregular ones). Loops skip empty file lists.

Move each module's AOT-able source list into its own
modules/<M>/CMakeLists.txt as a reusable <MODULE>_AOT_FILES
var. tests/aot bridges those to the suite vars and drops the
per-module IF guards on the module-lib rows (test-body rows keep theirs).
Trim STYLE014 (>3-line comment blocks) and STYLE015 (>1-line comments in private
defs) throughout llvm_exe.das, and combine one adjacent-guard pair (STYLE016).
Emit a native .o over the whole used function set with a load ctor that
registers each function into the AOT library via das_aot_register, for
static linking into a host binary. Program::linkCppAot binds each as a
SimNode_Jit and hard-errors on any miss -- same contract as C++ AOT
(whole-program emission makes hard-error viable).

Wire the run_tests_llvm_aot rail over tests/: whole-program per-test
corpus (TEST_AOT_ALL_DAS + jit_tests), msl/metal lattice suites excluded
(the LLVM JIT declines fp16/lattice arithmetic, so those interpret and
emit no object). Rename DAS_JIT_AOT_LIB -> DAS_LLVM_AOT_LIB; ignore
_llvm_aot_generated/.
@borisbat
borisbat merged commit ffb6f0e into master Jul 24, 2026
38 checks passed
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.

3 participants