From: Vincent Pit Date: Fri, 21 Sep 2012 14:07:13 +0000 (+0200) Subject: Force linking against the perl dll when using gcc 3.4 on Windows X-Git-Tag: v0.21~2 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=74200f41d79b6ff3e7b655d601180064bb8dd624;p=perl%2Fmodules%2FScope-Upper.git 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 33d3290..b86ec83 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -13,6 +13,7 @@ for ($pl, $desc) { } my @DEFINES; +my %macro; print "Checking if this is an official release of perl... "; my $is_release = ("$]" < 5.011) ? (defined($pl) || defined($desc) ? 0 : 1) @@ -20,12 +21,32 @@ my $is_release = ("$]" < 5.011) ? (defined($pl) || defined($desc) ? 0 : 1) push @DEFINES, "-DSU_RELEASE=$is_release"; print $is_release ? "yes\n" : "no\n"; +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' && "$]" < 5.009) { push @DEFINES, '-DSU_MULTIPLICITY=0'; } @DEFINES = (DEFINE => join ' ', @DEFINES) if @DEFINES; +%macro = (macro => { %macro }) if %macro; # Beware of the cycle my $dist = 'Scope-Upper'; @@ -82,6 +103,7 @@ WriteMakefile( clean => { FILES => "$dist-* *.gcov *.gcda *.gcno cover_db Debian_CPANTS.txt*" }, + %macro, ); package MY;