[MLton-commit] r6797

Wesley Terpstra wesley at mlton.org
Sun Aug 24 09:25:03 PDT 2008


Include the operating system name as an argument to the static-library script.
----------------------------------------------------------------------

U   mlton/trunk/bin/static-library
U   mlton/trunk/mlton/main/main.fun

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

Modified: mlton/trunk/bin/static-library
===================================================================
--- mlton/trunk/bin/static-library	2008-08-24 04:11:06 UTC (rev 6796)
+++ mlton/trunk/bin/static-library	2008-08-24 16:24:58 UTC (rev 6797)
@@ -1,8 +1,8 @@
 #! /usr/bin/env bash
 
 # This script creates a static library (archive).
-# It is invoked as: static-library ARCH OUTPUT objects* libraries*
-# eg: static-library self foo.a /tmp/obj1.o /tmp/obj2.o /lib/libmlton.a
+# It is invoked as: static-library TARGET OS OUTPUT objects* libraries*
+# eg: static-library self mingw foo.a /tmp/obj1.o /tmp/obj2.o /lib/libmlton.a
 
 # A safe fallback for unsupported platforms is:
 #  rm -f foo.a
@@ -22,6 +22,8 @@
 
 target="$1"
 shift
+os="$1"
+shift
 output="$1"
 shift
 
@@ -34,17 +36,30 @@
 
 if "$partialLink"; then
   "${target}ld" -r -o "$output.o" "$@"
-  # The osx linker already makes hidden symbols local, so we can skip this
-  if [ "$(uname -s)" != "Darwin" ]; then
+  
+  # Localize all but export symbols. Platform dependent.
+  if [ "$os" = "darwin" ]; then
+    # The osx linker already makes hidden symbols local
+    echo -n 
+  elif [ "$os" = "mingw" -o "$os" = "cygwin" ]; then
+    "${target}dlltool" --output-def "$output.def" "$@"
+    grep '@' "$output.def" \
+      | sed 's/^[[:space:]]*\([^[:space:]]*\).*$/\1/' \
+      > "$output.globals"
+    "${target}objcopy" --globalize-symbols "$output.globals" "$output.o"
+  else
+    # ELF systems are all the same...
     "${target}objdump" -t "$output.o" \
       | grep ' \.hidden ' \
       | sed 's/^.* \.hidden //' \
       > "$output.locals"
     "${target}objcopy" --localize-symbols "$output.locals" "$output.o"
   fi
+
+  # Create the final archive
   "${target}ar" rc "$output" "$output.o"
   "${target}ranlib" "$output"
-  rm -f "$output.o" "$output.locals"
+  rm -f "$output.o" "$output.def" "$output.globals" "$output.locals"
 else
   "${target}ar" rc "$output" "$@"
   "${target}ranlib" "$output"

Modified: mlton/trunk/mlton/main/main.fun
===================================================================
--- mlton/trunk/mlton/main/main.fun	2008-08-24 04:11:06 UTC (rev 6796)
+++ mlton/trunk/mlton/main/main.fun	2008-08-24 16:24:58 UTC (rev 6797)
@@ -1170,7 +1170,7 @@
                                then System.system
                                     (arScript, 
                                      List.concat 
-                                      [[targetStr, output],
+                                      [[targetStr, OSStr, output],
                                        inputs,
                                        linkArchives])
                                else System.system




More information about the MLton-commit mailing list