Remove the comptime_flat/need_vm gate and the vm_result-orelse-legacy fallback from emit_llvm.zig (runComptimeSideEffects + emitGlobals const-init) and comptime.zig (runComptimeTypeFunc). The comptime VM now always runs; a bail is always a build-gating diagnostic, never a fallback. Delete the now-moot entryNeedsVm. runComptimeSideEffects drops the Interpreter entirely (VM writes #run output direct to fd 1); emitGlobals keeps a fresh interp_inst only as the valueToLLVMConst materialization context (the regToValue bridge, removed with interp.zig in a later step). #insert (evalComptimeString) still routes through the legacy interp — deferred until interp.zig deletion. Reconcile 1654: the comptime asm-global #run now reports the VM's clean dlsym bail instead of the legacy CannotEvalComptime wrapper (exit still 1). 501/501 unit + 706/0 corpus.
23 lines
888 B
Plaintext
23 lines
888 B
Plaintext
// ASM stream — calling a global-asm symbol at COMPILE TIME (`#run`) fails loud.
|
|
// A module-asm symbol only exists once the module is assembled+linked; the
|
|
// comptime VM resolves `extern` calls via host `dlsym` (RTLD_DEFAULT),
|
|
// where the symbol is absent — so `#run my_add(…)` cannot evaluate and reports a
|
|
// clear diagnostic instead of silently misfiring. (Calling the same symbol at
|
|
// RUNTIME works under both JIT and AOT — see 1648/1653.) The failure is at
|
|
// dlsym resolution, before any asm is assembled, so it is arch-independent —
|
|
// no `.build` target needed. Regression guard for the comptime boundary.
|
|
asm {
|
|
#string ASM
|
|
.global _my_add
|
|
_my_add:
|
|
add x0, x0, x1
|
|
ret
|
|
ASM,
|
|
};
|
|
|
|
my_add :: (a: i64, b: i64) -> i64 extern;
|
|
|
|
COMPUTED :: #run my_add(40, 2); // compile-time call — module-asm symbol not yet linked
|
|
|
|
main :: () -> i64 { return COMPUTED; }
|