MS Windows needs patch to inc/GSLBuilder.pm (Math-GSL-0.25_04) #30

Closed
sisyphus opened this Issue Aug 31, 2011 · 1 comment

3 participants

@sisyphus

Hi,
It's actually 2 separate issues here.

Firstly, on Windows, it's by no means guaranteed that my gcc compiler will be called 'gcc'. In fact, my x64 compiler is called 'x86_64-w64-mingw32-gcc'.
And on some builds of ActivePerl where gcc is being used, $Config{cc} will be set to /full/path/to/gcc.
The below patch caters for these possibilities.
Note that this first issue pre-dates Math-GSL-0.25. It's not something that has just now sprung up.

Secondly, in inc/GSLBuilder.pm with Math-GSL-0.25_04 we have this line of code:
$file_base =~ s!swig/!!g;
which assumes (incorrectly) that the path separator is a forward slash. On windows, it can be either a forward slash or a backslash. The below patch also accommodates this ... though it doesn't cater for the more general (and rarer) case where the path separator is neither a forward slash nor a backslash.

--- inc/GSLBuilder.pm_orig Wed Aug 31 14:25:25 2011
+++ inc/GSLBuilder.pm Wed Aug 31 15:22:07 2011
@@ -112,6 +112,7 @@
my ($self, $main_swig_file, $ver) = @_;

 (my $file_base = $main_swig_file) =~ s/\.[^.]+$//;
  • $file_base =~ s!\!/!g; $file_base =~ s!swig/!!g; my $c_file = catfile('xs',"${file_base}_wrap.$ver.c");

@@ -215,14 +216,21 @@
unless ($self->up_to_date([$obj_file, @$objects], $lib_file)) {
my @linker_flags = $self->split_like_shell($p->{extra_linker_flags});

  • push @linker_flags, $Config{archlib} . '/CORE/' . $Config{libperl} if (is_windows() or is_darwin());
  • if(is_windows() or is_darwin()) {
  • if(is_windows() && $] eq '5.010000' && $Config{archname} =~ /x64/) {
  • push @linker_flags, $Config{bin} . '/' . $Config{libperl};
  • }
  • else {
  • push @linker_flags, $Config{archlib} . '/CORE/' . $Config{libperl};
  • }
  • }

    my @lddlflags = $self->split_like_shell($cf->{lddlflags});
    my @shrp = $self->split_like_shell($cf->{shrpenv});

  • my @ld = $self->split_like_shell($cf->{ld}) || "gcc";
  • my @ld = $self->split_like_shell($cf->{ld}) || "$Config{cc}";

    # Strip binaries if we are compiling on windows

  • push @ld, "-s" if (is_windows() && $Config{cc} eq 'gcc');
  • push @ld, "-s" if (is_windows() && $Config{cc} =~ /\bgcc\b/i);

    $self->do_system(@shrp, @ld, @lddlflags, '-o', $lib_file,
    $obj_file, @$objects, @linker_flags)
    @@ -272,7 +280,7 @@
    my @flags = (@include_dirs, @cccdlflags, '-c', @ccflags, @extra_compiler_flags, );

    my @cc = $self->split_like_shell($cf->{cc});

  • @cc = "gcc" unless @cc;
  • @cc = "$Config{cc}" unless @cc;

    $self->do_system(@cc, @flags, '-o', $obj_file, $file)
    or die "error building $Config{_o} file from '$file'";

Cheers,
Rob

@tadam

I've temporarily created gist that contains your patch: https://gist.github.com/1183195
But it will be more usable if you will create pull request with this patch.

I can't say anything about compiler options on Windows.
But the second problem with
$file_base =~ s!swig/!!g;
is my mistake.

It is more safe to change it to the following line:
(undef, undef, $file_base) = splitpath($file_base);

@leto leto closed this in dc26b32 Sep 10, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment