savonet / ocaml-posix

Bindings to the various POSIX APIs
https://www.liquidsoap.info/ocaml-posix/
MIT License
27 stars 2 forks source link

Update to Dune 3 `ctypes` stanza #11

Open MisterDA opened 1 year ago

MisterDA commented 1 year ago

Dune 3 has native support for ctypes. It now shows warnings when building ocaml-posix packages. I think it would be nicer to switch to the new stanza, but it's not clear to me how to proceed, seeing that we have C code being generated by hand. https://dune.readthedocs.io/en/stable/foreign-code.html#stub-generation-with-dune-ctypes

File "posix-types/src/generator/dune", line 19, characters 3-17:
19 |    %{lib:ctypes:}
        ^^^^^^^^^^^^^^
Error: The form %{lib:<libname>:} is no longer supported since version 3.0 of
the Dune language.
Hint: Did you know that Dune 3.0 supports ctypes natively? See the manual for
more details.
toots commented 1 year ago

Hi

I'd be down to switch to dune support. The tricky part, I believe, is to figure out how to make cross-compilation work. To do this, some of the programs used to get system-specific constants have to be run through wine. See: https://github.com/savonet/ocaml-posix/blob/main/posix-socket/src/generator/exec.sh

I'm not sure if dune supports that with ctypes. The cross-compilation layer for dune is very powerful but it assumes that all binaries that need to be executed have to built for the architecture running the build, not the target one.