Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'errno' into 'master'
Fix Errno.pm generation for gcc-5.0 and later.

See merge request mer-core/perl!6
  • Loading branch information
Matti Kosola committed Jan 30, 2020
2 parents 8e85911 + c6a038b commit 0628433
Show file tree
Hide file tree
Showing 6 changed files with 177 additions and 2 deletions.
66 changes: 66 additions & 0 deletions errno1-Fix-Errno.pm-generation-for-gcc-5.0.patch
@@ -0,0 +1,66 @@
From 7770a3f431b07efcb0965e3853b4310850505e9e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Wed, 11 Feb 2015 15:46:37 +0100
Subject: [PATCH] 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
---
ext/Errno/Errno_pm.PL | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/ext/Errno/Errno_pm.PL b/ext/Errno/Errno_pm.PL
index 439f2544ca..a324604a99 100644
--- a/ext/Errno/Errno_pm.PL
+++ b/ext/Errno/Errno_pm.PL
@@ -242,20 +242,31 @@ sub write_errno_pm {
unless ($^O eq 'beos') { # trust what we have / get later
# 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";
}
--
2.20.1

59 changes: 59 additions & 0 deletions errno2-h2ph-correct-handling-of-hex-constants.patch
@@ -0,0 +1,59 @@
From 3bea78d24634e630b610f59957e7a019205a67b2 Mon Sep 17 00:00:00 2001
From: Tony Cook <tony@develop-help.com>
Date: Mon, 16 Feb 2015 15:57:00 +1100
Subject: [PATCH] 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.
---
utils/h2ph.PL | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/utils/h2ph.PL b/utils/h2ph.PL
index 9a8b14dca8b..d082f227232 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}) {
36 changes: 36 additions & 0 deletions errno3-lib-h2ph.t-to-test-generated-t-_h2ph_pre.ph.patch
@@ -0,0 +1,36 @@
From 33593911f214382b592d05aa902655301915e666 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Tue, 17 Feb 2015 13:11:00 +0100
Subject: [PATCH] lib/h2ph.t to test generated t/_h2ph_pre.ph instead of the
system one
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The lib/h2ph.t test executes a t/lib/h2ph.pht which requires
'_h2ph_pre.ph'. This should find and exercise generated t/_h2ph_pre.ph
file. However, it found a loaded _h2ph_pre.ph from system because the
interpreter has the './' directory after the system paths in the @INC by
default.

This patch adds '-I./' to the runperl() invocation to prefer the
_h2ph_pre.ph generated at build time.

Signed-off-by: Petr Písař <ppisar@redhat.com>
---
lib/h2ph.t | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/h2ph.t b/lib/h2ph.t
index 2b58f6adae9..64d9dc080f4 100644
--- a/lib/h2ph.t
+++ b/lib/h2ph.t
@@ -48,7 +48,7 @@ $result = runperl( progfile => '_h2ph_pre.ph',
stderr => 1 );
like( $result, qr/syntax OK$/, "preamble compiles");

-$result = runperl( switches => ["-w"],
+$result = runperl( switches => ['-I.', "-w"],
stderr => 1,
prog => <<'PROG' );
$SIG{__WARN__} = sub { die $_[0] }; require q(lib/h2ph.pht);
Binary file renamed perl-5.16.1.tar.bz2 → perl-5.16.3.tar.bz2
Binary file not shown.
5 changes: 5 additions & 0 deletions perl.changes
@@ -1,3 +1,8 @@
* Thu Jan 30 2020 Juho Hämäläinen <juho.hamalainen@jolla.com> - 5.16.3-1
- Update to Perl version 5.16.3.
- Fix Errno.pm generation for gcc-5.0 and later.
Fixes JB#48351

* Mon Aug 12 2019 Niels Breet <niels.breet@jolla.com> - 5.16.1-3
- Remove gdbm support
Fixes JB#46707
Expand Down
13 changes: 11 additions & 2 deletions perl.spec
@@ -1,4 +1,4 @@
%global perl_version 5.16.1
%global perl_version 5.16.3
%global perl_epoch 2
%global perl_arch_stem -thread-multi
%global perl_archname %{_arch}-%{_os}%{perl_arch_stem}
Expand All @@ -25,7 +25,7 @@

Name: perl
Version: %{perl_version}
Release: 3
Release: 1
Epoch: %{perl_epoch}
Summary: Practical Extraction and Report Language
Group: Development/Languages
Expand Down Expand Up @@ -82,6 +82,11 @@ Patch11: perl-5.12.1-notimestamps.patch

Patch12: perl-5.12.1-norebuilds.patch

# Fix Errno.pm generation for gcc-5.0
Patch13: errno1-Fix-Errno.pm-generation-for-gcc-5.0.patch
Patch14: errno2-h2ph-correct-handling-of-hex-constants.patch
Patch15: errno3-lib-h2ph.t-to-test-generated-t-_h2ph_pre.ph.patch

#
# Update some of the bundled modules
# see http://fedoraproject.org/wiki/Perl/perl.spec for instructions
Expand All @@ -93,6 +98,7 @@ BuildRequires: gdbm-devel

# The long line of Perl provides.
# Compat provides
Provides: perl(:MODULE_COMPAT_5.16.3)
Provides: perl(:MODULE_COMPAT_5.16.1)
Provides: perl(:MODULE_COMPAT_5.16.0)
Provides: perl(:MODULE_COMPAT_5.12.1)
Expand Down Expand Up @@ -1149,6 +1155,9 @@ tarball from perl.org.
%patch10 -p1
%patch11 -p1
%patch12 -p1
%patch13 -p1
%patch14 -p1
%patch15 -p1

#copy the example script
cp -a %{SOURCE5} .
Expand Down

0 comments on commit 0628433

Please sign in to comment.