Re: Static linking with Mingw and dune
Antonin Décimo <[email protected]> Mon, 2 Dec 2024 09:25:00 +0100
| Newsgroups | gmane.comp.lang.caml.inria |
|---|---|
| Message-ID | <CAC=54B+DN2RKYMfM=R9YrpTkZZ=6i4K40WAp=HcLpZNT3+9V6Q@mail.gmail.com> |
> Regarding OCaml 5.3/mingw64 you shouldn't need to have to do anything with libwinpthreads because it's only used for the msvc port, not the mingw one.
That is not quite exact, winpthreads is used with mingw-w64, but found
in the system installation, and linked to. It is vendored for the MSVC
port and we *statically* link into the runtime only the parts we're
interested in.
To statically link with winpthreads, I suggest you do all of it manually:
- clone winpthreads sources at https://github.com/mingw-w64/mingw-w64,
go to mingw-w64-libraries/winpthreads, and build a static version of
the library with your preferred toolchain;
- hack the OCaml compiler / Makefile to *not* use `-lpthreads`:
https://github.com/ocaml/ocaml/blob/5a5eb481c7a9d0f039e3169aa8ed19c9b926e982/configure.ac#L2372-L2373
Maybe it's just sufficient to set PTHREAD_LIBS when invoking
configure; however seeing this line makes me think that winpthreads is
already statically linked with the runtime.
PTHREAD_LIBS="-l:libpthread.a $link_gcc_eh"]
Haven't dug further.
-- Antonin