yallop / ocaml-ctypes

Library for binding to C libraries using pure OCaml
MIT License
363 stars 95 forks source link

Remove compatibility with OCaml 4.02 (makes ctypes stubs compatible with ocaml-multicore for free) #673

Closed kit-ty-kate closed 3 years ago

kit-ty-kate commented 3 years ago

The stubs generation part of ctypes doesn't seem to be compatible with ocaml-multicore at the moment. For instance, the following error message is raised when trying to compile decompress which uses ctypes' stubs generation:

#=== ERROR while compiling decompress.1.4.1 ===================================#
# context              2.1.0~beta4 | linux/x86_64 | ocaml-variants.4.12.0+domains | file:///home/opam/opam-repository
# path                 ~/.opam/4.12.0+domains/.opam-switch/build/decompress.1.4.1
# command              ~/.opam/4.12.0+domains/bin/dune runtest -p decompress -j 31
# exit-code            1
# env-file             ~/.opam/log/decompress-2686-ca0fe3.env
# output-file          ~/.opam/log/decompress-2686-ca0fe3.out
### output ###
#          gcc bindings/stubs/gen_decompress.o (exit 1)
# (cd _build/default/bindings/stubs && /usr/bin/gcc -O2 -fno-strict-aliasing -fwrapv -fPIC -D_FILE_OFFSET_BITS=64 -D_REENTRANT -O2 -fno-strict-aliasing -fwrapv -fPIC -g -I /home/opam/.opam/4.12.0+domains/lib/ocaml -I /home/opam/.opam/4.12.0+domains/lib/bigarray-compat -I /home/opam/.opam/4.12.0+domains/lib/bytes -I /home/opam/.opam/4.12.0+domains/lib/checkseum/c -I /home/opam/.opam/4.12.0+domains/lib/ctypes -I /home/opam/.opam/4.12.0+domains/lib/integers -I /home/opam/.opam/4.12.0+domains/lib/optint -I . -I ../../lib -o gen_decompress.o -c gen_decompress.c)
# gen_decompress.c: In function 'decompress_inflate':
# gen_decompress.c:38:4: error: 'caml_local_roots' undeclared (first use in this function); did you mean 'caml_local_roots_ptr'?
#    38 |    caml_local_roots = caml__frame;;
#       |    ^~~~~~~~~~~~~~~~
#       |    caml_local_roots_ptr
# gen_decompress.c:38:4: note: each undeclared identifier is reported only once for each function it appears in

Looking into it, it seems the direct use of caml_local_roots stems from a care for backwards compatibility. Given it is relatively easy to simply bump the required version and use the "new" CAMLdrop() macro I feel like it might be worth doing anyway.

yallop commented 3 years ago

Thank you! It seems like a reasonable time to drop support for 4.02.3.