mirror of
https://github.com/Nexoniarz/Finch.git
synced 2026-11-03 08:54:25 +00:00
export fn name(...) is a C function of a library; build --shared makes lib<name>.so with no main and a finch_module_on_fatal(handler) the host can take runtime errors over with. Ported from the embed work (the runtime, its test and the docs are that work's; the compiler side is new). The driver reads FINCH_PATH (more module folders), FINCH_RT (the runtime's file) and FINCH_CC (the clang). tests/boot.sh also runs tests/shared.sh with the compiler under test. 41 passed.
17 lines
656 B
Shell
Executable file
17 lines
656 B
Shell
Executable file
#!/bin/sh
|
|
# finch build --shared: a library a C program loads, calls by name, and that hands runtime
|
|
# errors to the host instead of exiting.
|
|
set -e
|
|
cd "$(dirname "$0")/shared"
|
|
FINCH=${FINCH:-../../build/finch}
|
|
tmp=$(mktemp -d)
|
|
trap 'rm -rf "$tmp"' EXIT
|
|
"$FINCH" build mod.fch --shared -o "$tmp/libmod.so"
|
|
${CC:-cc} host.c -rdynamic -o "$tmp/host" -ldl
|
|
out=$("$tmp/host" "$tmp/libmod.so")
|
|
expected='add 42
|
|
even 1 0
|
|
host_print: hello Rakya
|
|
caught: mod.fch:17: runtime error: index 7 is out of range (the length is 3)
|
|
still alive'
|
|
if [ "$out" = "$expected" ]; then echo "shared library: passed"; else printf 'shared library: FAILED\n%s\n' "$out"; exit 1; fi
|