Submitted By: Ken Moffat Date: 2015-04-17 Initial Package Version: 5.20.2 Upstream Status: Committed Origin: Petr Pisař and Tony Cook Description: Fixes Errno.pm and h2ph with gcc-5. 1. cherry-picked because the change to $version will not apply, from commit 816b056ffb99ae54642320e20dc30a59fd1effef Author: Petr Písař Date: Wed Feb 11 15:46:37 2015 +0100 Fix Errno.pm generation for gcc-5.0 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 diff --git a/ext/Errno/Errno_pm.PL b/ext/Errno/Errno_pm.PL index 3dadfce..c6bfa06 100644 --- a/ext/Errno/Errno_pm.PL +++ b/ext/Errno/Errno_pm.PL @@ -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"; } commit 3bea78d24634e630b610f59957e7a019205a67b2 Author: Tony Cook Date: Mon Feb 16 15:57:00 2015 +1100 h2ph: correct handling of hex constants for the preamble Previously they were treated as identifiers resulting in code generated like C< &0xFFF >. We also try to prevent compile-time warnings from large hex integers, the user isn't responsible for the generated code, so we delay those warnings to run-time. diff --git a/utils/h2ph.PL b/utils/h2ph.PL index 9a8b14d..d082f22 100644 --- 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}) {