Documentation channel: current development main at compiler checkpoint 1d7e15e. The latest tagged release is v0.0.3; pages identify APIs that are not yet released.

Linking & FFI

Strut treats static and dynamic linking as equally legitimate deployment choices. A single self-contained executable is useful, but applications should not be forced to absorb every library into every binary.

Link a native library

Use a library name together with a search path, or pass an exact native library path. The default mode lets the platform linker choose its normal behaviour.

strut app.p --lib-path ./native --lib example

Choose static or dynamic per library

Strut can request a mode for each native dependency, which is the basis for mixed-link builds.

strut app.p --lib-path ./native --static-lib core --dynamic-lib plugin

Native libraries

The FFI/linker layer supports conventional C ABI declarations and native static/dynamic libraries across Linux, macOS, and Windows. Calls into C are explicit unsafe boundaries.

Linux:   libexample.a / libexample.so
macOS:   libexample.a / libexample.dylib
Windows: example.lib / example.dll

On platforms where a linker cannot force static selection by library name, pass the exact static archive path instead. Strut does not silently substitute a different link mode.

JSONIC, libcurl, and OpenSSL are the currently approved embedded third-party dependencies. Additional vendored libraries require an explicit design decision.

C ABI declarations

Declare a C ABI function with extern "C". Primitive values, Strut structs with ABI-compatible layouts, and ptr<T> map directly onto native C-compatible representations.

extern "C" function c_add(int a, int b) -> int;

function main() -> int {
    unsafe {
        print(c_add(20, 22));
    }
    return 0;
}

The compiler rejects calls to an extern "C" function outside an unsafe block so native code cannot silently bypass Strut's safety model.

Final executable mode

Choose whether the final executable should use the platform's normal dynamic runtime model or request a fully static link where the operating system/toolchain supports one.

strut app.p --dynamic
strut app.p --static

Linux toolchains can commonly produce fully static executables when all required static libraries are installed. The default macOS toolchain does not provide a fully static system executable model, so Strut reports that request instead of silently producing something else. On MSVC, the static/dynamic final mode selects the corresponding C/C++ runtime linkage.

Release linking

--release enables optimisation and asks the platform linker to discard unreachable sections and strip nonessential symbols where supported.

strut app.p --release --dynamic
strut app.p --release --static-lib core --dynamic-lib plugin

Runtime library lookup

Dynamically linked libraries are located by the operating system loader. Use the platform's normal install names/search paths (for example rpath/install-name configuration or system/package installation) rather than assuming Strut bundles arbitrary shared libraries automatically.