dune 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. ;; https://discuss.ocaml.org/t/dune-how-to-link-statically-on-linux-not-on-others/8537/4?u=mro
  2. (rule (with-stdout-to link_flags.sexp (run sh %{dep:gen_link_flags.sh})))
  3. ; https://stackoverflow.com/a/53325230/349514
  4. (executable
  5. (name html2broadcast)
  6. (libraries Lib)
  7. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  8. ;; Prepare for static linking
  9. ;
  10. ; http://rgrinberg.com/posts/static-binaries-tutorial/
  11. ; https://discuss.ocaml.org/t/statically-link/1464/9
  12. ; Issue https://discuss.ocaml.org/t/statically-link/1464/13
  13. ; https://www.systutorials.com/how-to-statically-link-ocaml-programs/
  14. ;
  15. ; $ date
  16. ; Tue Mar 24 11:36:40 CET 2020
  17. ; $ uname -o -m
  18. ; x86_64 GNU/Linux
  19. ; $ cat /etc/issue
  20. ; Devuan GNU/Linux 1 \n \l
  21. ;
  22. ; # on Ubuntu Bionic note
  23. ; # https://github.com/ocaml/ocaml/issues/9131#issuecomment-599765888
  24. ; $ sudo add-apt-repository ppa:avsm/musl
  25. ;
  26. ; $ sudo apt-get install musl-tools
  27. ; $ eval (opam env)
  28. ; $ opam switch create 4.10.0+musl+static+flambda
  29. ; $ opam switch 4.10.0+musl+static+flambda
  30. ; $ eval (opam env)
  31. ; $ opam install dune
  32. ; $ make clean build
  33. ; $ file _build/default/bin/*.exe
  34. ; _build/default/bin/meta.exe: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, not stripped
  35. (link_flags (:include link_flags.sexp))
  36. )