dune
dune copied to clipboard
ci: build a static linux binary
The dynamic one uses a dynamic loader under a nix path so we can't really use it.
@anmonteiro I tried using pkgsCross to build a static version of dune, but it's building a dynamic version:
$ nix build '.#dune-static'
$ file result/bin/dune
result/bin/dune: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /nix/store/73xmadm08bhnjq47vk5shw6h0rm2b7c6-musl-x86_64-unknown-linux-musl-1.2.3/lib/ld-musl-x86_64.so.1, not stripped
At least it's using musl, so I think it's just a matter of passing the right flags. I had a look at how ocaml-option-static works and it's just passing LIBS=-static to the compiler, which the static overlay seems to do. But since it's a cross-compilation I'm not sure whether there's something extra to do.
Ah right, we should be passing -ccopt -static to ocamlopt_flags.
I usually add that in an env stanza under a static profile.
Ah thanks that did it. We just make a bootstrap binary so we can't set flags directly from a profile, so I had to be creative.