Skip to content

Commit ec2214a

Browse files
committed
Patch to add __declspec(dllimport) to OCaml globals
Avoids: cannot relocate Caml_state RELOC_REL32, target is too far + Update Makefile to use unique repository names
1 parent 1f3f1f1 commit ec2214a

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

DEVELOPING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Everything in this document assumes you have done:
77
make local-install
88

99
# Windows
10-
with-dkml make local-install
10+
dk Ml.Use -- make local-install
1111
```
1212

1313
You may also add `--verbose` to the 'opam install' lines in the `Makefile`.

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ create-switch: _opam/.opam-switch/switch-config
1313
# Force an update since 'opam switch create' only updates when it newly registers the repository.
1414
# Upsert (remove + add) FLEXLINKFLAGS on MSVC for debugging
1515
_opam/.opam-switch/switch-config:
16-
opam switch create . --empty --repos diskuv=git+https://github.com/diskuv/diskuv-opam-repository.git#main,default=https://opam.ocaml.org
17-
opam update diskuv
16+
opam switch create . --empty --repos diskuv-main=git+https://github.com/diskuv/diskuv-opam-repository.git#main,default-main=git+https://github.com/ocaml/opam-repository.git
17+
opam update diskuv-main
1818
OPAMSWITCH="$$PWD" && \
1919
if [ -x /usr/bin/cygpath ]; then OPAMSWITCH=$$(/usr/bin/cygpath -aw "$$OPAMSWITCH"); fi && \
2020
if [ -n "$${COMSPEC:-}" ]; then opam option 'setenv-=FLEXLINKFLAGS+=" -link /DEBUG:FULL"'; fi
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# __declspec(dllimport)
2+
3+
Problem on a **64-bit** Windows machine:
4+
5+
```text
6+
Fatal error: cannot load shared library dllcurl_stubs
7+
Reason: flexdll error: cannot relocate Caml_state RELOC_REL32, target is too far: FFFFFFFF2DAA3206 000000002DAA3206
8+
```
9+
10+
Confer <https://github.com/ocaml/ocaml/pull/10351#issuecomment-821957197> for the problem and solution.
11+
12+
This patch will add `__declspec(dllimport)` to `Caml_state` and other OCaml globals if MSVC is the compiler.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/runtime/caml/misc.h b/runtime/caml/misc.h
2+
index c605f87..43e8762 100644
3+
--- a/runtime/caml/misc.h
4+
+++ b/runtime/caml/misc.h
5+
@@ -116,6 +116,8 @@ CAMLdeprecated_typedef(addr, char *);
6+
#if defined(SUPPORT_DYNAMIC_LINKING) && defined(ARCH_SIXTYFOUR) \
7+
&& (defined(__CYGWIN__) || defined(__MINGW32__))
8+
#define CAMLDLLIMPORT __declspec(dllimport)
9+
+ #elif defined(SUPPORT_DYNAMIC_LINKING) && defined(_MSC_VER)
10+
+ #define CAMLDLLIMPORT __declspec(dllimport)
11+
#else
12+
#define CAMLDLLIMPORT
13+
#endif

0 commit comments

Comments
 (0)