Files
scriptc/examples/native-object
Chris Tate 97a9257fa5 Inline string retains and dynamic value reference counting in release builds
Release builds now emit the string retain and the dyn retain and release
fast paths inline. The dyn release decides the cases scr_dyn_release
decides by kind and calls scr_dyn_release_survivor for capsules and
handles. String releases and the other families stay runtime calls, as
string-heavy programs have many release sites. The speed posture keeps
every fast path and gains the dyn release. The runtime ABI version moves
to 21 because program objects call the new runtime entry point.
2026-10-15 05:15:33 -05:00
..
2026-09-29 20:54:09 -05:00

External program object

This macOS arm64 example links a scriptc program object, a small C FFI implementation, and the exact installed precompiled runtime pack. It uses no scriptc cache path.

$ clang -target arm64-apple-macosx14.0.0 -O2 -c native.c -o native.o
$ scriptc build main.ts --ffi ffi.json --print=native-link-info -o app.o > link-info.json
$ node link.mjs cc link-info.json app-cc
$ ./app-cc
42
$ node link.mjs ld link-info.json app-ld
$ ./app-ld
42

cc uses the C compiler as a linker driver. ld links the same precompiled runtime objects directly with the selected Apple SDK. The object defines main; it is a complete program object, not a library to load into another process. Use scriptc build --lib --profile ... for a host-callable static library.

The external object ABI is experimental. Always consume the runtime pack at the exact runtime_pack.version reported by the same scriptc installation. The object requires scr_runtime_abi_v21, so a mismatched runtime fails during the link instead of starting with an incompatible ABI.