[MLton-commit] r6894

Wesley Terpstra wesley at mlton.org
Tue Sep 30 08:51:43 PDT 2008


Fix library regression for MinGW.
There were a few problems:
  * Symbols start with _, so the dlltool sed expression needed changing
  * --globalize doesn't localize the rest, we want --keep-global
  * We need to preserve the .drectve section so dlltool works on libarchives
  * Include --enable-stdcall-fixups for _address of stdcall fns

In order for the regressions to pass, however, one needs to have a patched
binutils which fixes a binutils/bfd bug. I've worked out a patch with one
of the binutils maintainers, so it will be in the next release. When MLton
is next released the mlton.msi windows installer should include the patch.


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

U   mlton/trunk/bin/static-library

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

Modified: mlton/trunk/bin/static-library
===================================================================
--- mlton/trunk/bin/static-library	2008-09-30 15:44:46 UTC (rev 6893)
+++ mlton/trunk/bin/static-library	2008-09-30 15:51:40 UTC (rev 6894)
@@ -35,19 +35,22 @@
 rm -f "${output}"
 
 if "$partialLink"; then
-  "${target}ld" -r -o "$output.o" "$@"
-  
   # Localize all but export symbols. Platform dependent.
   if [ "$os" = "darwin" ]; then
+    "${target}ld" -r -o "$output.o" "$@"
     # The osx linker already makes hidden symbols local
-    echo -n 
   elif [ "$os" = "mingw" -o "$os" = "cygwin" ]; then
+    # We need to force the export directives to be copied
+    echo "SECTIONS { .drectve : { *(.drectve) } }" > "$output.script"
+    "${target}ld" -r --enable-stdcall-fixup -o "$output.o" "$output.script" "$@"
+    # Extract the list of exports to make them global
     "${target}dlltool" --output-def "$output.def" "$@"
     grep '@' "$output.def" \
-      | sed 's/^[[:space:]]*\([^[:space:]]*\).*$/\1/' \
+      | sed 's/^[[:space:]]*\([^[:space:]]*\).*$/_\1/' \
       > "$output.globals"
-    "${target}objcopy" --globalize-symbols "$output.globals" "$output.o"
+    "${target}objcopy" --keep-global-symbols "$output.globals" "$output.o"
   else
+    "${target}ld" -r -o "$output.o" "$@"
     # ELF systems are all the same... localize hidden symbols
     # Be careful not to localize gcc PIC's common section thunks
     "${target}objdump" -t "$output.o" \
@@ -61,7 +64,7 @@
   # Create the final archive
   "${target}ar" rc "$output" "$output.o"
   "${target}ranlib" "$output"
-  rm -f "$output.o" "$output.def" "$output.globals" "$output.locals"
+  rm -f "$output.o" "$output.def" "$output.globals" "$output.locals" "$output.script"
 else
   "${target}ar" rc "$output" "$@"
   "${target}ranlib" "$output"




More information about the MLton-commit mailing list