From 2d6be9e8e8c3901a61689cd021e74d53f8ed28e1 Mon Sep 17 00:00:00 2001 From: Niko Tyni <ntyni@debian.org> Date: Mon, 30 May 2011 22:54:24 +0300 Subject: [PATCH] Append CCFLAGS to $Config{ccflags} instead of overriding it As seen in http://bugs.debian.org/628522 and https://rt.cpan.org/Ticket/Display.html?id=67990 compiling XS extensions without $Config{ccflags} can break the binary interface on some platforms. There does not seem to be any correct use case for compiling a module without $Config{ccflags}, so any extra CCFLAGS should be appended to those rather than overriding them. --- lib/ExtUtils/MM_Unix.pm | 6 +++++- t/MM_Unix.t | 8 ++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/cpan/ExtUtils-MakeMaker/lib/ExtUtils/MM_Unix.pm b/lib/ExtUtils/MM_Unix.pm index a3b7e9d..5e0758a 100644 --- a/cpan/ExtUtils-MakeMaker/lib/ExtUtils/MM_Unix.pm +++ b/cpan/ExtUtils-MakeMaker/lib/ExtUtils/MM_Unix.pm @@ -250,7 +250,11 @@ sub cflags { $cflags{$_} =~ s/^\s+//; $cflags{$_} =~ s/\s+/ /g; $cflags{$_} =~ s/\s+$//; - $self->{uc $_} ||= $cflags{$_}; + if (/ccflags/ && $self->{uc $_}) { + $self->{uc $_} = "$cflags{$_} " . $self->{uc $_}; + } else { + $self->{uc $_} ||= $cflags{$_}; + } } if ($self->{POLLUTE}) { diff --git a/cpan/ExtUtils-MakeMaker/t/MM_Unix.t b/t/MM_Unix.t index 55c29e3..5f76e08 100644 --- a/cpan/ExtUtils-MakeMaker/t/MM_Unix.t +++ b/cpan/ExtUtils-MakeMaker/t/MM_Unix.t @@ -12,7 +12,7 @@ BEGIN { plan skip_all => 'Non-Unix platform'; } else { - plan tests => 110; + plan tests => 112; } } @@ -20,6 +20,7 @@ BEGIN { use_ok( 'ExtUtils::MM_Unix' ); } use strict; use File::Spec; +use Config; my $class = 'ExtUtils::MM_Unix'; @@ -220,6 +221,9 @@ foreach (qw/ EXPORT_LIST PERL_ARCHIVE PERL_ARCHIVE_AFTER /) $t->cflags(); # Brief bug where CCFLAGS was being blown away - is( $t->{CCFLAGS}, '-DMY_THING', 'cflags retains CCFLAGS' ); + like( $t->{CCFLAGS}, "/-DMY_THING/", 'cflags retains CCFLAGS' ); + + like( $t->{CCFLAGS}, "/\Q$Config{ccflags}\E/", 'cflags does not override $Config{ccflags} with CCFLAGS' ); + like( $t->{CCFLAGS}, '/ -DMY_THING$/', 'cflags appends CCFLAGS to $Config{ccflags}' ); } -- 1.7.5.1