Skip to content

Add cross compilation support#5

Merged
cs01 merged 3 commits intomainfrom
cross-compile
Feb 19, 2026
Merged

Add cross compilation support#5
cs01 merged 3 commits intomainfrom
cross-compile

Conversation

@cs01
Copy link
Copy Markdown
Owner

@cs01 cs01 commented Feb 19, 2026

add support for cross compilation (eg from mac -> linux or linux -> mac)

@cs01 cs01 changed the title Cross compile Add cross compilation support Feb 19, 2026
@cs01 cs01 merged commit 6ff0e28 into main Feb 19, 2026
11 checks passed
@cs01 cs01 deleted the cross-compile branch February 19, 2026 04:34
cs01 added a commit that referenced this pull request Feb 19, 2026
This was referenced Mar 19, 2026
cs01 added a commit that referenced this pull request Apr 19, 2026
…DE.md rule #5)

stage1 self-compiled binary crashed on Array.isArray because inserting a
new field mid-class shifted GEP indices for subsequent fields (most
notably lastInlineLambdaEnvPtr in BaseGenerator, although the same rule
applies to LLVMGenerator's own fields). moving trampolineEmitter to the
END of both IGeneratorContext and LLVMGenerator's field lists restores
the expected struct layout and unblocks stage2 self-hosting.
cs01 added a commit that referenced this pull request Apr 19, 2026
…PR2 of closure-cabi series) (#564)

* feat(runtime): wire closures to child_process.spawn via trampolines, remove spawnTagged (pr2 of closure-cabi series)

arrow-function callbacks now work with child_process.spawn(). captured
variables are lifted into a gc-allocated env struct, registered with the
trampoline slot table (pr1 infrastructure), and dispatched through a
per-shape trampoline that the c bridge invokes after recovering env via
cs_tramp_get(handle).

this removes a long-standing constraint that spawn callbacks had to be
named function references. multi-session demuxing (formerly spawnTagged,
which is hard-removed here) is now a natural capture:

  child_process.spawn(cmd, args,
    (d) => onOut(sessionId, d),
    (d) => onErr(sessionId, d),
    (c) => onExit(sessionId, c))

changes:
- c_bridges/child-process-spawn.c: cs_spawn_v2 takes per-callback
  {fn_ptr, tramp_handle} pairs. handle == -1 keeps the legacy bare-fn
  path; handle >= 0 routes through the trampoline. slots freed in the
  pipe-close / post-exit callbacks.
- src/codegen/stdlib/child-process.ts: spawn() accepts arrow functions
  alongside variable refs; generates trampoline env + cs_tramp_alloc.
- src/codegen/infrastructure/trampoline-emitter.ts: instantiated on the
  llvm generator, emitAll() called after lifted lambdas. stores user fn
  as i8* to sidestep the store-type validator.
- chadscript.d.ts, llvm-declarations.ts: spawnTagged and cs_spawn_tagged
  removed. spawn signatures updated to document closure support.
- src/codegen/expressions/method-calls/named-object-dispatch.ts: emits a
  clear compile error if anyone still calls spawnTagged.
- tests/fixtures/closures-cabi/: three new fixtures cover single-session
  closure capture, multi-session demux, and named-fn back-compat.
- tests/fixtures/builtins/cp-spawn-tagged.ts removed (closure form
  subsumes it).

* fix(codegen): move trampolineEmitter to end of class field list (CLAUDE.md rule #5)

stage1 self-compiled binary crashed on Array.isArray because inserting a
new field mid-class shifted GEP indices for subsequent fields (most
notably lastInlineLambdaEnvPtr in BaseGenerator, although the same rule
applies to LLVMGenerator's own fields). moving trampolineEmitter to the
END of both IGeneratorContext and LLVMGenerator's field lists restores
the expected struct layout and unblocks stage2 self-hosting.

---------

Co-authored-by: cs01 <cs01@users.noreply.github.com>
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