mirror of
https://github.com/Nexoniarz/Finch.git
synced 2026-11-03 08:54:25 +00:00
boot/ is src/ now. The C++ compiler and CMake are gone from this branch (they are on before-bootstrap). bootstrap/build.sh builds the compiler from bootstrap/<system>.ll -- the compiler's own LLVM IR -- then builds it with itself and checks the two come out identical. bootstrap/build.sh seed writes the seed anew. The driver is complete: the runtime is compiled once and kept in ~/.cache/finch; a program's own C files, .o and .a files and frameworks link along; a linker failure is read and answered with link "lib" or the library that is missing. The old tests/fail diagnostics are all in again (a missing import, a str compared with null, 'write just the library's name', a map key that is a float, non-ASCII names, ...). tests/run.sh is the one test runner: programs, refusals, -g builds and the shared library. 106 passed.
18 lines
715 B
Shell
Executable file
18 lines
715 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}
|
|
export FINCH_RT=${FINCH_RT:-$PWD/../../runtime/finch_rt.c}
|
|
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
|