[MLton-commit] r6685

Wesley Terpstra wesley at mlton.org
Fri Aug 1 03:43:41 PDT 2008


Create DLLs on win32/64.

The win64 DLLs only work with the C-codegen (amd64 on win64 is broken).


----------------------------------------------------------------------

U   mlton/trunk/mlton/codegen/x86-codegen/x86.fun
U   mlton/trunk/mlton/main/main.fun
U   mlton/trunk/runtime/Makefile
U   mlton/trunk/runtime/export.h

----------------------------------------------------------------------

Modified: mlton/trunk/mlton/codegen/x86-codegen/x86.fun
===================================================================
--- mlton/trunk/mlton/codegen/x86-codegen/x86.fun	2008-08-01 10:11:49 UTC (rev 6684)
+++ mlton/trunk/mlton/codegen/x86-codegen/x86.fun	2008-08-01 10:43:24 UTC (rev 6685)
@@ -3349,10 +3349,12 @@
                                                  str "\""]),
                                    ","))]
              | Global l 
-             => seq [str ".globl ",
-                     Label.layout l,
-                     str "\n.hidden ",
-                     Label.layout l]
+             => seq (List.concat 
+                [ [str ".globl ", Label.layout l],
+                  case !Control.Target.os of
+                     Control.Target.MinGW => []
+                   | Control.Target.Cygwin => []
+                   | _ => [str "\n.hidden ", Label.layout l]])
              | IndirectSymbol l 
              => seq [str ".indirect_symbol ",
                      Label.layout l]

Modified: mlton/trunk/mlton/main/main.fun
===================================================================
--- mlton/trunk/mlton/main/main.fun	2008-08-01 10:11:49 UTC (rev 6684)
+++ mlton/trunk/mlton/main/main.fun	2008-08-01 10:43:24 UTC (rev 6685)
@@ -1119,6 +1119,9 @@
                            val (libOpts, libExt) = 
                               case targetOS of
                                  Darwin => ([ "-dynamiclib" ], ".dylib")
+                               | MinGW => ([ "-shared", "-Wl,--out-implib," ^
+                                                        libname () ^ ".a"], 
+                                           ".dll")
                                | _ => ([ "-shared" ], ".so")
                            val output = 
                               case !format of

Modified: mlton/trunk/runtime/Makefile
===================================================================
--- mlton/trunk/runtime/Makefile	2008-08-01 10:11:49 UTC (rev 6684)
+++ mlton/trunk/runtime/Makefile	2008-08-01 10:43:24 UTC (rev 6685)
@@ -34,7 +34,7 @@
 EXE :=
 OPTFLAGS := -O2 -fomit-frame-pointer
 DEBUGFLAGS := -O1 -fno-inline -fkeep-inline-functions -g2
-PICFLAGS := -fPIC -DPIC
+PICFLAGS := -DPIC
 GCOPTFLAGS :=
 GCDEBUGFLAGS :=
 GCPICFLAGS := 
@@ -43,10 +43,17 @@
 DEBUGWARNFLAGS :=
 PICWARNFLAGS := 
 
-# Make mlton static library symbols private
+# Win32&64 don't use PIC code, all other platforms do
+ifeq ($(findstring $(TARGET_OS), mingw cygwin),)
+PICFLAGS += -fPIC
+endif
+
+# Make mlton library symbols private (win32&64 use another technique)
 ifeq ($(findstring $(GCC_MAJOR_VERSION), 4),$(GCC_MAJOR_VERSION))
+ifeq ($(findstring $(TARGET_OS), mingw cygwin),)
 FLAGS += -fvisibility=hidden
 endif
+endif
 
 ifeq ($(TARGET_ARCH), amd64)
 FLAGS += -m64

Modified: mlton/trunk/runtime/export.h
===================================================================
--- mlton/trunk/runtime/export.h	2008-08-01 10:11:49 UTC (rev 6684)
+++ mlton/trunk/runtime/export.h	2008-08-01 10:43:24 UTC (rev 6685)
@@ -13,6 +13,11 @@
 /*                      Symbols                      */
 /* ------------------------------------------------- */
 
+#if defined(_WIN32) || defined(_WIN64)
+#define IMPORTED __declspec(dllimport)
+#define EXPORTED __declspec(dllexport)
+#define INTERNAL
+#else
 #if __GNUC__ >= 4
 #define IMPORTED __attribute__((visibility("default")))
 #define EXPORTED __attribute__((visibility("default")))
@@ -22,5 +27,6 @@
 #define EXPORTED
 #define INTERNAL
 #endif
+#endif
 
 #endif /* _MLTON_EXPORT_H_ */




More information about the MLton-commit mailing list