diff --git a/Changes b/Changes index 1ec5ffe71..688b8080f 100644 --- a/Changes +++ b/Changes @@ -485,6 +485,9 @@ Working version it with -link. (David Allsopp, review by Xavier Leroy) +- #9927: Restore Cygwin64 support. + (David Allsopp, review by Xavier Leroy) + OCaml 4.11.1 ------------ diff --git a/bytecomp/bytelink.ml b/bytecomp/bytelink.ml index 6660fee46..fd5bd490a 100644 --- a/bytecomp/bytelink.ml +++ b/bytecomp/bytelink.ml @@ -466,7 +466,8 @@ let link_bytecode_as_c tolink outfile with_main = (fun () -> (* The bytecode *) output_string outchan "\ -#define CAML_INTERNALS\ +#define CAML_INTERNALS\n\ +#define CAMLDLLIMPORT\ \n\ \n#ifdef __cplusplus\ \nextern \"C\" {\ diff --git a/otherlibs/systhreads/st_stubs.c b/otherlibs/systhreads/st_stubs.c index 9c96df54f..d27e14230 100644 --- a/otherlibs/systhreads/st_stubs.c +++ b/otherlibs/systhreads/st_stubs.c @@ -35,7 +35,9 @@ #endif #include "caml/sys.h" #include "caml/memprof.h" -#include "threads.h" + +/* threads.h is *not* included since it contains the _external_ declarations for + the caml_c_thread_register and caml_c_thread_unregister functions. */ #if defined(NATIVE_CODE) && defined(WITH_SPACETIME) #include "caml/spacetime.h" diff --git a/runtime/Makefile b/runtime/Makefile index 9cccfd069..f688af70a 100644 --- a/runtime/Makefile +++ b/runtime/Makefile @@ -130,6 +130,8 @@ ifneq "$(CCOMPTYPE)" "msvc" OC_CFLAGS += -g endif +OC_CPPFLAGS += -DCAMLDLLIMPORT= + OC_NATIVE_CPPFLAGS = -DNATIVE_CODE -DTARGET_$(ARCH) ifeq "$(UNIX_OR_WIN32)" "unix" diff --git a/runtime/caml/misc.h b/runtime/caml/misc.h index f1029ed06..5c3631033 100644 --- a/runtime/caml/misc.h +++ b/runtime/caml/misc.h @@ -74,13 +74,20 @@ CAMLdeprecated_typedef(addr, char *); #define Noreturn #endif - - /* Export control (to mark primitives and to handle Windows DLL) */ +#ifndef CAMLDLLIMPORT + #if defined(SUPPORT_DYNAMIC_LINKING) && defined(ARCH_SIXTYFOUR) \ + && defined(__CYGWIN__) + #define CAMLDLLIMPORT __declspec(dllimport) + #else + #define CAMLDLLIMPORT + #endif +#endif + #define CAMLexport #define CAMLprim -#define CAMLextern extern +#define CAMLextern CAMLDLLIMPORT extern /* Weak function definitions that can be overridden by external libs */ /* Conservatively restricted to ELF and MacOSX platforms */ diff --git a/testsuite/tests/lib-dynlink-bytecode/stub2.c b/testsuite/tests/lib-dynlink-bytecode/stub2.c index f4cd3a7ee..403bcd555 100644 --- a/testsuite/tests/lib-dynlink-bytecode/stub2.c +++ b/testsuite/tests/lib-dynlink-bytecode/stub2.c @@ -18,7 +18,7 @@ #include "caml/alloc.h" #include -extern value stub1(void); +CAMLextern value stub1(void); value stub2(void) { printf("This is stub2, calling stub1:\n"); fflush(stdout);