zarith-musl.sh 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/bin/sh
  2. # $ opam install zarith
  3. # https://github.com/ocaml/Zarith/issues/77#issuecomment-991797884
  4. #
  5. # 'Opam install fails with OCaml 4.12 flambda musl static'
  6. # https://github.com/nberth/mlgmpidl/issues/11#issuecomment-884881150
  7. #
  8. set -eu
  9. cd "$(dirname "$0")" || exit 1
  10. musl-gcc --version >/dev/null || {
  11. echo "install \$ sudo apt-get install musl-tools"
  12. exit 1
  13. }
  14. lzip --version >/dev/null || {
  15. echo "install \$ sudo apt-get install lzip"
  16. exit 1
  17. }
  18. readonly prefix="$HOME/.opam/$(opam switch show)/share/gmp-prefix"
  19. # rm -r "$prefix" 2>/dev/null || true
  20. mkdir -p "$prefix"
  21. cd "$prefix" || exit 1
  22. # MUSL-based GMP
  23. ver="gmp-6.2.1"
  24. if [ ! -r "${prefix}/lib/libgmp.a" ]
  25. then
  26. curl --silent -LO "https://gmplib.org/download/gmp/${ver}.tar.lz" \
  27. && tar xaf "${ver}.tar.lz" \
  28. && cd "${ver}" \
  29. && CC=musl-gcc ./configure --enable-fat --prefix "$prefix" \
  30. && nice make \
  31. && nice make check \
  32. && make install \
  33. && cd ..
  34. fi
  35. # --enable-fat https://codeberg.org/seppo/seppo/issues/2
  36. # https://discuss.ocaml.org/t/sigill-crash-in-mirage-crypto-pk-rsa-generate/12209
  37. # https://github.com/ocaml/Zarith/issues/77#issuecomment-991797884
  38. CPPFLAGS=-I"$prefix/include" LDFLAGS=-L"$prefix/lib" opam upgrade zarith --yes