From: Vincent Pit Date: Tue, 5 Mar 2013 00:12:52 +0000 (-0300) Subject: Force linking against the perl dll when using gcc 3.4 on Windows X-Git-Tag: rt83659~1 X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2Findirect.git;a=commitdiff_plain;h=4e2370e14767646be62be5902c16580a75a55eed Force linking against the perl dll when using gcc 3.4 on Windows When a Windows perl links an XS shared object to an import library using gcc/g++ version 3.4.x, strange breakage happens at load time because the mutex-related symbols seems not to be reachable. This situation happens especially for AS perl and the default compiler suite it installs. We fix this by forcing g++ to link against the dll instead, which should be in the same directory as the perl executable (at least for AS perl). --- diff --git a/Makefile.PL b/Makefile.PL index dd01441..b0c82a6 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -4,7 +4,29 @@ use strict; use warnings; use ExtUtils::MakeMaker; +use Config; + my @DEFINES; +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}; + if ($gccversion =~ /^3\.4\.[0-9]+/ and $libperl =~ s/\.lib$//) { + $is_gcc_34 = 1; + my ($lddlflags, $ldflags) = @Config{qw}; + $_ ||= '', s/-L(?:".*?"|\S+)//g for $lddlflags, $ldflags; + $libperl = "-l$libperl"; + my $libdirs = join ' ', + map { s/(?}; + $macro{LDDLFLAGS} = "$lddlflags $libdirs $libperl"; + $macro{LDFLAGS} = "$ldflags $libdirs $libperl"; + $macro{PERL_ARCHIVE} = '', + } +} +print $is_gcc_34 ? "yes\n" : "no\n"; # Threads, Windows and 5.8.x don't seem to be best friends if ($^O eq 'MSWin32' and "$]" < 5.009) { @@ -17,6 +39,7 @@ if ($^O eq 'MSWin32' and "$]" < 5.010_001) { } @DEFINES = (DEFINE => join ' ', @DEFINES) if @DEFINES; +%macro = (macro => { %macro }) if %macro; # Beware of the circle my $dist = 'indirect'; @@ -31,6 +54,7 @@ my %PREREQ_PM = ( ); my %BUILD_REQUIRES =( + 'Config' => 0, 'ExtUtils::MakeMaker' => 0, 'Test::More' => 0, %PREREQ_PM, @@ -38,6 +62,7 @@ my %BUILD_REQUIRES =( my %META = ( configure_requires => { + 'Config' => 0, 'ExtUtils::MakeMaker' => 0, }, build_requires => { @@ -71,4 +96,5 @@ WriteMakefile( clean => { FILES => "$dist-* *.gcov *.gcda *.gcno cover_db Debian_CPANTS.txt*" }, + %macro, );