Add a script generating static builds

We have an obvious limitation: static builds won't support plugins. We
could resort to the classic method and do normal builds but on an old
distrib to dodge compatibility issues.

That would still be compatible with statically linking the more specific
libs, like e.g. z3.
This commit is contained in:
Louis Gesbert 2022-08-03 15:03:33 +02:00
parent 289975ebe8
commit bc8eda581c
3 changed files with 61 additions and 0 deletions

39
build_release.sh Executable file
View File

@ -0,0 +1,39 @@
#! /usr/bin/env sh
set -ue
CUSTOM_LINKING_CATALA_Z3="\
(-cclib -static
-cclib -no-pie
-noautolink
-cclib -L/home/ocaml/.opam/z3/lib/stublibs
-cclib -lz3ml-static
-cclib -lz3
-cclib -lstdc++
-cclib -lthreadsnat
-cclib -lzarith
-cclib -lgmp
-cclib -lcamlstr
-cclib -lANSITerminal_stubs
-cclib -lunix)"
CUSTOM_LINKING_CATALA_NOZ3="(-cclib -static -cclib -no-pie)"
CUSTOM_LINKING_CLERK="(-cclib -static -cclib -no-pie)"
git archive HEAD --prefix catala/ | \
docker run --rm -i registry.gitlab.inria.fr/lgesbert/catala-ci-images:ocaml.4.14-z3static.4.10.1 \
sh -uexc \
'{ tar x &&
cd catala &&
echo "'"${CUSTOM_LINKING_CATALA_Z3}"'" >compiler/custom_linking.sexp &&
echo "'"${CUSTOM_LINKING_CLERK}"'" >build_system/custom_linking.sexp &&
opam --cli=2.1 install ./ninja_utils.opam ./clerk.opam ./catala.opam --destdir ../release.out/ &&
mv ../release.out/bin/catala ../release.out/bin/catala-z3 &&
opam --cli=2.1 remove z3 catala &&
echo "'"${CUSTOM_LINKING_CATALA_NOZ3}"'" >compiler/custom_linking.sexp &&
opam --cli=2.1 install ./catala.opam --destdir ../release.out/ &&
rm -f ../release.out/bin/catala_web_interpreter;
strip ../release.out/bin/*;
} >&2 && tar c -hC ../release.out/bin .' |
tar vx

View File

@ -16,9 +16,20 @@
ANSITerminal)
(modules clerk_driver))
(rule
(target custom_linking.sexp)
(mode fallback)
(action
(with-stdout-to
%{target}
(echo "()"))))
(executable
(name clerk)
(public_name clerk)
(flags
(:standard
(:include custom_linking.sexp)))
(libraries clerk.driver)
(modules clerk)
(package clerk))

View File

@ -28,9 +28,20 @@
catala.runtime_ocaml
catala.runtime_jsoo))
(rule
(target custom_linking.sexp)
(mode fallback)
(action
(with-stdout-to
%{target}
(echo "()"))))
(executable
(name catala)
(modes native js)
(flags
(:standard
(:include custom_linking.sexp)))
(package catala)
(modules catala)
(public_name catala)