Files
sx/examples/platform/1654-platform-asm-global-comptime-call.sx
agra 66bdc70bf1 test: group examples into per-category folders
Move examples/*.sx and their expected/ snapshots into per-category
subfolders (examples/<category>/...). Folder = leading filename token,
with ffi-objc/ffi-jni kept whole; filenames are unchanged. The corpus
runner and LSP sweep now discover each category's expected/ dir, while
issues/ stays flat. Example 1058's repo-root-relative companion import
is made file-relative. Path strings embedded in 164 snapshots were
regenerated (path-only changes). Test-layout docs in CLAUDE.md updated.
2026-06-21 14:41:34 +03:00

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; }