#!/usr/bin/env bash # Step 5b on its own: the SIGSEGV question, embedded and standalone side by # side. The standalone build is the control -- if OCaml behaves the same in a # plain ocamlopt executable, then embedding changed nothing about signals. set -u here=$(cd "$(dirname "$0")" && pwd) cd "$here" || exit 1 OCAMLLIB=$(ocamlopt -where) SYSLIBS="-lm -lpthread -ldl -lzstd" echo "=== 5b-embedded: caml_startup called from a C main() ===" ocamlfind ocamlopt -package unix -linkpkg -output-complete-obj \ -o embed5b.o sig_ml.ml || exit 1 clang -I"$OCAMLLIB" harness5b.c embed5b.o -o spike5b $SYSLIBS || exit 1 ./spike5b; echo "exit: $?" echo echo "=== 5b-standalone: the same OCaml, as a plain ocamlopt executable ===" # The control. Same stubs, but OCaml owns main(). clang -c -I"$OCAMLLIB" -DSPIKE_NO_MAIN harness5b.c -o stubs5b.o || exit 1 ocamlfind ocamlopt -package unix -linkpkg -o spike5b_std sig_ml.ml stubs5b.o \ -cclib -lzstd || exit 1 ./spike5b_std; echo "exit: $?"