Subject: | Time::HiRes does not build in cpan under ActivePerl 1007 (Perl 5.10.1) (patch included) |
ActicePerl Build 1007 is distributed with MinGW 3.4.5 included. This
means it is perfectly feasible to compile Perl modules on this platform
successfully without human intervention.
However some perl modules end up with broken libraries when attempting
to do this, which is apparently connected to some unique "features" of
MinGW 3.4.5.
Time::HiRes is one of these modules. With a reverse dependency count of
1877 CPAN modules it is in fact one of the most important modules that
should be fixed in this regard.
Recently i worked with Vincent Pit to help him reproduce and pinpoint
the problem in his module Variable::Magic, which allowed him to fix the
same issue Time::HiRes has.
As a test i applied his change to your Makefile.PL and was able to
successfully compile and test the dll.
I do not pretend to understand his fix, because i am not a C
programmer. All i know on a high level is that it makes the compiler
link against the system's perl dll when gcc 3.4 is detected.
You can find the patch attached to this bug report.
Subject: | patch.diff |
diff --git a/Makefile.PL b/Makefile.PL
index 16990ee..29e4a79 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -746,6 +746,32 @@ EOM
}
}
+sub make_macro_params {
+ my %macro;
+ my $is_gcc_34 = 0;
+ print "Checking if this is gcc 3.4 on Windows trying to link against an import library... ";
+ if ($^O eq 'MSWin32' and not grep /^LD[A-Z]*=/, @ARGV) {
+ my ($libperl, $gccversion) = map $_ || '', @Config{qw/libperl gccversion/};
+ if ($gccversion =~ /^3\.4\.[0-9]+/ and $libperl =~ s/\.lib$//) {
+ $is_gcc_34 = 1;
+ my ($lddlflags, $ldflags) = @Config{qw/lddlflags ldflags/};
+ $_ ||= '', s/-L(?:".*?"|\S+)//g for $lddlflags, $ldflags;
+ $libperl = "-l$libperl";
+ my $libdirs = join ' ',
+ map { s/(?<!\\)((?:\\\\)*")/\\$1/g; qq[-L"$_"] }
+ @Config{qw/bin sitebin/};
+ $macro{LDDLFLAGS} = "$lddlflags $libdirs $libperl";
+ $macro{LDFLAGS} = "$ldflags $libdirs $libperl";
+ $macro{PERL_ARCHIVE} = '',
+ }
+ }
+ print $is_gcc_34 ? "yes\n" : "no\n";
+
+ %macro = ( macro => { %macro } ) if %macro; # Beware of the circle
+
+ return %macro;
+}
+
sub doMakefile {
my @makefileopts = ();
@@ -757,6 +783,7 @@ sub doMakefile {
DEFINE('ATLEASTFIVEOHOHFIVE');
}
+ my %macro = make_macro_params();
push (@makefileopts,
'NAME' => 'Time::HiRes',
'VERSION_FROM' => 'HiRes.pm', # finds $VERSION
@@ -774,6 +801,7 @@ sub doMakefile {
},
clean => { FILES => "xdefine" },
realclean => { FILES=> 'const-c.inc const-xs.inc' },
+ %macro,
);
if ($ENV{PERL_CORE}) {