diff --git a/.ci-macosx.sh b/.ci-macosx.sh index ea6d44cb1..b793b0d7a 100644 --- a/.ci-macosx.sh +++ b/.ci-macosx.sh @@ -6,7 +6,7 @@ brew update brew install pkg-config brew install opam brew install libev -opam init -y --compiler=4.05.0 +opam init -y --compiler=4.12.0 eval $(opam env) opam install -y -j 2 . --deps-only --locked diff --git a/.github/workflows/static-builds.yml b/.github/workflows/static-builds.yml index 02b1c868c..a87fffebd 100644 --- a/.github/workflows/static-builds.yml +++ b/.github/workflows/static-builds.yml @@ -46,20 +46,16 @@ jobs: sw_vers system_profiler SPSoftwareDataType uname -a - # Need unreleased 2.1.0~rc - # - name: Retrieve opam - # run: | - # mkdir "$HOME/bin" - # wget https://github.com/ocaml/opam/releases/download/2.1.0-beta2/opam-2.1.0-beta2-x86_64-macos -O $HOME/bin/opam - # chmod a+x $HOME/bin/opam - # echo "$HOME/bin" >> $GITHUB_PATH - - name: Install latest opam + - name: Retrieve opam run: | - brew install opam --HEAD + mkdir "$HOME/bin" + wget https://github.com/ocaml/opam/releases/download/2.1.0/opam-2.1.0-x86_64-macos -O $HOME/bin/opam + chmod a+x $HOME/bin/opam + echo "$HOME/bin" >> $GITHUB_PATH - name: Prepare build environment run: | opam init -a --bare - opam switch create . ocaml-base-compiler 'dune<2' --deps-only + opam switch create . ocaml-base-compiler --deps-only - name: Build the binaries run: | opam exec -- make LINKING_MODE=static diff --git a/Dockerfile b/Dockerfile index c9e6079b7..00e6fd143 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ocaml/opam2:alpine as compilation +FROM ocaml/opam:alpine-3.13-ocaml-4.12 as compilation LABEL Description="learn-ocaml building" Vendor="OCamlPro" WORKDIR /home/opam/learn-ocaml @@ -42,7 +42,7 @@ WORKDIR /learnocaml COPY --from=compilation /home/opam/install-prefix/bin/learn-ocaml-client /usr/bin -ENTRYPOINT ["dumb-init","learn-ocaml-client"] +ENTRYPOINT ["dumb-init","/usr/bin/learn-ocaml-client"] LABEL org.opencontainers.image.title="learn-ocaml-client" LABEL org.opencontainers.image.description="learn-ocaml command-line client" @@ -68,7 +68,7 @@ WORKDIR /home/learn-ocaml COPY --from=compilation /home/opam/install-prefix /usr -ENTRYPOINT ["dumb-init","learn-ocaml","--sync-dir=/sync","--repo=/repository"] +ENTRYPOINT ["dumb-init","/usr/bin∕learn-ocaml","--sync-dir=/sync","--repo=/repository"] CMD ["build","serve"] LABEL org.opencontainers.image.title="learn-ocaml" diff --git a/Dockerfile.test-client b/Dockerfile.test-client index ee7c49a13..32345200a 100644 --- a/Dockerfile.test-client +++ b/Dockerfile.test-client @@ -1,7 +1,7 @@ # This Dockerfile is useful for testing purposes # to ensure learn-ocaml-client can be built alone from learn-ocaml-client.opam -FROM ocaml/opam:alpine-3.13-ocaml-4.05 as compilation +FROM ocaml/opam:alpine-3.13-ocaml-4.12 as compilation LABEL Description="learn-ocaml building" Vendor="OCamlPro" WORKDIR learn-ocaml @@ -13,7 +13,7 @@ RUN sudo chown -R opam:nogroup . ENV OPAMYES true RUN echo 'archive-mirrors: [ "https://opam.ocaml.org/cache" ]' >> ~/.opam/config \ && opam repository set-url default http://opam.ocaml.org \ - && opam switch 4.05 \ + && opam switch 4.12 \ && echo 'pre-session-commands: [ "sudo" "apk" "add" depexts ]' >> ~/.opam/config \ && opam pin add -n -y -k path learn-ocaml-client . \ && opam install learn-ocaml-client --deps-only diff --git a/Makefile b/Makefile index 22faba759..096b20344 100644 --- a/Makefile +++ b/Makefile @@ -95,7 +95,7 @@ travis: # From https://stackoverflow.com/questions/21053657/how-to-run-travis-ci static-binaries: ./scripts/static-build.sh -BINARIES = src/main/learnocaml_client.bc src/main/learnocaml_main.bc src/main/learnocaml_server_main.exe +BINARIES = src/main/learnocaml_client.exe src/main/learnocaml_main.exe src/main/learnocaml_server_main.exe .PHONY: detect-libs detect-libs: @@ -104,6 +104,7 @@ detect-libs: baseid="detect-libs.$$$$"; echo ...; \ $(MAKE) LINKING_MODE=dynamic OCAMLPARAM="_,verbose=1" > $$baseid.log 2>&1; \ for bin in $(BINARIES); do \ + rm -f "_build/default/$$bin"; \ base=$${bin#src/main/}; base=$${base%.*}; \ grep -e "'$$bin'" $$baseid.log > $$baseid.$$base.log; \ printf "%s: " "$$base"; \ diff --git a/learn-ocaml-client.opam.locked b/learn-ocaml-client.opam.locked new file mode 100644 index 000000000..e6c67f20b --- /dev/null +++ b/learn-ocaml-client.opam.locked @@ -0,0 +1,107 @@ +opam-version: "2.0" +name: "learn-ocaml-client" +version: "0.12" +synopsis: "The learn-ocaml client" +description: """\ +This contains the binaries to interact with the learn-ocaml +platform from the command line.""" +maintainer: "Yann Régis-Gianas" +authors: [ + "Benjamin Canou (OCamlPro)" + "Çağdaş Bozman (OCamlPro)" + "Grégoire Henry (OCamlPro)" + "Louis Gesbert (OCamlPro)" + "Pierrick Couderc (OCamlPro)" +] +license: "MIT" +homepage: "https://github.com/ocaml-sf/learn-ocaml" +bug-reports: "https://github.com/ocaml-sf/learn-ocaml/issues" +depends: [ + "angstrom" {= "0.15.0"} + "asak" {= "0.3"} + "astring" {= "0.8.5"} + "base" {= "v0.14.1"} + "base-bigarray" {= "base"} + "base-bytes" {= "base"} + "base-threads" {= "base"} + "base-unix" {= "base"} + "base64" {= "3.5.0"} + "bigarray-compat" {= "1.0.0"} + "bigstringaf" {= "0.8.0"} + "biniou" {= "1.2.1"} + "cmdliner" {= "1.0.4"} + "cohttp" {= "4.0.0"} + "cohttp-lwt" {= "4.0.0"} + "cohttp-lwt-unix" {= "4.0.0"} + "conduit" {= "1.3.0"} + "conduit-lwt" {= "1.3.0"} + "conduit-lwt-unix" {= "1.3.0"} + "conf-libssl" {= "3"} + "conf-pkg-config" {= "2"} + "conf-which" {= "1"} + "cppo" {= "1.6.7"} + "csexp" {= "1.5.1"} + "cstruct" {= "5.0.0"} + "digestif" {= "1.0.0"} + "dune" {= "2.9.0"} + "dune-configurator" {= "2.9.0"} + "easy-format" {= "1.3.2"} + "eqaf" {= "0.7"} + "ezjsonm" {= "1.1.0"} + "fieldslib" {= "v0.14.0"} + "fmt" {= "0.8.9"} + "gg" {= "0.9.3"} + "hex" {= "1.4.0"} + "ipaddr" {= "2.8.0"} + "jbuilder" {= "1.0+beta20.2"} + "js_of_ocaml" {= "3.9.0"} + "js_of_ocaml-compiler" {= "3.9.1"} + "js_of_ocaml-ppx" {= "3.9.0"} + "jsonm" {= "1.0.1"} + "logs" {= "0.7.0"} + "lwt" {= "5.4.1"} + "lwt_ssl" {= "1.1.3"} + "magic-mime" {= "1.1.3"} + "menhir" {= "20210419"} + "menhirLib" {= "20210419"} + "menhirSdk" {= "20210419"} + "mmap" {= "1.1.0"} + "num" {= "1.4"} + "ocaml" {= "4.12.0"} + "ocaml-compiler-libs" {= "v0.12.3"} + "ocaml-config" {= "2"} + "ocaml-migrate-parsetree" {= "1.8.0"} + "ocaml-options-vanilla" {= "1"} + "ocaml-syntax-shims" {= "1.0.0"} + "ocamlbuild" {= "0.14.0"} + "ocamlfind" {= "1.9.1"} + "ocp-indent-nlfork" {= "1.5.4"} + "ocp-ocamlres" {= "0.4"} + "ocplib-endian" {= "1.1"} + "ocplib-json-typed" {= "0.7.1"} + "omd" {= "1.3.1"} + "parsexp" {= "v0.14.1"} + "pprint" {= "20200410"} + "ppx_derivers" {= "1.2.1"} + "ppx_fields_conv" {= "v0.14.1"} + "ppx_sexp_conv" {= "v0.14.1"} + "ppx_tools" {= "6.3"} + "ppxlib" {= "0.15.0"} + "re" {= "1.9.0"} + "result" {= "1.5"} + "seq" {= "0.2.2"} + "sexplib" {= "v0.14.0"} + "sexplib0" {= "v0.14.0"} + "ssl" {= "0.5.5"} + "stdlib-shims" {= "0.3.0"} + "stringext" {= "1.6.0"} + "topkg" {= "1.0.3"} + "uchar" {= "0.0.2"} + "uri" {= "4.2.0"} + "uri-sexp" {= "4.2.0"} + "uutf" {= "1.0.2"} + "vg" {= "0.9.4"} + "yojson" {= "1.7.0"} +] +build: ["dune" "build" "@install" "-p" name "-j" jobs] +dev-repo: "git+https://github.com/ocaml-sf/learn-ocaml" diff --git a/learn-ocaml.opam.locked b/learn-ocaml.opam.locked index c402ccabd..40f7a6ef0 100644 --- a/learn-ocaml.opam.locked +++ b/learn-ocaml.opam.locked @@ -74,7 +74,6 @@ depends: [ "mmap" {= "1.1.0"} "num" {= "1.4"} "ocaml" {= "4.12.0"} - "ocaml-base-compiler" {= "4.12.0"} "ocaml-compiler-libs" {= "v0.12.3"} "ocaml-config" {= "2"} "ocaml-migrate-parsetree" {= "1.8.0"} diff --git a/scripts/static-build.sh b/scripts/static-build.sh index adbddf9a5..f336e7f2e 100755 --- a/scripts/static-build.sh +++ b/scripts/static-build.sh @@ -10,11 +10,11 @@ cd $(dirname "$0")/.. set -o pipefail git ls-files -z | xargs -0 tar c | \ docker run --rm -i \ - ocamlpro/ocaml:4.05 \ + ocamlpro/ocaml:4.12-2021-07-25 \ sh -uexc \ 'tar x >&2 && - sudo apk add openssl-libs-static >&2 && - opam switch create . ocaml-system "dune<2" --deps-only >&2 && + sudo apk add openssl-libs-static bash >&2 && + opam switch create . ocaml-system --deps-only --locked >&2 && opam exec make LINKING_MODE=static >&2 && tar c -hC _build/install/default/bin .' | \ tar vx diff --git a/src/main/dune b/src/main/dune index eab003c95..7d4e4bbb5 100644 --- a/src/main/dune +++ b/src/main/dune @@ -56,7 +56,7 @@ (rule (targets linking_main.sexp) (action (with-stdout-to %{targets} - (run ./linking_flags.sh %{env:LINKING_MODE=dynamic} %{ocaml-config:system} laolao_stubs threads camlrun)))) + (run ./linking_flags.sh %{env:LINKING_MODE=dynamic} %{ocaml-config:system} checkseum_c_stubs threads camlrun)))) (rule (targets linking_client.sexp) (action (with-stdout-to %{targets} @@ -64,4 +64,4 @@ (rule (targets linking_server.sexp) (action (with-stdout-to %{targets} - (run ./linking_flags.sh %{env:LINKING_MODE=dynamic} -- laolao_stubs threadsnat)))) + (run ./linking_flags.sh %{env:LINKING_MODE=dynamic} -- checkseum_c_stubs threadsnat)))) diff --git a/src/main/linking_flags.sh b/src/main/linking_flags.sh index 514840d74..f019eb7ea 100755 --- a/src/main/linking_flags.sh +++ b/src/main/linking_flags.sh @@ -43,18 +43,21 @@ case $(uname -s) in Linux) case $(. /etc/os-release && echo $ID) in alpine) - COMMON_LIBS="camlstr base_stubs ssl_threads_stubs ssl crypto cstruct_stubs lwt_unix_stubs bigarray unix c" + COMMON_LIBS="camlstr ssl_threads_stubs ssl crypto cstruct_stubs bigstringaf_stubs lwt_unix_stubs unix c" # `m` and `pthread` are built-in musl echo '(-noautolink' + echo ' -verbose' echo ' -cclib -Wl,-Bstatic' echo ' -cclib -static-libgcc' + # checkseum requires an additional `-L` argument + ocamlfind query -l-format checkseum.c for l in $EXTRA_LIBS $COMMON_LIBS; do echo " -cclib -l$l" done echo ' -cclib -static)' ;; *) - echo "Error: static linking is only supported in Alpine, to avoids glibc constraints" >&2 + echo "Error: static linking is only supported in Alpine, to avoids glibc constraints (use scripts/static-build.sh to build through an Alpine Docker container)" >&2 exit 3 esac ;; @@ -62,6 +65,7 @@ case $(uname -s) in COMMON_LIBS="camlstr base_stubs ssl_threads_stubs /usr/local/opt/openssl/lib/libssl.a /usr/local/opt/openssl/lib/libcrypto.a cstruct_stubs lwt_unix_stubs bigarray unix" # `m` and `pthread` are built-in in libSystem echo '(-noautolink' + echo ' -verbose' for l in $EXTRA_LIBS $COMMON_LIBS; do if [ "${l%.a}" != "${l}" ]; then echo " -cclib $l" else echo " -cclib -l$l"