test(asm): pin loud failure of #run into a module-asm symbol
Adds examples/1654-platform-asm-global-comptime-call.sx — the comptime
guard. A module-asm symbol only exists after assemble+link; the comptime
interpreter resolves extern calls via host dlsym, where it's absent, so
`#run my_add(…)` fails with a clear diagnostic ("comptime extern call:
symbol not found via dlsym") rather than misfiring. Runtime calls work
(1648/1653). dlsym-miss precedes asm assembly, so arch-independent — no
.build. Locks current behavior; no compiler change.
This commit is contained in:
22
examples/1654-platform-asm-global-comptime-call.sx
Normal file
22
examples/1654-platform-asm-global-comptime-call.sx
Normal file
@@ -0,0 +1,22 @@
|
||||
// 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 interpreter 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; }
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -0,0 +1 @@
|
||||
error: comptime init of 'COMPUTED' failed: CannotEvalComptime (op=call: comptime extern call: symbol not found via dlsym (target-specific binding called at compile time?))
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
Reference in New Issue
Block a user