dune 1.2 KB

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