docs(asm): correct stale 'AOT only' module-asm prose (JIT works)
sx run compiles to an object before ORC relocation, so module asm is assembled in and its symbols resolve at JIT main execution. Corrected the Phase F note, Current state, and Next step; the only real boundary is a compile-time #run into a module-asm symbol (loud dlsym-miss).
This commit is contained in:
@@ -76,12 +76,16 @@ three `Node.Data` switches as `asm_expr` (`sema.zig` ×2, `semantic_diagnostics.
|
||||
`lowerMainAndComptime` captures each template (the dead `lowerDecls` is NOT the
|
||||
top-level pass — `lowerRoot` Pass 2 uses `lowerMainAndComptime`); `emit_llvm.zig`'s
|
||||
`emit()` appends each via `LLVMAppendModuleInlineAsm` (source order). Verified
|
||||
end-to-end: an aarch64 `_my_add` global routine called via `extern` returns 42 —
|
||||
**AOT only** (the ORC JIT doesn't link module-asm symbols, so `sx run` is wrong;
|
||||
the design ties global-asm symbols to the final linked binary). Locked with
|
||||
`examples/1648-platform-asm-global.sx` (`.build { "aot": true, "target": "macos" }`
|
||||
→ AOT build+run on aarch64, ir-only elsewhere). `zig build test` green (656
|
||||
corpus, 446 unit). Files: `src/ast.zig`, `src/parser.zig`, `src/sema.zig`,
|
||||
end-to-end: an aarch64 `_my_add` global routine called via `extern` returns 42.
|
||||
Locked with `examples/1648-platform-asm-global.sx`
|
||||
(`.build { "aot": true, "target": "macos" }` → AOT build+run on aarch64, ir-only
|
||||
elsewhere). `zig build test` green (656 corpus, 446 unit). **(Correction, later:
|
||||
module asm ALSO runs under the JIT — `sx run` compiles to an in-memory object,
|
||||
the integrated assembler assembles the `module asm` into it, ORC relocates and
|
||||
runs it, so the symbol is resolvable at JIT main execution. The original "AOT
|
||||
only" note was wrong; see 1653 for the JIT sibling. The genuine boundary is a
|
||||
COMPILE-TIME `#run` call into a module-asm symbol, which fails loud via host
|
||||
dlsym-miss — see 1654.)** Files: `src/ast.zig`, `src/parser.zig`, `src/sema.zig`,
|
||||
`src/ir/semantic_diagnostics.zig`, `src/ir/module.zig`, `src/ir/lower/decl.zig`,
|
||||
`src/ir/emit_llvm.zig`, `examples/1648-*`.
|
||||
|
||||
@@ -214,16 +218,15 @@ pipeline: lex (A.0) → parse (A.1) → validate (B.0/B.1 + `%[name]` check) →
|
||||
(C.0) → lower-builds-op + LLVM emit + JIT asm-parser init (C.1/D) → multi-output
|
||||
tuples (E). Register-class + register-pinned operands, inputs, clobbers, `#string`
|
||||
multi-instruction templates, `%[name]`/`%%` rewriting, and the §II.5 auto-naming
|
||||
rule all work and execute on the host JIT. Global `asm { … }` (Phase F) works AOT (call-into-asm
|
||||
via lib-less `extern`). All three `-> @place` output forms now work and execute
|
||||
rule all work and execute on the host JIT. Global `asm { … }` (Phase F) works via
|
||||
lib-less `extern` under BOTH the JIT (`sx run` → 1653) and AOT (1648) — `sx run`
|
||||
compiles to an object, so the integrated assembler bakes the `module asm` symbol
|
||||
in and ORC resolves it. All three `-> @place` output forms now work and execute
|
||||
on aarch64: **write-through** `=` (Phase 2), **read-write** `+` (tied input), and
|
||||
**indirect-memory** `=*m` (pointer arg + `elementtype`, asm writes through it).
|
||||
**Inline assembly is now feature-complete — no substantive features remain.** The
|
||||
x86_64 syscall-write ir-only example is DONE (1651). Only polish follow-ups
|
||||
remain: the comptime-call guard for global asm (`#run` into a module-asm symbol
|
||||
should fail loud via dlsym-miss — pin a test) and a JIT-vs-global-asm note
|
||||
(`sx run` silently mishandles module-asm symbols; AOT is correct). `readme.md`
|
||||
now has an "Inline Assembly" section.
|
||||
x86_64 syscall-write ir-only example is DONE (1651). Global asm runs under both
|
||||
JIT (1653) and AOT (1648). `readme.md` now has an "Inline Assembly" section.
|
||||
|
||||
Known orthogonal bug: **issue 0137** — `sx run` on a program with no `main`
|
||||
segfaults (`src/target.zig:256-273`, unguarded JIT entry lookup). Pre-existing,
|
||||
@@ -242,12 +245,17 @@ Phase E–F feasibility already confirmed against the live tree
|
||||
read-write (`+`), and indirect-memory (`=*m`). The x86_64 syscall-write ir-only
|
||||
example (1651) and the output-to-`const` rejection (issue 0138) are also done.
|
||||
|
||||
Global asm runs under BOTH the JIT (`sx run` → object → ORC; 1653) and AOT (1648)
|
||||
— the earlier "AOT only / `sx run` mishandles module-asm" note was stale and has
|
||||
been corrected. The one genuine boundary is a COMPILE-TIME `#run` into a
|
||||
module-asm symbol: the interpreter resolves externs via host dlsym, the symbol
|
||||
isn't linked yet, so it already fails loud (`comptime extern call: symbol not
|
||||
found via dlsym`) — pinned by 1654.
|
||||
|
||||
Remaining work, all **polish** (optional):
|
||||
- **Global-asm comptime-call guard**: pin a test that `#run` into a module-asm
|
||||
symbol fails loud via the dlsym-miss path (module-asm symbols don't exist until
|
||||
the final link).
|
||||
- **`sx run` module-asm**: make it *error* (not silently mishandle) a module-asm
|
||||
symbol — the ORC JIT doesn't link `module asm`, so AOT is the only correct path.
|
||||
- None substantive. Possible niceties: tighten the `#run`-into-module-asm error
|
||||
text to name module-asm specifically; broaden clobber validation to a checked
|
||||
per-arch enum (design doc Phase 4).
|
||||
|
||||
Orthogonal: **issue 0137** (no-`main` JIT segfault).
|
||||
|
||||
@@ -333,6 +341,12 @@ Orthogonal: **issue 0137** (no-`main` segfault).
|
||||
commits (cadence): 1652 locked the rejection, then flipped to a runnable aarch64
|
||||
example. **Inline asm now feature-complete.** `zig build test` green (661 corpus,
|
||||
446 unit).
|
||||
- (jit) explored "asm in JIT": found it ALREADY works — `sx run` emits an
|
||||
in-memory object (integrated assembler bakes in both in-function inline asm and
|
||||
`module asm`), then ORC relocates+runs it. The stale "AOT only / `sx run`
|
||||
mishandles module-asm" checkpoint prose was corrected. Locked global-asm-under-
|
||||
JIT with `examples/1653-platform-asm-global-jit.sx` (`{ "target": "macos" }`, no
|
||||
aot, → 42). `zig build test` green (662 corpus, 446 unit).
|
||||
|
||||
## Known issues
|
||||
- **0138** — RESOLVED. `@const` (address-of a `::` comptime constant) yielded a
|
||||
|
||||
Reference in New Issue
Block a user