This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Make ExtUtils::CBuilder throw an exception on Windows on linker errors
[perl5.git] / dist / ExtUtils-CBuilder / lib / ExtUtils / CBuilder / Platform / darwin.pm
1 package ExtUtils::CBuilder::Platform::darwin;
2
3 use warnings;
4 use strict;
5 use ExtUtils::CBuilder::Platform::Unix;
6 use Config;
7
8 our $VERSION = '0.280240'; # VERSION
9 our @ISA = qw(ExtUtils::CBuilder::Platform::Unix);
10
11 my ($osver) = split /\./, $Config{osvers};
12 my $apple_cor = $^X eq "/usr/bin/perl" && $osver >= 18;
13
14 sub compile {
15   my $self = shift;
16   my $cf = $self->{config};
17
18   # -flat_namespace isn't a compile flag, it's a linker flag.  But
19   # it's mistakenly in Config.pm as both.  Make the correction here.
20   local $cf->{ccflags} = $cf->{ccflags};
21   $cf->{ccflags} =~ s/-flat_namespace//;
22
23   # XCode 12 makes this fatal, breaking tons of XS modules
24   $cf->{ccflags} .= ($cf->{ccflags} ? ' ' : '').'-Wno-error=implicit-function-declaration';
25
26   $self->SUPER::compile(@_);
27 }
28
29 sub arg_include_dirs {
30     my $self = shift;
31
32     if ($apple_cor) {
33         my $perl_inc = $self->perl_inc;
34         return map {
35            $_ eq $perl_inc ? ("-iwithsysroot", $_ ) : "-I$_"
36         } @_;
37     }
38     else {
39         return $self->SUPER::arg_include_dirs(@_);
40     }
41 }
42
43 1;