dune 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. ;; https://discuss.ocaml.org/t/dune-how-to-link-statically-on-linux-not-on-others/8537/4?u=mro
  2. (rule
  3. (with-stdout-to
  4. flags.sexp
  5. (run sh %{dep:gen_flags.sh})))
  6. (rule
  7. (with-stdout-to
  8. version.ml
  9. ; (run echo "let dune_project_num = \"%{version:seppo}\"")
  10. (run sh %{dep:gen_version.sh} "%{version:seppo}" # ${build-number}) ; https://github.com/ocaml/dune/issues/255#issuecomment-372077123
  11. ))
  12. ; https://stackoverflow.com/a/53325230/349514
  13. (executable
  14. (name apchk)
  15. (public_name apchk)
  16. (package apchk)
  17. (libraries
  18. seppo_lib
  19. cohttp-lwt
  20. ezjsonm
  21. lwt.unix
  22. mirage-crypto-rng-lwt
  23. ptime.clock.os
  24. result
  25. uri)
  26. (preprocess
  27. (pps lwt_ppx))
  28. ; https://discuss.ocaml.org/t/lwt-ppx-binary-footprint/11818/2
  29. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  30. ;; Prepare for static linking
  31. ;
  32. ; http://rgrinberg.com/posts/static-binaries-tutorial/
  33. ; https://discuss.ocaml.org/t/statically-link/1464/9
  34. ; Issue https://discuss.ocaml.org/t/statically-link/1464/13
  35. ; https://www.systutorials.com/how-to-statically-link-ocaml-programs/
  36. ;
  37. ; $ date
  38. ; Tue Mar 24 11:36:40 CET 2020
  39. ; $ uname -o -m
  40. ; x86_64 GNU/Linux
  41. ; $ cat /etc/issue
  42. ; Devuan GNU/Linux 1 \n \l
  43. ;
  44. ; # on Ubuntu Bionic note
  45. ; # https://github.com/ocaml/ocaml/issues/9131#issuecomment-599765888
  46. ; $ sudo add-apt-repository ppa:avsm/musl
  47. ;
  48. ; $ sudo apt-get install musl-tools
  49. ; $ eval (opam env)
  50. ; $ opam switch create 4.11.2+musl+static+flambda
  51. ; $ opam switch 4.11.2+musl+static+flambda
  52. ; $ eval (opam env)
  53. ; $ cat */deps | xargs opam install --yes
  54. ; $ make test clean build
  55. ; $ file _build/default/chkr/*.exe
  56. ; _build/default/chkr/apchk.exe: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, not stripped
  57. (flags
  58. (:include flags.sexp)))