# New Ticket Created by  François PERRAD 
# Please include the string:  [perl #36755]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/rt3/Ticket/Display.html?id=36755 >



With this patch, dynclasses work with MinGW32.
(same as r8717 by Jonathan Worthington with MSC)

gdbmhash.dll (libgdbm) needs to add Parrot_load_lib in parrot.def

Francois Perrad.
svn diff
Index: build_tools/parrotdef.pl
===================================================================
--- build_tools/parrotdef.pl    (revision 8735)
+++ build_tools/parrotdef.pl    (working copy)
@@ -31,6 +31,7 @@
        Parrot_debug
        Parrot_disassemble
        Parrot_load_bytecode
+       Parrot_load_lib
        pmc_new
        pmc_reuse
        pmc_new_noinit
Index: config/init/hints/mswin32.pl
===================================================================
--- config/init/hints/mswin32.pl        (revision 8735)
+++ config/init/hints/mswin32.pl        (working copy)
@@ -189,5 +189,17 @@
                } else {
                        warn "unknown configuration";
                }
+
+               # We need to build a .def file to export parrot.exe symbols.
+               Configure::Data->set(
+                       ld_parrot_exe_def       => 'parrot.def',
+                       parrot_exe_def  => 'parrot.def',
+                       link_dynamic    => '-Wl,--out-implib,parrot.a',
+               );
+               # When building dynclasses we need to flag up the need to
+               # mark shared variables with __declspec(dllimport).
+               Configure::Data->set(
+                       cc_building_dynclass_flag => 
'-DPARROT_BUILDING_WIN32_DLL'
+               );
        }
 }
Index: config/gen/makefiles/dynclasses_pl.in
===================================================================
--- config/gen/makefiles/dynclasses_pl.in       (revision 8735)
+++ config/gen/makefiles/dynclasses_pl.in       (working copy)
@@ -39,12 +39,8 @@
     # Paths need quoting as they may contain spaces.
     $PATHQUOTE = '"';
     
-    # Also need various libraries in the link line.
-    my $extraLibs = '${libs} ${icu_shared}';
-    $extraLibs =~ s/blib/..\\blib/g;
-    $extraLibs =~ s/\Q$(A)\E/.lib/g;
-    $LD_LOAD_FLAGS =~ s/(-def:)/$extraLibs $1..\\/;
-    $LIBPARROT = '${build_dir}/parrot.lib';
+    $LD_LOAD_FLAGS =~ s/(-def:)/$1..\\/;
+    $LIBPARROT = '${build_dir}/parrot${a}';
 }
 
 # PMC2C Config
@@ -69,16 +65,29 @@
     my $def = '';
     if ($^O =~ /mswin32/i) {
       $liblist = join( ' ', map { "$_.lib" } keys %$libs );
-      $def = "-def:$target ";
+      if ($CC =~ /gcc/i) {
+        $liblist =~ s/gdbm\.lib/-llibgdbm/i;
+      }
+      # Also need various libraries in the link line.
+      my $extraLibs = '${libs} ${icu_shared}';
+      $extraLibs =~ s/blib/..\\blib/g;
+      $extraLibs =~ s/\Q$(A)\E/.lib/g;
+      $liblist .= ' ' . $extraLibs;
+      if ($CC =~ /gcc/i) {
+        $def = "$target ";
+      } else {
+        $def = "-def:$target ";
+      }
       $def =~ s/\.dll/.def/i;
     } else {
       $liblist = join( ' ', map { "-l$_" } keys %$libs );
     }
 
     return
-        "$LD $LDFLAGS $LD_LOAD_FLAGS $liblist $PATHQUOTE$LIBPARROT$PATHQUOTE ".
-        "${ld_out}" . $target . " " . $def .
-        join(" ", map {"$PATHQUOTE$_$PATHQUOTE"} @$sources);
+        "$LD $LDFLAGS $LD_LOAD_FLAGS ".
+        "-o " . $target . " " . $def .
+        join(" ", map {"$PATHQUOTE$_$PATHQUOTE"} @$sources) .
+        " $liblist $PATHQUOTE$LIBPARROT$PATHQUOTE";
 }
 
 our $NOW = time();

Reply via email to