From cc7e77fd5a0ee9f1498e54dddf566117da62754b Mon Sep 17 00:00:00 2001 From: Reini Urban Date: Tue, 14 Sep 2010 17:48:32 +0200 Subject: [PATCH] CYG14 Dynaloader without USEIMPORTLIB, and search cyg prefix 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 | 1 + ext/DynaLoader/Makefile.PL | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/ext/DynaLoader/DynaLoader_pm.PL b/ext/DynaLoader/DynaLoader_pm.PL index 6ab4740..cfee108 100644 --- a/ext/DynaLoader/DynaLoader_pm.PL +++ b/ext/DynaLoader/DynaLoader_pm.PL @@ -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, $_); diff --git a/ext/DynaLoader/Makefile.PL b/ext/DynaLoader/Makefile.PL index 779523f..76c3bc0 100644 --- a/ext/DynaLoader/Makefile.PL +++ b/ext/DynaLoader/Makefile.PL @@ -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; -- 2.7.4