Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PATCH] How to use Devel::PatchPerl to repair older builds #15900

Closed
p5pRT opened this issue Feb 27, 2017 · 7 comments
Closed

[PATCH] How to use Devel::PatchPerl to repair older builds #15900

p5pRT opened this issue Feb 27, 2017 · 7 comments

Comments

@p5pRT
Copy link

p5pRT commented Feb 27, 2017

Migrated from rt.perl.org#130885 (status was 'resolved')

Searchable as RT130885$

@p5pRT
Copy link
Author

p5pRT commented Feb 27, 2017

From @jkeenan

Created by @jkeenan

The patch attached reflects discussion on #p5p today and is
documentation-only. The patch discusses when and how someone
debugging problems in the core distribution would use CPAN
library Devel​::PatchPerl to get perl to build at an old commit.

Thanks to alh for guidance.

Please review.

Perl Info

Flags:
     category=docs
     severity=wishlist

Site configuration information for perl 5.12.5:

Configured by jkeenan at Sun Feb 26 21:10:57 EST 2017.

Summary of my perl5 (revision 5 version 12 subversion 5) configuration:

   Platform:
     osname=linux, osvers=4.4.0-64-generic, archname=x86_64-linux
     uname='linux zareason 4.4.0-64-generic #85-ubuntu smp mon feb 20 
11:50:30 utc 2017 x86_64 x86_64 x86_64 gnulinux '
     config_args='-de 
-Dprefix=/home/jkeenan/perl5/perlbrew/perls/perl-5.12.5 
-Aeval:scriptdir=/home/jkeenan/perl5/perlbrew/perls/perl-5.12.5/bin'
     hint=recommended, useposix=true, d_sigaction=define
     useithreads=undef, usemultiplicity=undef
     useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
     use64bitint=define, use64bitall=define, uselongdouble=undef
     usemymalloc=n, bincompat5005=undef
   Compiler:
     cc='cc', ccflags ='-fno-strict-aliasing -pipe -fstack-protector 
-I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
     optimize='-O2',
     cppflags='-fno-strict-aliasing -pipe -fstack-protector 
-I/usr/local/include'
     ccversion='', gccversion='5.4.0 20160609', gccosandvers=''
     intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
     d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
     ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', 
lseeksize=8
     alignbytes=8, prototype=define
   Linker and Libraries:
     ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
     libpth=/usr/local/lib /lib/x86_64-linux-gnu /lib/../lib 
/usr/lib/x86_64-linux-gnu /usr/lib/../lib /lib /usr/lib /lib64 /usr/lib64
     libs=-lnsl -ldb -ldl -lm -lcrypt -lutil -lc
     perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
     libc=libc-2.23.so, so=so, useshrplib=false, libperl=libperl.a
     gnulibc_version='2.23'
   Dynamic Linking:
     dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
     cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib 
-fstack-protector'

Locally applied patches:
     Devel::PatchPerl 1.38


@INC for perl 5.12.5:
 
/home/jkeenan/perl5/perlbrew/perls/perl-5.12.5/lib/site_perl/5.12.5/x86_64-linux
     /home/jkeenan/perl5/perlbrew/perls/perl-5.12.5/lib/site_perl/5.12.5
     /home/jkeenan/perl5/perlbrew/perls/perl-5.12.5/lib/5.12.5/x86_64-linux
     /home/jkeenan/perl5/perlbrew/perls/perl-5.12.5/lib/5.12.5
     .


Environment for perl 5.12.5:
     HOME=/home/jkeenan
     LANG=en_US.UTF-8
     LANGUAGE=en_US
     LD_LIBRARY_PATH (unset)
     LOGDIR (unset)
 
PATH=/home/jkeenan/perl5/perlbrew/bin:/home/jkeenan/perl5/perlbrew/perls/perl-5.12.5/bin:/usr/lib/ccache:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/jkeenan/bin:/home/jkeenan/bin/perl:/home/jkeenan/bin/shell
     PERLBREW_BASHRC_VERSION=0.78
     PERLBREW_HOME=/home/jkeenan/.perlbrew
     PERLBREW_MANPATH=/home/jkeenan/perl5/perlbrew/perls/perl-5.12.5/man
 
PERLBREW_PATH=/home/jkeenan/perl5/perlbrew/bin:/home/jkeenan/perl5/perlbrew/perls/perl-5.12.5/bin
     PERLBREW_PERL=perl-5.12.5
     PERLBREW_ROOT=/home/jkeenan/perl5/perlbrew
     PERLBREW_VERSION=0.78
     PERL_BADLANG (unset)
     PERL_WORKDIR=/home/jkeenan/gitwork/perl
     SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Feb 27, 2017

From @jkeenan

0001-When-and-how-to-use-Devel-PatchPerl-to-repair-older-.patch
From 07b35b6fe060e658ccb06d46362abdef0e8c8f34 Mon Sep 17 00:00:00 2001
From: James E Keenan <jkeenan@cpan.org>
Date: Mon, 27 Feb 2017 12:24:25 -0500
Subject: [PATCH] When and how to use Devel::PatchPerl to repair older builds.

Following recommendation by Matthew Horsfall.
---
 pod/perlgit.pod                |  7 ++++++
 pod/perlhack.pod               | 49 ++++++++++++++++++++++++++++++++++++++++++
 t/porting/known_pod_issues.dat |  1 +
 3 files changed, 57 insertions(+)

diff --git a/pod/perlgit.pod b/pod/perlgit.pod
index 9d3edcc..12aace2 100644
--- a/pod/perlgit.pod
+++ b/pod/perlgit.pod
@@ -481,6 +481,13 @@ the "first commit where the bug is solved".
 C<git help bisect> has much more information on how you can tweak your
 binary searches.
 
+Following bisection you may wish to configure, build and test perl at
+commits identified by the bisection process.  Sometimes, particularly
+with older perls, C<make> may fail during this process.  In this case
+you may be able to patch the source code at the older commit point.  To
+do so, please follow the suggestions provided in
+L<perlhack/Building perl at older commits>.
+
 =head2 Topic branches and rewriting history
 
 Individual committers should create topic branches under
diff --git a/pod/perlhack.pod b/pod/perlhack.pod
index c8c6b86..7572d83 100644
--- a/pod/perlhack.pod
+++ b/pod/perlhack.pod
@@ -1041,6 +1041,55 @@ is broken (for example, the utf8 length cache on long utf8 strings).
 Add a test that will take a fraction of a second normally, and minutes
 otherwise, causing the test file to time out on failure.
 
+=head2 Building perl at older commits
+
+In the course of hacking on the Perl core distribution, you may have occasion
+to configure, build and test perl at an old commit.  Sometimes C<make> will
+fail during this process.  If that happens, you may be able to salvage the
+situation by using the Devel::PatchPerl library from CPAN (not included in the
+core) to bring the source code at that commit to a buildable state.
+
+Here's a real world example, taken from work done to resolve
+L<perl #72414|https://rt.perl.org/Ticket/Display.html?id=72414>.
+Use of F<Porting/bisect.pl> had identified commit
+C<ba77e4cc9d1ceebf472c9c5c18b2377ee47062e6> as the commit in which a bug was
+corrected.  To confirm, a P5P developer wanted to configure and build perl at
+commit C<ba77e4c^> (presumably "bad") and then at C<ba77e4c> (presumably
+"good").  Normal configuration and build was attempted:
+
+    $ sh ./Configure -des -Dusedevel
+    $ make test_prep
+
+C<make>, however, failed with output (excerpted) like this:
+
+    cc -fstack-protector -L/usr/local/lib -o miniperl \
+      gv.o toke.o perly.o pad.o regcomp.o dump.o util.o \
+      mg.o reentr.o mro.o hv.o av.o run.o pp_hot.o sv.o \
+      pp.o scope.o pp_ctl.o pp_sys.o doop.o doio.o regexec.o \
+      utf8.o taint.o deb.o universal.o globals.o perlio.o \
+      perlapi.o numeric.o mathoms.o locale.o pp_pack.o pp_sort.o  \
+      miniperlmain.o opmini.o perlmini.o
+    pp.o: In function `Perl_pp_pow':
+    pp.c:(.text+0x2db9): undefined reference to `pow'
+    ...
+    collect2: error: ld returned 1 exit status
+    makefile:348: recipe for target 'miniperl' failed
+    make: *** [miniperl] Error 1
+
+Another P5P contributor recommended installation and use of Devel::PatchPerl
+for this situation, first to determine the version of perl at the commit in
+question, then to patch the source code at that point to facilitate a build.
+
+    $ perl -MDevel::PatchPerl -e \
+        'print Devel::PatchPerl->determine_version("/path/to/sourcecode"), "\n";'
+    5.11.1
+    $ perl -MDevel::PatchPerl -e \
+        'Devel::PatchPerl->patch_source("5.11.1", "/path/to/sourcecode");'
+
+Once the source was patched, C<./Configure> and C<make test_prep> were called
+and completed successfully, enabling confirmation of the findings in RT
+#72414.
+
 =head1 MORE READING FOR GUTS HACKERS
 
 To hack on the Perl guts, you'll need to read the following things:
diff --git a/t/porting/known_pod_issues.dat b/t/porting/known_pod_issues.dat
index 44c13ff..ebe09a9 100644
--- a/t/porting/known_pod_issues.dat
+++ b/t/porting/known_pod_issues.dat
@@ -343,6 +343,7 @@ pod/perlgit.pod	? Should you be using F<...> or maybe L<...> instead of	1
 pod/perlgit.pod	Verbatim line length including indents exceeds 79 by	1
 pod/perlguts.pod	? Should you be using L<...> instead of	1
 pod/perlhack.pod	? Should you be using L<...> instead of	1
+pod/perlhack.pod	Verbatim line length including indents exceeds 79 by	2
 pod/perlhist.pod	Verbatim line length including indents exceeds 79 by	1
 pod/perlhpux.pod	Verbatim line length including indents exceeds 79 by	1
 pod/perlinterp.pod	? Should you be using L<...> instead of	1
-- 
2.7.4

@p5pRT
Copy link
Author

p5pRT commented Feb 28, 2017

From @xsawyerx

On 02/27/2017 08​:15 PM, James E Keenan (via RT) wrote​:

# New Ticket Created by James E Keenan
# Please include the string​: [perl #130885]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl5/Ticket/Display.html?id=130885 >

This is a bug report for perl from jkeenan@​cpan.org,
generated with the help of perlbug 1.39 running under perl 5.12.5.

-----------------------------------------------------------------
[Please describe your issue here]

The patch attached reflects discussion on #p5p today and is
documentation-only. The patch discusses when and how someone
debugging problems in the core distribution would use CPAN
library Devel​::PatchPerl to get perl to build at an old commit.

I like this patch and these kinds of patches. :)

@p5pRT
Copy link
Author

p5pRT commented Feb 28, 2017

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Feb 28, 2017

From @wolfsage

On Tue, Feb 28, 2017 at 8​:15 AM, Matthew Horsfall (alh)
<wolfsage@​gmail.com> wrote​:

On Tue, Feb 28, 2017 at 4​:42 AM, Sawyer X <xsawyerx@​gmail.com> wrote​:

On 02/27/2017 08​:15 PM, James E Keenan (via RT) wrote​:

The patch attached reflects discussion on #p5p today and is
documentation-only. The patch discusses when and how someone
debugging problems in the core distribution would use CPAN
library Devel​::PatchPerl to get perl to build at an old commit.

I like this patch and these kinds of patches. :)

Agreed! Thanks James, I wasn't even aware of 'determine_version'!

-- Matthew Horsfall (alh)

@p5pRT
Copy link
Author

p5pRT commented Jun 1, 2017

From @jkeenan

On Tue, 28 Feb 2017 09​:43​:36 GMT, xsawyerx@​gmail.com wrote​:

On 02/27/2017 08​:15 PM, James E Keenan (via RT) wrote​:

# New Ticket Created by James E Keenan
# Please include the string​: [perl #130885]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl5/Ticket/Display.html?id=130885 >

This is a bug report for perl from jkeenan@​cpan.org,
generated with the help of perlbug 1.39 running under perl 5.12.5.

-----------------------------------------------------------------
[Please describe your issue here]

The patch attached reflects discussion on #p5p today and is
documentation-only. The patch discusses when and how someone
debugging problems in the core distribution would use CPAN
library Devel​::PatchPerl to get perl to build at an old commit.

I like this patch and these kinds of patches. :)

Applied to blead in ca31f56. Marking ticket Resolved.

Thank you very much.

--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

p5pRT commented Jun 1, 2017

@jkeenan - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant