Errno module is broken by preprocessor changes in GCC 5.1 Fix integer overflow issue in h2ph https://bugs.gentoo.org/548094 https://rt.perl.org/Public/Bug/Display.html?id=123784 https://github.com/Perl/perl5/commit/816b056ffb99ae54642320e20dc30a59fd1effef https://github.com/Perl/perl5/commit/3bea78d24634e630b610f59957e7a019205a67b2 --- a/ext/Errno/Errno_pm.PL +++ b/ext/Errno/Errno_pm.PL @@ -225,20 +225,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"; } --- a/utils/h2ph.PL +++ b/utils/h2ph.PL @@ -769,7 +769,7 @@ sub inc_dirs sub build_preamble_if_necessary { # Increment $VERSION every time this function is modified: - my $VERSION = 3; + my $VERSION = 4; my $preamble = "$Dest_dir/_h2ph_pre.ph"; # Can we skip building the preamble file? @@ -788,6 +788,11 @@ sub build_preamble_if_necessary open PREAMBLE, ">$preamble" or die "Cannot open $preamble: $!"; print PREAMBLE "# This file was created by h2ph version $VERSION\n"; + # Prevent non-portable hex constants from warning. + # + # We still produce an overflow warning if we can't represent + # a hex constant as an integer. + print PREAMBLE "no warnings qw(portable);\n"; foreach (sort keys %define) { if ($opt_D) { @@ -814,6 +819,18 @@ DEFINE # integer: print PREAMBLE "unless (defined &$_) { sub $_() { $1 } }\n\n"; + } elsif ($define{$_} =~ /^([+-]?0x[\da-f]+)U?L{0,2}$/i) { + # hex integer + # Special cased, since perl warns on hex integers + # that can't be represented in a UV. + # + # This way we get the warning at time of use, so the user + # only gets the warning if they happen to use this + # platform-specific definition. + my $code = $1; + $code = "hex('$code')" if length $code > 10; + print PREAMBLE + "unless (defined &$_) { sub $_() { $code } }\n\n"; } elsif ($define{$_} =~ /^\w+$/) { my $def = $define{$_}; if ($isatype{$def}) {