From bc8eda581cfb2350a4d0c379c865d263677796f7 Mon Sep 17 00:00:00 2001 From: Louis Gesbert Date: Wed, 3 Aug 2022 15:03:33 +0200 Subject: [PATCH] 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. --- build_release.sh | 39 +++++++++++++++++++++++++++++++++++++++ build_system/dune | 11 +++++++++++ compiler/dune | 11 +++++++++++ 3 files changed, 61 insertions(+) create mode 100755 build_release.sh diff --git a/build_release.sh b/build_release.sh new file mode 100755 index 00000000..9601a7f1 --- /dev/null +++ b/build_release.sh @@ -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 diff --git a/build_system/dune b/build_system/dune index 9fe70d05..c1ffbcba 100644 --- a/build_system/dune +++ b/build_system/dune @@ -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)) diff --git a/compiler/dune b/compiler/dune index ee0b9d50..3fdc3105 100644 --- a/compiler/dune +++ b/compiler/dune @@ -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)