Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch ./configure script to Dune configurator #81

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

nojb
Copy link
Contributor

@nojb nojb commented Sep 7, 2024

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 1bc75b8 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.

@jonahbeckford
Copy link

This needs to remove ./configure from the opam file as well: jonahbeckford@a8a49bf

@jonahbeckford
Copy link

jonahbeckford commented Oct 25, 2024

This also needs to depend on the dune-configurator package: jonahbeckford@0b706b2


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

Copy link

@jonahbeckford jonahbeckford left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should address #81 (comment)

config/discover.ml Outdated Show resolved Hide resolved
config/discover.ml Outdated Show resolved Hide resolved
config/discover.ml Outdated Show resolved Hide resolved
config/discover.ml Outdated Show resolved Hide resolved
@jonahbeckford
Copy link

I've end-to-end tested this PR successfully with MSVC for bytecode with the modifications I posted. Thanks!

@nojb
Copy link
Contributor Author

nojb commented Oct 25, 2024

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!

nojb and others added 4 commits October 25, 2024 21:29
Co-authored-by: jonahbeckford <[email protected]>
Co-authored-by: jonahbeckford <[email protected]>
Co-authored-by: jonahbeckford <[email protected]>
Co-authored-by: jonahbeckford <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants