[MLton-commit] r6676

Wesley Terpstra wesley at mlton.org
Wed Jul 30 01:03:10 PDT 2008


Support building shared libraries (dylibs) on osx.
This requires a different switch (-dynamiclib instead of -shared).

Also, the environ variable seems not to be available in dynamic libraries. 
Instead we can grab it from a system call.


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

U   mlton/trunk/mlton/main/main.fun
U   mlton/trunk/runtime/platform/darwin.h

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

Modified: mlton/trunk/mlton/main/main.fun
===================================================================
--- mlton/trunk/mlton/main/main.fun	2008-07-27 19:04:30 UTC (rev 6675)
+++ mlton/trunk/mlton/main/main.fun	2008-07-30 08:03:07 UTC (rev 6676)
@@ -1120,13 +1120,15 @@
                          | StabsPlus => (["-gstabs+", "-g2"], "-Wa,--gstabs")
                      fun compileO (inputs: File.t list): unit =
                         let
+                           val (libOpts, libExt) = 
+                              case targetOS of
+                                 Darwin => ([ "-dynamiclib" ], ".dylib")
+                               | _ => ([ "-shared" ], ".so")
                            val output = 
                               case !format of
                                  Archive => maybeOut ".a"
                                | Executable => maybeOut ""
-                               | Library => maybeOut ".so"
-                           val libOpts = 
-                               [ "-shared", "-Wl,-Bsymbolic" ]
+                               | Library => maybeOut libExt
                            val _ =
                               trace (Top, "Link")
                               (fn () =>

Modified: mlton/trunk/runtime/platform/darwin.h
===================================================================
--- mlton/trunk/runtime/platform/darwin.h	2008-07-27 19:04:30 UTC (rev 6675)
+++ mlton/trunk/runtime/platform/darwin.h	2008-07-30 08:03:07 UTC (rev 6676)
@@ -30,6 +30,8 @@
 #include <ucontext.h>
 #include <utime.h>
 
+#include <crt_externs.h>
+
 #define HAS_FEROUND TRUE
 #define HAS_FPCLASSIFY TRUE
 #define HAS_MSG_DONTWAIT TRUE
@@ -48,4 +50,5 @@
 #define SIGPOLL 7
 #endif
 
-extern char **environ; /* for Posix_ProcEnv_environ */
+/* for Posix_ProcEnv_environ */
+#define environ *_NSGetEnviron()




More information about the MLton-commit mailing list