Closed MisterDA closed 2 months ago
Why is moving the stub in another file enough to fix the issue ?
This was my initial question:
I've just noticed that the new version of JS base doesn't build anymore on Windows: it's defining a
caml_csel_value
function withCAMLweakdef
, but theirocaml_intrinsic_kernel
package also defines that same function, withoutCAMLweakdef
. I understand there's no easy definition of weak linking on Windows?
This PR is based on @dra27's explanations:
Sadly, this is true - there's a very strange
selectany
, but its semantics are really odd The best way - which is used inlibcamlrun
already - is to put the "weak" function in its own.o
file Because it is well defined that if you have already linked a symbol, then a.o
file doesn't get pulled in when linking a.a
file (we use this withmain.o
inlibcamlrun.a
)
Hmm, it appears I had only tested ocaml_intrinsics_kernel
and base
, but installing ppx_base
still fails (as someone reported, then removed their comment). The catch is that the same patch needs to be applied to ocaml_intrinsics_kernel
.
Yes, I’ve tested the branch and got the same error. After my comment, I’ve been in doubt if I set up the branch properly when I compiled the package and I’ve removed the comment. (after checking I confirm I was right, but I didn’t had the opportunity to connect here again :)
Could you confirm that with both patches in base and ocaml_intrinsics_kernel, the compilation of ppx_base succeeds?
I just tried this morning and with the two branches I’ve been able to build the package properly. (I did not test any code using it but the compilation went fine)
I've removed the symbol from base
as it is now provided by ocaml_intrinsics_kernel
. This also fixes the problem.
Hi, thanks for your PR!
Put
CAMLweakdef
function in its own translation unit for Windows compatibility, or it conflicts with other non-weakdef symbols with the same name from other libraries. There's a conflicting symbol inocaml_intrinsics_kernel
at: https://github.com/janestreet/ocaml_intrinsics_kernel/blob/1047d3186d0c6b498f1baa96024901cc3cbc2a19/src/conditional_stubs.c#L23-L26.Also note that the
caml_
prefix for C symbols is reserved by the OCaml runtime. I suggest JS libraries pick another prefix.