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
CommitLineData
6b09c160 1package ExtUtils::CBuilder::Platform::darwin;
c39276c1 2
83dcc064 3use warnings;
6b09c160
YST
4use strict;
5use ExtUtils::CBuilder::Platform::Unix;
e3066f81 6use Config;
6b09c160 7
8bae84e5 8our $VERSION = '0.280240'; # VERSION
1a58b39a 9our @ISA = qw(ExtUtils::CBuilder::Platform::Unix);
6b09c160 10
e3066f81
TC
11my ($osver) = split /\./, $Config{osvers};
12my $apple_cor = $^X eq "/usr/bin/perl" && $osver >= 18;
13
6b09c160
YST
14sub 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//;
7fc0439b
CBW
22
23 # XCode 12 makes this fatal, breaking tons of XS modules
24 $cf->{ccflags} .= ($cf->{ccflags} ? ' ' : '').'-Wno-error=implicit-function-declaration';
25
6b09c160
YST
26 $self->SUPER::compile(@_);
27}
28
e3066f81
TC
29sub 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}
6b09c160
YST
42
431;