dune 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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})
  11. ; https://github.com/ocaml/dune/issues/255#issuecomment-372077123
  12. ))
  13. ; https://stackoverflow.com/a/53325230/349514
  14. (executable
  15. (name apchk)
  16. (public_name apchk)
  17. (package apchk)
  18. (libraries seppo_lib unix)
  19. (preprocess
  20. (pps lwt_ppx))
  21. ; https://discuss.ocaml.org/t/lwt-ppx-binary-footprint/11818/2
  22. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  23. ;; Prepare for static linking
  24. ;
  25. ; http://rgrinberg.com/posts/static-binaries-tutorial/
  26. ; https://discuss.ocaml.org/t/statically-link/1464/9
  27. ; Issue https://discuss.ocaml.org/t/statically-link/1464/13
  28. ; https://www.systutorials.com/how-to-statically-link-ocaml-programs/
  29. ;
  30. ; $ date
  31. ; Tue Mar 24 11:36:40 CET 2020
  32. ; $ uname -o -m
  33. ; x86_64 GNU/Linux
  34. ; $ cat /etc/issue
  35. ; Devuan GNU/Linux 1 \n \l
  36. ;
  37. ; # on Ubuntu Bionic note
  38. ; # https://github.com/ocaml/ocaml/issues/9131#issuecomment-599765888
  39. ; $ sudo add-apt-repository ppa:avsm/musl
  40. ;
  41. ; $ sudo apt-get install musl-tools
  42. ; $ eval (opam env)
  43. ; $ opam switch create 4.11.2+musl+static+flambda
  44. ; $ opam switch 4.11.2+musl+static+flambda
  45. ; $ eval (opam env)
  46. ; $ cat */deps | xargs opam install --yes
  47. ; $ make test clean build
  48. ; $ file _build/default/chkr/*.exe
  49. ; _build/default/chkr/apchk.exe: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, not stripped
  50. (flags
  51. (:include flags.sexp)))
  52. (documentation
  53. (package apchk))