Skip to content

Commit

Permalink
Fix Errno.pm generation for gcc-5.0
Browse files Browse the repository at this point in the history
gcc-5.0 -E interleaves now line numbers with expended macros, so that
the generated errno.c will be preprocessed to

EBFONT => [[
           59
                ]]

which is hard to parse in in line-based reader.

So use -P option with gcc >= 5.0. Global -P usage would break makedepend,
global -ftrack-macro-expansion=0 would break lib/h2ph.t.

RT#123784
  • Loading branch information
ppisar authored and tonycoz committed Feb 16, 2015
1 parent 5bd81aa commit 816b056
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions ext/Errno/Errno_pm.PL
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use ExtUtils::MakeMaker;
use Config;
use strict;

our $VERSION = "1.22";
our $VERSION = "1.23";

my %err = ();

Expand Down Expand Up @@ -215,20 +215,31 @@ sub write_errno_pm {
{ # BeOS (support now removed) did not enter this block
# invoke CPP and read the output

my $inhibit_linemarkers = '';
if ($Config{gccversion} =~ /\A(\d+)\./ and $1 >= 5) {
# GCC 5.0 interleaves expanded macros with line numbers breaking
# each line into multiple lines. RT#123784
$inhibit_linemarkers = ' -P';
}

if ($^O eq 'VMS') {
my $cpp = "$Config{cppstdin} $Config{cppflags} $Config{cppminus}";
my $cpp = "$Config{cppstdin} $Config{cppflags}" .
$inhibit_linemarkers . " $Config{cppminus}";
$cpp =~ s/sys\$input//i;
open(CPPO,"$cpp errno.c |") or
die "Cannot exec $Config{cppstdin}";
} elsif ($IsMSWin32 || $^O eq 'NetWare') {
open(CPPO,"$Config{cpprun} $Config{cppflags} errno.c |") or
die "Cannot run '$Config{cpprun} $Config{cppflags} errno.c'";
my $cpp = "$Config{cpprun} $Config{cppflags}" .
$inhibit_linemarkers;
open(CPPO,"$cpp errno.c |") or
die "Cannot run '$cpp errno.c'";
} elsif ($IsSymbian) {
my $cpp = "gcc -E -I$ENV{SDK}\\epoc32\\include\\libc -";
my $cpp = "gcc -E -I$ENV{SDK}\\epoc32\\include\\libc" .
$inhibit_linemarkers ." -";
open(CPPO,"$cpp < errno.c |")
or die "Cannot exec $cpp";
} else {
my $cpp = default_cpp();
my $cpp = default_cpp() . $inhibit_linemarkers;
open(CPPO,"$cpp < errno.c |")
or die "Cannot exec $cpp";
}
Expand Down

0 comments on commit 816b056

Please sign in to comment.