Switch `./configure` script to Dune configurator
Hello!
This is a rework of #38, getting rid of autotools and switching to dune-configurator instead. The most visible effect of this change is that the ./configure step is no longer needed; a simple make is enough to build the library.
A new "discover" script config/discover.ml that depends on dune.configurator is added. The script will compile one test C program per symbol to be discovered, in much the same way as autoconf. However, since this is as slow as autoconf (even a bit slower, since dune-configurator also links the test programs instead of just compiling them), a "fast path" is added in which we first try to check for the existence of all symbols at once; this means that on modern systems, the configuration script is very fast.
I removed a bit of code from curl-helper.c that seemed dead code. And added a few more #undefs as in 1bc75b8314575929450d378c0b156e686edc420c which I needed in order to compile on Windows.
Since we don't have an extra ./configure step anymore, I somehow extract the version number from dune-project in order to use it in the Makefile. I'm sure better solutions are possible; this was just a quick hack.
Each commit can be reviewed individually.
Let me know what you think! Cheers.
This needs to remove ./configure from the opam file as well: https://github.com/jonahbeckford/ocurl/commit/a8a49bf07e43ddc7b621d8a8a74dcd80276174b6
This also needs to depend on the dune-configurator package: https://github.com/jonahbeckford/ocurl/commit/0b706b25934eaa31d6acdd8d177e50d4f8076982
Aside: I still don't have a successful end-to-end test with this PR yet. I'm getting:
Fatal error: cannot load shared library dllcurl_stubs
Reason: Cannot resolve socket
When I figure out why that is happening (socket should come from WS2_32.dll) I'll update edit this comment.
EDIT 1: Below is a repeat of what dune is doing (with some extra verbosity arguments for flexlink) ...
Y:\source\ocurl\_build\default> del -Force libcurl_stubs.lib
Y:\source\ocurl\_build\default> del -Force dllcurl_stubs.dll
Y:\source\ocurl\_build\default> ocamlmklib.opt.exe -g -o curl_stubs curl-helper.obj -ldopt Y:/source/dksdk-coder/.ci/o/dkml/share/dkcoder-c/debug/lib/pkgconfig/../../lib/libcurl-d.lib -verbose -ldopt -v -ldopt -v -ldopt -show-imports
+ flexlink -x64 -merge-manifest -stack 33554432 -g -o .\dllcurl_stubs.dll curl-helper.obj Y:/source/dksdk-coder/.ci/o/dkml/share/dkcoder-c/debug/lib/pkgconfig/../../lib/libcurl-d.lib -v -v -show-imports -LY:/source/dksdk-coder/.ci/o/dkml/lib/ocaml\flexdll
...
** Imported symbols for curl-helper.obj:
Caml_state
...
caml_string_length
win_alloc_socket
** Imported symbols for descriptor object:
socket
EDIT 2: I might be seeing this because I link against ucrt rather than msvcrt. But regardless, the fix is to tell flexlink to not import symbols that are in ws2_32 by adding -defaultlib ws2_32.lib:
Y:\source\ocurl\_build\default> ocamlmklib.opt.exe -g -o curl_stubs curl-helper.obj -ldopt Y:/source/dksdk-coder/.ci/o/dkml/share/dkcoder-c/debug/lib/pkgconfig/../../lib/libcurl-d.lib -verbose -ldopt -v -ldopt -v -ldopt -show-imports -ldopt -defaultlib -ldopt ws2_32.lib
...
** Imported symbols for curl-helper.obj:
Caml_state
...
caml_string_length
win_alloc_socket
I've end-to-end tested this PR successfully with MSVC for bytecode with the modifications I posted. Thanks!
I've end-to-end tested this PR successfully with MSVC for bytecode with the modifications I posted. Thanks!
Thanks for the fixes, and the confirmation!