CYG14 Dynaloader without USEIMPORTLIB, and search cyg prefix
authorReini Urban <rurban@x-ray.at>
Tue, 14 Sep 2010 15:48:32 +0000 (17:48 +0200)
committerJesse Vincent <jesse@bestpractical.com>
Mon, 3 Jan 2011 16:29:09 +0000 (00:29 +0800)
part1: Support the standard cyg dll prefix, which is e.g. needed for FFI's.
Ctypes and C::DynaLib use DynaLoader to find dlls.

part2: With -DUSEIMPORTLIB DynaLoader symbols link against the prefixed
symbol names for the .dll.a importlib, but we need to link against the
symbols directly. We don't link Dynaloader against libperl.dll.a.

Otherwise:
$ g++-4 -o cygperl5_13_4.dll --shared perlsrc.o cygwin.o  DynaLoader.o -ldl -lcrypt
  Creating library file: libperl.dll.a
  DynaLoader.o: In function `XS_DynaLoader_dl_undef_symbols':
  ext/DynaLoader/DynaLoader.c:346: undefined reference to `__imp__PL_stack_sp'
  ext/DynaLoader/DynaLoader.c:346: undefined reference to `__imp__PL_markstack_ptr'
  ext/DynaLoader/DynaLoader.c:346: undefined reference to `__imp__PL_stack_base'

ext/DynaLoader/DynaLoader_pm.PL
ext/DynaLoader/Makefile.PL

index 6ab4740..cfee108 100644 (file)
@@ -456,6 +456,7 @@ sub dl_findfile {
             # these should be ordered with the most likely first
             push(@names,"$_.$dl_dlext")    unless m/\.$dl_dlext$/o;
             push(@names,"$_.$dl_so")     unless m/\.$dl_so$/o;
+            push(@names,"cyg$_.$dl_so")  if !m:/: and $^O eq 'cygwin';
             push(@names,"lib$_.$dl_so")  unless m:/:;
             push(@names,"$_.a")          if !m/\.a$/ and $dlsrc eq "dl_dld.xs";
             push(@names, $_);
index 779523f..76c3bc0 100644 (file)
@@ -18,6 +18,15 @@ WriteMakefile(
     clean      => {FILES => 'DynaLoader.c DynaLoader.xs DynaLoader.pm'},
 );
 
+sub MY::cflags {
+  package MY;
+  my $flags = shift->SUPER::cflags(@_);
+  if ($flags =~ /-DUSEIMPORTLIB/m) {
+    $flags =~ s/-DUSEIMPORTLIB/-UUSEIMPORTLIB/m;
+  }
+  $flags;
+}
+
 sub MY::postamble {
     my $test_xs;