4 use Getopt::Long qw(:config bundling no_auto_abbrev);
9 = qw(none config.sh config.h miniperl lib/Config.pm Fcntl perl test_prep);
14 clean => 1, # mostly for debugging this
17 # We accept #!./miniperl and #!./perl
18 # We don't accept #!miniperl and #!perl as their intent is ambiguous
19 my $run_with_our_perl = qr{\A#!(\./(?:mini)?perl)\b};
21 my $linux64 = `uname -sm` eq "Linux x86_64\n" ? '64' : '';
26 # This is the search logic for a multi-arch library layout
27 # added to linux.sh in commits 40f026236b9959b7 and dcffd848632af2c7.
28 my $gcc = -x '/usr/bin/gcc' ? '/usr/bin/gcc' : 'gcc';
30 foreach (`$gcc -print-search-dirs`) {
31 next unless /^libraries: =(.*)/;
32 foreach (split ':', $1) {
39 push @paths, map {$_ . $linux64} qw(/usr/local/lib /lib /usr/lib)
48 (@paths ? (libpth => \@paths) : ()),
51 # Needed for the 'ignore_versioned_solibs' emulation below.
52 push @paths, qw(/usr/local/lib /lib /usr/lib)
55 unless(GetOptions(\%options,
56 'target=s', 'make=s', 'jobs|j=i', 'expect-pass=i',
57 'expect-fail' => sub { $options{'expect-pass'} = 0; },
58 'clean!', 'one-liner|e=s', 'c', 'l', 'w', 'match=s',
60 $options{match} = $_[1];
61 $options{'expect-pass'} = 0;
63 'force-manifest', 'force-regen', 'setpgrp!', 'timeout=i',
64 'test-build', 'validate',
65 'all-fixups', 'early-fixup=s@', 'late-fixup=s@', 'valgrind',
66 'check-args', 'check-shebang!', 'usage|help|?', 'gold=s',
69 my (undef, $val) = @_;
70 if ($val =~ /\A([^=]+)=(.*)/s) {
71 $defines{$1} = length $2 ? $2 : "\0";
77 $defines{$_[1]} = undef;
80 pod2usage(exitval => 255, verbose => 1);
83 my ($target, $match) = @options{qw(target match)};
85 @ARGV = ('sh', '-c', 'cd t && ./perl TEST base/*.t')
86 if $options{validate} && !@ARGV;
88 pod2usage(exitval => 0, verbose => 2) if $options{usage};
89 pod2usage(exitval => 255, verbose => 1)
90 unless @ARGV || $match || $options{'test-build'} || defined $options{'one-liner'};
91 pod2usage(exitval => 255, verbose => 1)
92 if !$options{'one-liner'} && ($options{l} || $options{w});
94 check_shebang($ARGV[0])
95 if $options{'check-shebang'} && @ARGV && !$options{match};
97 exit 0 if $options{'check-args'};
101 bisect.pl - use git bisect to pinpoint changes
105 # When did this become an error?
106 .../Porting/bisect.pl -e 'my $a := 2;'
107 # When did this stop being an error?
108 .../Porting/bisect.pl --expect-fail -e '1 // 2'
109 # When were all lines matching this pattern removed from all files?
110 .../Porting/bisect.pl --match '\b(?:PL_)hash_seed_set\b'
111 # When was some line matching this pattern added to some file?
112 .../Porting/bisect.pl --expect-fail --match '\buseithreads\b'
113 # When did this test program stop exiting 0?
114 .../Porting/bisect.pl -- ./perl -Ilib ../test_prog.pl
115 # When did this test start failing?
116 .../Porting/bisect.pl -- ./perl -Ilib t/TEST op/sort.t
117 # When did this first become valid syntax?
118 .../Porting/bisect.pl --target=miniperl --end=v5.10.0 \
119 --expect-fail -e 'my $a := 2;'
120 # What was the last revision to build with these options?
121 .../Porting/bisect.pl --test-build -Dd_dosuid
122 # When did this test program start generating errors from valgrind?
123 .../Porting/bisect.pl --valgrind ../test_prog.pl
127 Together F<bisect.pl> and F<bisect-runner.pl> attempt to automate the use
128 of C<git bisect> as much as possible. With one command (and no other files)
129 it's easy to find out
135 Which commit caused this example code to break?
139 Which commit caused this example code to start working?
143 Which commit added the first file to match this regex?
147 Which commit removed the last file to match this regex?
151 usually without needing to know which versions of perl to use as start and
154 By default F<bisect.pl> will process all options, then use the rest of the
155 command line as arguments to list C<system> to run a test case. By default,
156 the test case should pass (exit with 0) on earlier perls, and fail (exit
157 non-zero) on I<blead> (note that running most of perl's test files directly
158 won't do this, you'll need to run them through a harness to get the proper
159 error code). F<bisect.pl> will use F<bisect-runner.pl> to find the earliest
160 stable perl version on which the test case passes, check that it fails on
161 blead, and then use F<bisect-runner.pl> with C<git bisect run> to find the
162 commit which caused the failure.
164 Because the test case is the complete argument to C<system>, it is easy to
165 run something other than the F<perl> built, if necessary. If you need to run
166 the perl built, you'll probably need to invoke it as C<./perl -Ilib ...>.
167 As a special case, if the first argument of the test case is a readable file
168 (whether executable or not), matching C<qr{\A#!./(?:mini)?perl\b}> then it
169 will have C<./perl> <-Ilib> (or C<./miniperl>) prepended to it.
171 You need a clean checkout to run a bisect, and you can't use the checkout
172 which contains F<Porting/bisect.pl> (because C<git bisect>) will check out
173 a revision before F<Porting/bisect-runner.pl> was added, which
174 C<git bisect run> needs). If your working checkout is called F<perl>, the
175 simplest solution is to make a local clone, and run from that. I<i.e.>:
180 ../perl/Porting/bisect.pl ...
182 By default, F<bisect-runner.pl> will automatically disable the build of
183 L<DB_File> for commits earlier than ccb44e3bf3be2c30, as it's not practical
184 to patch DB_File 1.70 and earlier to build with current Berkeley DB headers.
185 (ccb44e3bf3be2c30 was in September 1999, between 5.005_62 and 5.005_63.)
186 If your F<db.h> is old enough you can override this with C<-Unoextensions>.
194 --start I<commit-ish>
196 Earliest revision to test, as a I<commit-ish> (a tag, commit or anything
197 else C<git> understands as a revision). If not specified, F<bisect.pl> will
198 search stable .0 perl releases until it finds one where the test case passes
199 (5.16.0 at the time of writing). The default is to search from 5.002 to the
200 most recent tagged stable release. If F<bisect.pl> detects that the
201 checkout is on a case insensitive file system, it will search from 5.005 to
202 the most recent tagged stable release. Only .0 stable releases are used
203 because these are the only stable releases that are parents of blead, and
204 hence suitable for a bisect run.
210 Most recent revision to test, as a I<commit-ish>. If not specified, defaults
217 F<Makefile> target (or equivalent) needed, to run the test case. If specified,
218 this should be one of
226 Don't build anything - just run the user test case against a clean checkout.
227 Using this gives a couple of features that a plain C<git bisect run> can't
228 offer - automatic start revision detection, and test case C<--timeout>.
234 Just run F<./Configure>
240 Run the various F<*.SH> files to generate F<Makefile>, F<config.h>, I<etc>.
252 Use F<miniperl> to build F<lib/Config.pm>
258 Build F<lib/auto/Fcntl/Fnctl.so> (strictly, C<.$Config{so}>). As L<Fcntl>
259 is simple XS module present since 5.000, this provides a fast test of
260 whether XS modules can be built. Note, XS modules are built by F<miniperl>,
261 hence this target will not build F<perl>.
267 Build F<perl>. This also builds pure-Perl modules in F<cpan>, F<dist> and
268 F<ext>. XS modules (such as L<Fcntl>) are not built.
274 Build everything needed to run the tests. This is the default if we're
275 running test code, but is time consuming, as it means building all
276 XS modules. For older F<Makefile>s, the previous name of C<test-prep>
277 is automatically substituted. For very old F<Makefile>s, C<make test> is
278 run, as there is no target provided to just get things ready, and for 5.004
279 and earlier the tests run very quickly.
285 --one-liner 'code to run'
291 Example code to run, just like you'd use with C<perl -e>.
293 This prepends C<./perl -Ilib -e 'code to run'> to the test case given,
294 or F<./miniperl> if I<target> is C<miniperl>.
296 (Usually you'll use C<-e> instead of providing a test case in the
297 non-option arguments to F<bisect.pl>)
299 C<-E> intentionally isn't supported, as it's an error in 5.8.0 and earlier,
300 which interferes with detecting errors in the example code itself.
306 Add C<-c> to the command line, to cause perl to exit after syntax checking.
312 Add C<-l> to the command line with C<-e>
314 This will automatically append a newline to every output line of your testcase.
315 Note that you can't specify an argument to F<perl>'s C<-l> with this, as it's
316 not feasible to emulate F<perl>'s somewhat quirky switch parsing with
317 L<Getopt::Long>. If you need the full flexibility of C<-l>, you need to write
318 a full test case, instead of using C<bisect.pl>'s C<-e> shortcut.
324 Add C<-w> to the command line with C<-e>
326 It's not valid to pass C<-c>, C<-l> or C<-w> to C<bisect.pl> unless you are
333 The test case should fail for the I<start> revision, and pass for the I<end>
334 revision. The bisect run will find the first commit where it passes.
338 -D I<config_arg=value>
346 -A I<config_arg=value>
348 Arguments (C<-A>, C<-D>, C<-U>) to pass to F<Configure>. For example,
350 -Dnoextensions=Encode
352 -Accflags=-DNO_MATHOMS
354 Repeated C<-A> arguments are passed
355 through as is. C<-D> and C<-U> are processed in order, and override
356 previous settings for the same parameter. F<bisect-runner.pl> emulates
357 C<-Dnoextensions> when F<Configure> itself does not provide it, as it's
358 often very useful to be able to disable some XS extensions.
364 The C<make> command to use. If this not set, F<make> is used. If this is
365 set, it also adds a C<-Dmake=...> else some recursive make invocations
366 in extensions may fail. Typically one would use this as C<--make gmake>
367 to use F<gmake> in place of the system F<make>.
377 Number of C<make> jobs to run in parallel. A value of 0 suppresses
378 parallelism. If F</proc/cpuinfo> exists and can be parsed, or F</sbin/sysctl>
379 exists and reports C<hw.ncpu>, or F</usr/bin/getconf> exists and reports
380 C<_NPROCESSORS_ONLN> defaults to 1 + I<number of CPUs>. On HP-UX with the
381 system make defaults to 0, otherwise defaults to 2.
391 Instead of running a test program to determine I<pass> or I<fail>,
392 C<--match> will pass if the given regex matches, and hence search for the
393 commit that removes the last matching file. C<--no-match> inverts the test,
394 to search for the first commit that adds files that match.
396 The remaining command line arguments are treated as glob patterns for files
397 to match against. If none are specified, then they default as follows:
403 If no I<target> is specified, the match is against all files in the
404 repository (which is fast).
408 If a I<target> is specified, that target is built, and the match is against
409 only the built files.
413 Treating the command line arguments as glob patterns should not cause
414 problems, as the perl distribution has never shipped or built files with
415 names that contain characters which are globbing metacharacters.
417 Anything which is not a readable file is ignored, instead of generating an
418 error. (If you want an error, run C<grep> or C<ack> as a test case). This
419 permits one to easily search in a file that changed its name. For example:
421 .../Porting/bisect.pl --match 'Pod.*Functions' 'pod/buildtoc*'
423 C<--no-match ...> is implemented as C<--expect-fail --match ...>
429 Run the test program under C<valgrind>. If you need to test for memory
430 errors when parsing invalid programs, the default parser fail exit code of
431 255 will always override C<valgrind>, so try putting the test case invalid
432 code inside a I<string> C<eval>, so that the perl interpreter will exit with 0.
433 (Be sure to check the output of $@, to avoid missing mistakes such as
434 unintended C<eval> failures due to incorrect C<@INC>)
436 Specifically, this option prepends C<valgrind> C<--error-exitcode=124> to
437 the command line that runs the testcase, to cause valgrind to exit non-zero
438 if it detects errors, with the assumption that the test program itself
439 always exits with zero. If you require more flexibility than this, either
440 specify your C<valgrind> invocation explicitly as part of the test case, or
441 use a wrapper script to control the command line or massage the exit codes.
447 Test that the build completes, without running any test case.
449 By default, if the build for the desired I<target> fails to complete,
450 F<bisect-runner.pl> reports a I<skip> back to C<git bisect>, the assumption
451 being that one wants to find a commit which changed state "builds && passes"
452 to "builds && fails". If instead one is interested in which commit broke the
453 build (possibly for particular F<Configure> options), use I<--test-build>
454 to treat a build failure as a failure, not a "skip".
456 Often this option isn't as useful as it first seems, because I<any> build
457 failure will be reported to C<git bisect> as a failure, not just the failure
458 that you're interested in. Generally, to debug a particular problem, it's
459 more useful to use a I<target> that builds properly at the point of interest,
460 and then a test case that runs C<make>. For example:
462 .../Porting/bisect.pl --start=perl-5.000 --end=perl-5.002 \
463 --expect-fail --force-manifest --target=miniperl make perl
465 will find the first revision capable of building L<DynaLoader> and then
466 F<perl>, without becoming confused by revisions where F<miniperl> won't
473 By default, a build will "skip" if any files listed in F<MANIFEST> are not
474 present. Usually this is useful, as it avoids false-failures. However, there
475 are some long ranges of commits where listed files are missing, which can
476 cause a bisect to abort because all that remain are skipped revisions.
478 In these cases, particularly if the test case uses F<miniperl> and no modules,
479 it may be more useful to force the build to continue, even if files
480 F<MANIFEST> are missing.
486 Run C<make regen_headers> before building F<miniperl>. This may fix a build
487 that otherwise would skip because the generated headers at that revision
488 are stale. It's not the default because it conceals this error in the true
489 state of such revisions.
495 C<--expect-pass=0> is equivalent to C<--expect-fail>. I<1> is the default.
501 Run the testcase with the given timeout. If this is exceeded, kill it (and
502 by default all its children), and treat it as a failure.
508 Run the testcase in its own process group. Specifically, call C<setpgrp 0, 0>
509 just before C<exec>-ing the user testcase. The default is not to set the
510 process group, unless a timeout is used.
516 F<bisect-runner.pl> will minimally patch various files on a platform and
517 version dependent basis to get the build to complete. Normally it defers
518 doing this as long as possible - C<.SH> files aren't patched until after
519 F<Configure> is run, and C<C> and C<XS> code isn't patched until after
520 F<miniperl> is built. If C<--all-fixups> is specified, all the fixups are
521 done before running C<Configure>. In rare cases adding this may cause a
522 bisect to abort, because an inapplicable patch or other fixup is attempted
523 for a revision which would usually have already I<skip>ed. If this happens,
524 please report it as a bug, giving the OS and problem revision.
534 Specify a file containing a patch or other fixup for the source code. The
535 action to take depends on the first line of the fixup file
543 If the first line starts C<#!perl> then the file is run using C<$^X>
549 If a shebang line is present the file is executed using C<system>
553 C<I<filename> =~ /I<pattern>/>
557 C<I<filename> !~ /I<pattern>/>
559 If I<filename> does not exist then the fixup file's contents are ignored.
560 Otherwise, for C<=~>, if it contains a line matching I<pattern>, then the
561 file is fed to C<patch -p1> on standard input. For C<=~>, the patch is
562 applied if no lines match the pattern.
564 As the empty pattern in Perl is a special case (it matches the most recent
565 sucessful match) which is not useful here, an the treatment of empty pattern
566 is special-cased. C<I<filename> =~ //> applies the patch if filename is
567 present. C<I<filename> !~ //> applies the patch if filename missing. This
568 makes it easy to unconditionally apply patches to files, and to use a patch
569 as a way of creating a new file.
573 Otherwise, the file is assumed to be a patch, and always applied.
577 I<early-fixup>s are applied before F<./Configure> is run. I<late-fixup>s are
578 applied just after F<./Configure> is run.
580 These options can be specified more than once. I<file> is actually expanded
581 as a glob pattern. Globs that do not match are errors, as are missing files.
587 Tell F<bisect-runner.pl> not to clean up after the build. This allows one
588 to use F<bisect-runner.pl> to build the current particular perl revision for
589 interactive testing, or for debugging F<bisect-runner.pl>.
591 Passing this to F<bisect.pl> will likely cause the bisect to fail badly.
597 Test that all stable (.0) revisions can be built. By default, attempts to
598 build I<blead>, then tagged stable releases in reverse order down to
599 I<perl-5.002> (or I<perl5.005> on a case insensitive file system). Stops at
600 the first failure, without cleaning the checkout. Use I<--start> to specify
601 the earliest revision to test, I<--end> to specify the most recent. Useful
602 for validating a new OS/CPU/compiler combination. For example
604 ../perl/Porting/bisect.pl --validate -le 'print "Hello from $]"'
606 If no testcase is specified, the default is to use F<t/TEST> to run
613 Validate the options and arguments, and exit silently if they are valid.
619 Validate that the test case isn't an executable file with a
620 C<#!/usr/bin/perl> line (or similar). As F<bisect-runner.pl> does B<not>
621 automatically prepend C<./perl> to the test case, a I<#!> line specifying an
622 external F<perl> binary will cause the test case to always run with I<that>
623 F<perl>, not the F<perl> built by the bisect runner. Likely this is not what
624 you wanted. If your test case is actually a wrapper script to run other
625 commands, you should run it with an explicit interpreter, to be clear. For
626 example, instead of C<../perl/Porting/bisect.pl ~/test/testcase.pl> you'd
627 run C<../perl/Porting/bisect.pl /usr/bin/perl ~/test/testcase.pl>
633 Revision to use when checking out known-good recent versions of files,
634 such as F<makedepend.SH>. F<bisect-runner.pl> defaults this to I<blead>,
635 but F<bisect.pl> will default it to the most recent stable release.
649 Display the usage information and exit.
655 # Ensure we always exit with 255, to cause git bisect to abort.
657 my $message = join '', @_;
658 if ($message =~ /\n\z/) {
659 print STDERR $message;
661 my (undef, $file, $line) = caller 1;
662 print STDERR "@_ at $file line $line\n";
671 die_255("$0: Can't build $target")
672 if defined $target && !grep {@targets} $target;
674 foreach my $phase (qw(early late)) {
675 next unless $options{"$phase-fixup"};
679 foreach my $glob (@{$options{"$phase-fixup"}}) {
680 my @got = File::Glob::bsd_glob($glob);
681 push @expanded, @got ? @got : $glob;
683 @expanded = sort @expanded;
684 $options{"$phase-fixup"} = \@expanded;
685 foreach (@expanded) {
687 print STDERR "$phase-fixup '$_' is not a readable file\n";
691 exit 255 if $bail_out;
694 unless (exists $defines{cc}) {
695 # If it fails, the heuristic of 63f9ec3008baf7d6 is noisy, and hence
697 # FIXME - really it should be replaced with a proper test of
698 # "can we build something?" and a helpful diagnostic if we can't.
699 # For now, simply move it here.
700 $defines{cc} = (`ccache -V`, $?) ? 'cc' : 'ccache cc';
703 my $j = $options{jobs} ? "-j$options{jobs}" : '';
705 if (exists $options{make}) {
706 if (!exists $defines{make}) {
707 $defines{make} = $options{make};
710 $options{make} = 'make';
713 # Sadly, however hard we try, I don't think that it will be possible to build
714 # modules in ext/ on x86_64 Linux before commit e1666bf5602ae794 on 1999/12/29,
715 # which updated to MakeMaker 3.7, which changed from using a hard coded ld
716 # in the Makefile to $(LD). On x86_64 Linux the "linker" is gcc.
720 my $mode = @_ ? shift : '<';
721 open my $fh, $mode, $file or croak_255("Can't open $file: $!");
722 ${*$fh{SCALAR}} = $file;
729 croak_255("Can't close: $!") unless ref $fh eq 'GLOB';
730 croak_255("Can't close ${*$fh{SCALAR}}: $!");
734 my $command = '</dev/null ' . shift;
735 system($command) and croak_255("'$command' failed, \$!=$!, \$?=$?");
738 sub run_with_options {
740 my $name = $options->{name};
741 $name = "@_" unless defined $name;
743 my $setgrp = $options->{setpgrp};
744 if ($options->{timeout}) {
745 # Unless you explicitly disabled it on the commandline, set it:
746 $setgrp = 1 unless defined $setgrp;
749 die_255("Can't fork: $!") unless defined $pid;
751 if (exists $options->{stdin}) {
752 open STDIN, '<', $options->{stdin}
753 or die "Can't open STDIN from $options->{stdin}: $!";
757 or die "Can't setpgrp 0, 0: $!";
760 die_255("Failed to start $name: $!");
763 if ($options->{timeout}) {
766 die_255("No POSIX::WNOHANG")
767 unless &POSIX::WNOHANG;
770 my $victim = $setgrp ? -$pid : $pid;
772 kill 'TERM', $victim;
773 waitpid(-1, &POSIX::WNOHANG);
774 while (kill 0, $victim) {
776 waitpid(-1, &POSIX::WNOHANG);
779 if (kill 'KILL', $victim) {
780 print STDERR "$0: Had to kill 'KILL', $victim\n"
781 } elsif (! $!{ESRCH}) {
782 print STDERR "$0: kill 'KILL', $victim failed: $!\n";
787 report_and_exit(0, 'No timeout', 'Timeout', "when running $name");
789 alarm $options->{timeout};
792 or die_255("wait for $name, pid $pid failed: $!");
794 if ($options->{timeout}) {
795 my $elapsed = time - $start;
796 if ($elapsed / $options->{timeout} > 0.8) {
797 print STDERR "$0: Beware, took $elapsed seconds of $options->{timeout} permitted to run $name\n";
803 sub extract_from_file {
804 my ($file, $rx, $default) = @_;
805 my $fh = open_or_die($file);
808 return wantarray ? @got : $got[0]
811 return $default if defined $default;
816 my ($file, $munger) = @_;
818 my $fh = open_or_die($file);
820 die_255("Can't read $file: $!") unless defined $orig && close $fh;
821 my $new = $munger->($orig);
822 return if $new eq $orig;
823 $fh = open_or_die($file, '>');
824 print $fh $new or die_255("Can't print to $file: $!");
828 # AIX supplies a pre-historic patch program, which certainly predates Linux
829 # and is probably older than NT. It can't cope with unified diffs. Meanwhile,
830 # it's hard enough to get git diff to output context diffs, let alone git show,
831 # and nearly all the patches embedded here are unified. So it seems that the
832 # path of least resistance is to convert unified diffs to context diffs:
835 my ($from_out, $to_out, $has_from, $has_to, $delete, $add) = @_;
836 ++$$has_from if $delete;
839 if ($delete && $add) {
840 $$from_out .= "! $_\n" foreach @$delete;
841 $$to_out .= "! $_\n" foreach @$add;
843 $$from_out .= "- $_\n" foreach @$delete;
845 $$to_out .= "+ $_\n" foreach @$add;
849 # This isn't quite general purpose, as it can't cope with
850 # '\ No newline at end of file'
855 # Stuff before the diff
856 while ($diff_in =~ s/\A(?!\*\*\* )(?!--- )([^\n]*\n?)//ms && length $1) {
860 if (!length $diff_in) {
861 die_255("That didn't seem to be a diff");
864 if ($diff_in =~ /\A\*\*\* /ms) {
865 warn "Seems to be a context diff already\n";
866 return $diff_out . $diff_in;
871 if ($diff_in =~ s/\A((?:diff |index )[^\n]+\n)//ms) {
875 if ($diff_in !~ /\A--- /ms) {
876 # Stuff after the diff;
877 return $diff_out . $diff_in;
879 $diff_in =~ s/\A([^\n]+\n?)//ms;
881 die_255("Can't parse '$line'") unless $line =~ s/\A--- /*** /ms;
883 $diff_in =~ s/\A([^\n]+\n?)//ms;
885 die_255("Can't parse '$line'") unless $line =~ s/\A\+\+\+ /--- /ms;
891 unless $diff_in =~ s/\A\@\@ (-([0-9]+),([0-9]+) \+([0-9]+),([0-9]+)) \@\@[^\n]*\n?//;
892 my ($hunk, $from_start, $from_count, $to_start, $to_count)
893 = ($1, $2, $3, $4, $5);
894 my $from_end = $from_start + $from_count - 1;
895 my $to_end = $to_start + $to_count - 1;
896 my ($from_out, $to_out, $has_from, $has_to, $add, $delete);
897 while (length $diff_in && ($from_count || $to_count)) {
898 die_255("Confused in $hunk")
899 unless $diff_in =~ s/\A([^\n]*)\n//ms;
901 $line = ' ' unless length $line;
902 if ($line =~ /^ .*/) {
903 process_hunk(\$from_out, \$to_out, \$has_from, \$has_to,
907 $from_out .= " $line\n";
908 $to_out .= " $line\n";
911 } elsif ($line =~ /^-(.*)/) {
914 } elsif ($line =~ /^\+(.*)/) {
918 die_255("Can't parse '$line' as part of hunk $hunk");
921 process_hunk(\$from_out, \$to_out, \$has_from, \$has_to,
923 die_255("No lines in hunk $hunk")
924 unless length $from_out || length $to_out;
925 die_255("No changes in hunk $hunk")
926 unless $has_from || $has_to;
927 $diff_out .= "***************\n";
928 $diff_out .= "*** $from_start,$from_end ****\n";
929 $diff_out .= $from_out if $has_from;
930 $diff_out .= "--- $to_start,$to_end ----\n";
931 $diff_out .= $to_out if $has_to;
939 sub placate_patch_prog {
942 if (!defined $use_context) {
943 my $version = `patch -v 2>&1`;
944 die_255("Can't run `patch -v`, \$?=$?, bailing out")
945 unless defined $version;
946 if ($version =~ /Free Software Foundation/) {
948 } elsif ($version =~ /Header: patch\.c,v.*\blwall\b/) {
949 # The system patch is older than Linux, and probably older than
952 } elsif ($version =~ /Header: patch\.c,v.*\babhinav\b/) {
953 # Thank you HP. No, we have no idea *which* version this is:
954 # $Header: patch.c,v 76.1.1.2.1.3 2001/12/03 12:24:52 abhinav Exp $
962 return $use_context ? ud2cd($patch) : $patch;
967 my ($patch, $what, $files) = @_;
968 $what = 'patch' unless defined $what;
969 unless (defined $files) {
970 $patch =~ m!^--- [ab]/(\S+)\n\+\+\+ [ba]/\1!sm;
973 my $patch_to_use = placate_patch_prog($patch);
974 open my $fh, '|-', 'patch', '-p1' or die_255("Can't run patch: $!");
975 print $fh $patch_to_use;
977 print STDERR "Patch is <<'EOPATCH'\n${patch}EOPATCH\n";
978 print STDERR "\nConverted to a context diff <<'EOCONTEXT'\n${patch_to_use}EOCONTEXT\n"
979 if $patch_to_use ne $patch;
980 die_255("Can't $what$files: $?, $!");
984 my ($commit, @files) = @_;
985 my $patch = `git show $commit @files`;
986 if (!defined $patch) {
987 die_255("Can't get commit $commit for @files: $?") if @files;
988 die_255("Can't get commit $commit: $?");
990 apply_patch($patch, "patch $commit", @files ? " for @files" : '');
994 my ($commit, @files) = @_;
995 my $patch = `git show -R $commit @files`;
996 if (!defined $patch) {
997 die_255("Can't get revert commit $commit for @files: $?") if @files;
998 die_255("Can't get revert commit $commit: $?");
1000 apply_patch($patch, "revert $commit", @files ? " for @files" : '');
1004 my ($file, $commit) = @_;
1005 $commit ||= $options{gold} || 'blead';
1006 system "git show $commit:$file > $file </dev/null"
1007 and die_255("Could not extract $file at revision $commit");
1012 return unless -e $file;
1013 my $fh = open_or_die($file);
1015 return if $line =~ $run_with_our_perl;
1017 die_255("$file is not executable.
1018 system($file, ...) is always going to fail.
1022 return unless $line =~ m{\A#!(/\S+/perl\S*)\s};
1023 die_255("$file will always be run by $1
1024 It won't be tested by the ./perl we build.
1025 If you intended to run it with that perl binary, please change your
1030 If you intended to test it with the ./perl we build, please change your
1035 [You may also need to add -- before ./perl to prevent that -Ilib as being
1036 parsed as an argument to bisect.pl]
1042 if ($options{clean}) {
1043 # Needed, because files that are build products in this checked out
1044 # version might be in git in the next desired version.
1045 system 'git clean -dxf </dev/null';
1046 # Needed, because at some revisions the build alters checked out files.
1047 # (eg pod/perlapi.pod). Also undoes any changes to makedepend.SH
1048 system 'git reset --hard HEAD </dev/null';
1055 warn "skipping - $reason";
1059 sub report_and_exit {
1060 my ($good, $pass, $fail, $desc) = @_;
1064 my $got = ($options{'expect-pass'} ? $good : !$good) ? 'good' : 'bad';
1066 print "$got - $pass $desc\n";
1068 print "$got - $fail $desc\n";
1071 exit($got eq 'bad');
1074 sub run_report_and_exit {
1075 my $ret = run_with_options({setprgp => $options{setpgrp},
1076 timeout => $options{timeout},
1078 report_and_exit(!$ret, 'zero exit from', 'non-zero exit from', "@_");
1081 sub match_and_exit {
1082 my ($target, @globs) = @_;
1084 my $re = qr/$match/;
1089 foreach (sort map { File::Glob::bsd_glob($_)} @globs) {
1090 if (!-f $_ || !-r _) {
1091 warn "Skipping matching '$_' as it is not a readable file\n";
1098 @files = defined $target ? `git ls-files -o -z`: `git ls-files -z`;
1102 foreach my $file (@files) {
1103 my $fh = open_or_die($file);
1107 if (tr/\t\r\n -~\200-\377//c) {
1108 print "Binary file $file matches\n";
1110 $_ .= "\n" unless /\n\z/;
1117 report_and_exit($matches,
1118 $matches == 1 ? '1 match for' : "$matches matches for",
1119 'no matches for', $match);
1122 # Not going to assume that system perl is yet new enough to have autodie
1123 system_or_die('git clean -dxf');
1125 if (!defined $target) {
1126 match_and_exit(undef, @ARGV) if $match;
1127 $target = 'test_prep';
1128 } elsif ($target eq 'none') {
1129 match_and_exit(undef, @ARGV) if $match;
1130 run_report_and_exit(@ARGV);
1133 skip('no Configure - is this the //depot/perlext/Compiler branch?')
1134 unless -f 'Configure';
1136 my $case_insensitive;
1138 my ($dev_C, $ino_C) = stat 'Configure';
1139 die_255("Could not stat Configure: $!") unless defined $dev_C;
1140 my ($dev_c, $ino_c) = stat 'configure';
1142 if defined $dev_c && $dev_C == $dev_c && $ino_C == $ino_c;
1145 # This changes to PERL_VERSION in 4d8076ea25903dcb in 1999
1147 = extract_from_file('patchlevel.h',
1148 qr/^#define\s+(?:PERL_VERSION|PATCHLEVEL)\s+(\d+)\s/,
1151 my $unfixable_db_file;
1154 && !extract_from_file('ext/DB_File/DB_File.xs',
1155 qr!^#else /\* Berkeley DB Version > 2 \*/$!)) {
1156 # This DB_File.xs is really too old to patch up.
1157 # Skip DB_File, unless we're invoked with an explicit -Unoextensions
1158 if (!exists $defines{noextensions}) {
1159 $defines{noextensions} = 'DB_File';
1160 } elsif (defined $defines{noextensions}) {
1161 $defines{noextensions} .= ' DB_File';
1163 ++$unfixable_db_file;
1168 if ($options{'all-fixups'}) {
1173 apply_fixups($options{'early-fixup'});
1175 # if Encode is not needed for the test, you can speed up the bisect by
1176 # excluding it from the runs with -Dnoextensions=Encode
1177 # ccache is an easy win. Remove it if it causes problems.
1178 # Commit 1cfa4ec74d4933da adds ignore_versioned_solibs to Configure, and sets it
1179 # to true in hints/linux.sh
1180 # On dromedary, from that point on, Configure (by default) fails to find any
1181 # libraries, because it scans /usr/local/lib /lib /usr/lib, which only contain
1182 # versioned libraries. Without -lm, the build fails.
1183 # Telling /usr/local/lib64 /lib64 /usr/lib64 works from that commit onwards,
1184 # until commit faae14e6e968e1c0 adds it to the hints.
1185 # However, prior to 1cfa4ec74d4933da telling Configure the truth doesn't work,
1186 # because it will spot versioned libraries, pass them to the compiler, and then
1187 # bail out pretty early on. Configure won't let us override libswanted, but it
1188 # will let us override the entire libs list.
1190 foreach (@{$options{A}}) {
1191 push @paths, $1 if /^libpth=(.*)/s;
1194 unless (extract_from_file('Configure', 'ignore_versioned_solibs')) {
1195 # Before 1cfa4ec74d4933da, so force the libs list.
1198 # This is the current libswanted list from Configure, less the libs removed
1199 # by current hints/linux.sh
1200 foreach my $lib (qw(sfio socket inet nsl nm ndbm gdbm dbm db malloc dl dld
1201 ld sun m crypt sec util c cposix posix ucb BSD)) {
1202 foreach my $dir (@paths) {
1203 # Note the wonderful consistency of dot-or-not in the config vars:
1204 next unless -f "$dir/lib$lib.$Config{dlext}"
1205 || -f "$dir/lib$lib$Config{lib_ext}";
1206 push @libs, "-l$lib";
1210 $defines{libs} = \@libs unless exists $defines{libs};
1213 $defines{usenm} = undef
1214 if $major < 2 && !exists $defines{usenm};
1216 my ($missing, $created_dirs);
1217 ($missing, $created_dirs) = force_manifest()
1218 if $options{'force-manifest'};
1221 foreach my $key (sort keys %defines) {
1222 my $val = $defines{$key};
1224 push @ARGS, "-D$key=@$val";
1225 } elsif (!defined $val) {
1226 push @ARGS, "-U$key";
1227 } elsif (!length $val) {
1228 push @ARGS, "-D$key";
1230 $val = "" if $val eq "\0";
1231 push @ARGS, "-D$key=$val";
1234 push @ARGS, map {"-A$_"} @{$options{A}};
1236 # If a file in MANIFEST is missing, Configure asks if you want to
1237 # continue (the default being 'n'). With stdin closed or /dev/null,
1238 # it exits immediately and the check for config.sh below will skip.
1239 # Without redirecting stdin, the commands called will attempt to read from
1240 # stdin (and thus effectively hang)
1241 run_with_options({stdin => '/dev/null', name => 'Configure'},
1242 './Configure', @ARGS);
1244 patch_SH() unless $options{'all-fixups'};
1245 apply_fixups($options{'late-fixup'});
1247 if (-f 'config.sh') {
1248 # Emulate noextensions if Configure doesn't support it.
1250 if $major < 10 && $defines{noextensions};
1251 system_or_die('./Configure -S');
1254 if ($target =~ /config\.s?h/) {
1255 match_and_exit($target, @ARGV) if $match && -f $target;
1256 report_and_exit(-f $target, 'could build', 'could not build', $target)
1257 if $options{'test-build'};
1259 skip("could not build $target") unless -f $target;
1261 run_report_and_exit(@ARGV);
1262 } elsif (!-f 'config.sh') {
1263 # Skip if something went wrong with Configure
1265 skip('could not build config.sh');
1268 force_manifest_cleanup($missing, $created_dirs)
1271 if($options{'force-regen'}
1272 && extract_from_file('Makefile', qr/\bregen_headers\b/)) {
1273 # regen_headers was added in e50aee73b3d4c555, patch.1m for perl5.001
1274 # It's not worth faking it for earlier revisions.
1275 system_or_die('make regen_headers');
1278 unless ($options{'all-fixups'}) {
1283 # Parallel build for miniperl is safe
1284 system "$options{make} $j miniperl </dev/null";
1286 # This is the file we expect make to create
1287 my $expected_file = $target =~ /^test/ ? 't/perl'
1288 : $target eq 'Fcntl' ? "lib/auto/Fcntl/Fcntl.$Config{so}"
1290 # This is the target we tell make to build in order to get $expected_file
1291 my $real_target = $target eq 'Fcntl' ? $expected_file : $target;
1293 if ($target ne 'miniperl') {
1294 # Nearly all parallel build issues fixed by 5.10.0. Untrustworthy before that.
1295 $j = '' if $major < 10;
1297 if ($real_target eq 'test_prep') {
1299 # test-prep was added in 5.004_01, 3e3baf6d63945cb6.
1300 # renamed to test_prep in 2001 in 5fe84fd29acaf55c.
1301 # earlier than that, just make test. It will be fast enough.
1302 $real_target = extract_from_file('Makefile.SH',
1303 qr/^(test[-_]prep):/,
1308 system "$options{make} $j $real_target </dev/null";
1311 my $expected_file_found = $expected_file =~ /perl$/
1312 ? -x $expected_file : -r $expected_file;
1314 if ($expected_file_found && $expected_file eq 't/perl') {
1315 # Check that it isn't actually pointing to ../miniperl, which will happen
1316 # if the sanity check ./miniperl -Ilib -MExporter -e '<?>' fails, and
1317 # Makefile tries to run minitest.
1319 # Of course, helpfully sometimes it's called ../perl, other times .././perl
1320 # and who knows if that list is exhaustive...
1321 my ($dev0, $ino0) = stat 't/perl';
1322 my ($dev1, $ino1) = stat 'perl';
1323 unless (defined $dev0 && defined $dev1 && $dev0 == $dev1 && $ino0 == $ino1) {
1324 undef $expected_file_found;
1325 my $link = readlink $expected_file;
1326 warn "'t/perl' => '$link', not 'perl'";
1327 die_255("Could not realink t/perl: $!") unless defined $link;
1331 if ($options{'test-build'}) {
1332 report_and_exit($expected_file_found, 'could build', 'could not build',
1334 } elsif (!$expected_file_found) {
1335 skip("could not build $real_target");
1338 match_and_exit($real_target, @ARGV) if $match;
1340 if (defined $options{'one-liner'}) {
1341 my $exe = $target =~ /^(?:perl$|test)/ ? 'perl' : 'miniperl';
1342 unshift @ARGV, '-e', $options{'one-liner'};
1343 foreach (qw(c l w)) {
1344 unshift @ARGV, "-$_" if $options{$_};
1346 unshift @ARGV, "./$exe", '-Ilib';
1350 my $fh = open_or_die($ARGV[0]);
1352 unshift @ARGV, $1, '-Ilib'
1353 if $line =~ $run_with_our_perl;
1356 if ($options{valgrind}) {
1357 # Turns out to be too confusing to use an optional argument with the path
1358 # of the valgrind binary, as if --valgrind takes an optional argument,
1359 # then specifying it as the last option eats the first part of the testcase.
1360 # ie this: .../bisect.pl --valgrind testcase
1361 # is treated as --valgrind=testcase and as there is no test case given,
1362 # it's an invalid commandline, bailing out with the usage message.
1364 # Currently, the test script can't signal a skip with 125, so anything
1365 # non-zero would do. But to keep that option open in future, use 124
1366 unshift @ARGV, 'valgrind', '--error-exitcode=124';
1369 # This is what we came here to run:
1371 if (exists $Config{ldlibpthname}) {
1373 my $varname = $Config{ldlibpthname};
1374 my $cwd = Cwd::getcwd();
1375 if (defined $ENV{$varname}) {
1376 $ENV{$varname} = $cwd . $Config{path_sep} . $ENV{$varname};
1378 $ENV{$varname} = $cwd;
1382 run_report_and_exit(@ARGV);
1384 ############################################################################
1386 # Patching, editing and faking routines only below here.
1388 ############################################################################
1390 sub fake_noextensions {
1391 edit_file('config.sh', sub {
1392 my @lines = split /\n/, shift;
1393 my @ext = split /\s+/, $defines{noextensions};
1395 next unless /^extensions=/ || /^dynamic_ext/;
1396 foreach my $ext (@ext) {
1400 return join "\n", @lines;
1404 sub force_manifest {
1405 my (@missing, @created_dirs);
1406 my $fh = open_or_die('MANIFEST');
1408 next unless /^(\S+)/;
1409 # -d is special case needed (at least) between 27332437a2ed1941 and
1410 # bf3d9ec563d25054^ inclusive, as manifest contains ext/Thread/Thread
1412 unless -f $1 || -d $1;
1416 foreach my $pathname (@missing) {
1417 my @parts = split '/', $pathname;
1418 my $leaf = pop @parts;
1421 $path .= '/' . shift @parts;
1423 mkdir $path, 0700 or die_255("Can't create $path: $!");
1424 unshift @created_dirs, $path;
1426 $fh = open_or_die($pathname, '>');
1428 chmod 0, $pathname or die_255("Can't chmod 0 $pathname: $!");
1430 return \@missing, \@created_dirs;
1433 sub force_manifest_cleanup {
1434 my ($missing, $created_dirs) = @_;
1435 # This is probably way too paranoid:
1438 foreach my $file (@$missing) {
1439 my (undef, undef, $mode, undef, undef, undef, undef, $size)
1441 if (!defined $mode) {
1442 push @errors, "Added file $file has been deleted by Configure";
1445 if (Fcntl::S_IMODE($mode) != 0) {
1447 sprintf 'Added file %s had mode changed by Configure to %03o',
1452 "Added file $file had sized changed by Configure to $size";
1454 unlink $file or die_255("Can't unlink $file: $!");
1456 foreach my $dir (@$created_dirs) {
1457 rmdir $dir or die_255("Can't rmdir $dir: $!");
1463 sub patch_Configure {
1465 if (extract_from_file('Configure',
1466 qr/^\t\t\*=\*\) echo "\$1" >> \$optdef;;$/)) {
1467 # This is " Spaces now allowed in -D command line options.",
1468 # part of commit ecfc54246c2a6f42
1469 apply_patch(<<'EOPATCH');
1470 diff --git a/Configure b/Configure
1471 index 3d3b38d..78ffe16 100755
1474 @@ -652,7 +777,8 @@ while test $# -gt 0; do
1475 echo "$me: use '-U symbol=', not '-D symbol='." >&2
1476 echo "$me: ignoring -D $1" >&2
1478 - *=*) echo "$1" >> $optdef;;
1479 + *=*) echo "$1" | \
1480 + sed -e "s/'/'\"'\"'/g" -e "s/=\(.*\)/='\1'/" >> $optdef;;
1481 *) echo "$1='define'" >> $optdef;;
1487 if (extract_from_file('Configure', qr/^if \$contains 'd_namlen' \$xinc\b/)) {
1488 # Configure's original simple "grep" for d_namlen falls foul of the
1489 # approach taken by the glibc headers:
1490 # #ifdef _DIRENT_HAVE_D_NAMLEN
1491 # # define _D_EXACT_NAMLEN(d) ((d)->d_namlen)
1493 # where _DIRENT_HAVE_D_NAMLEN is not defined on Linux.
1494 # This is also part of commit ecfc54246c2a6f42
1495 apply_patch(<<'EOPATCH');
1496 diff --git a/Configure b/Configure
1497 index 3d3b38d..78ffe16 100755
1500 @@ -3935,7 +4045,8 @@ $rm -f try.c
1502 : see if the directory entry stores field length
1504 -if $contains 'd_namlen' $xinc >/dev/null 2>&1; then
1505 +$cppstdin $cppflags $cppminus < "$xinc" > try.c
1506 +if $contains 'd_namlen' try.c >/dev/null 2>&1; then
1507 echo "Good, your directory entry keeps length information in d_namlen." >&4
1515 && !extract_from_file('Configure',
1516 qr/Try to guess additional flags to pick up local libraries/)) {
1517 my $mips = extract_from_file('Configure',
1518 qr!(''\) if (?:\./)?mips; then)!);
1519 # This is part of perl-5.001n. It's needed, to add -L/usr/local/lib to
1520 # the ld flags if libraries are found there. It shifts the code to set
1521 # up libpth earlier, and then adds the code to add libpth entries to
1523 # mips was changed to ./mips in ecfc54246c2a6f42, perl5.000 patch.0g
1524 apply_patch(sprintf <<'EOPATCH', $mips);
1525 diff --git a/Configure b/Configure
1526 index 53649d5..0635a6e 100755
1529 @@ -2749,6 +2749,52 @@ EOM
1533 +: Set private lib path
1535 +'') if ./mips; then
1536 + plibpth="$incpath/usr/lib /usr/local/lib /usr/ccs/lib"
1541 +'') dlist="$plibpth $glibpth";;
1542 +*) dlist="$libpth";;
1545 +: Now check and see which directories actually exist, avoiding duplicates
1549 + if $test -d $xxx; then
1550 + case " $libpth " in
1552 + *) libpth="$libpth $xxx";;
1558 +Some systems have incompatible or broken versions of libraries. Among
1559 +the directories listed in the question below, please remove any you
1560 +know not to be holding relevant libraries, and add any that are needed.
1561 +Say "none" for none.
1572 +rp="Directories to use for library searches?"
1579 : flags used in final linking phase
1581 '') if ./venix; then
1582 @@ -2765,6 +2811,23 @@ case "$ldflags" in
1584 *) dflt="$ldflags";;
1587 +: Possible local library directories to search.
1588 +loclibpth="/usr/local/lib /opt/local/lib /usr/gnu/lib"
1589 +loclibpth="$loclibpth /opt/gnu/lib /usr/GNU/lib /opt/GNU/lib"
1591 +: Try to guess additional flags to pick up local libraries.
1592 +for thislibdir in $libpth; do
1593 + case " $loclibpth " in
1594 + *" $thislibdir "*)
1596 + "-L$thislibdir ") ;;
1597 + *) dflt="$dflt -L$thislibdir" ;;
1604 rp="Any additional ld flags (NOT including libraries)?"
1606 @@ -2828,52 +2891,6 @@ n) echo "OK, that should do.";;
1608 $rm -f try try.* core
1610 -: Set private lib path
1613 - plibpth="$incpath/usr/lib /usr/local/lib /usr/ccs/lib"
1618 -'') dlist="$plibpth $glibpth";;
1619 -*) dlist="$libpth";;
1622 -: Now check and see which directories actually exist, avoiding duplicates
1626 - if $test -d $xxx; then
1627 - case " $libpth " in
1629 - *) libpth="$libpth $xxx";;
1635 -Some systems have incompatible or broken versions of libraries. Among
1636 -the directories listed in the question below, please remove any you
1637 -know not to be holding relevant libraries, and add any that are needed.
1638 -Say "none" for none.
1649 -rp="Directories to use for library searches?"
1656 : compute shared library extension
1662 if ($major == 4 && extract_from_file('Configure', qr/^d_gethbynam=/)) {
1663 # Fixes a bug introduced in 4599a1dedd47b916
1664 apply_commit('3cbc818d1d0ac470');
1667 if ($major == 4 && extract_from_file('Configure',
1668 qr/gethbadd_addr_type=`echo \$gethbadd_addr_type/)) {
1669 # Fixes a bug introduced in 3fd537d4b944bc7a
1670 apply_commit('6ff9219da6cf8cfd');
1673 if ($major == 4 && extract_from_file('Configure',
1674 qr/^pthreads_created_joinable=/)) {
1675 # Fix for bug introduced in 52e1cb5ebf5e5a8c
1676 # Part of commit ce637636a41b2fef
1677 edit_file('Configure', sub {
1679 $code =~ s{^pthreads_created_joinable=''}
1680 {d_pthreads_created_joinable=''}ms
1681 or die_255("Substitution failed");
1682 $code =~ s{^pthreads_created_joinable='\$pthreads_created_joinable'}
1683 {d_pthreads_created_joinable='\$d_pthreads_created_joinable'}ms
1684 or die_255("Substitution failed");
1689 if ($major < 5 && extract_from_file('Configure',
1690 qr!if \$cc \$ccflags try\.c -o try >/dev/null 2>&1; then!)) {
1691 # Analogous to the more general fix of dfe9444ca7881e71
1692 # Without this flags such as -m64 may not be passed to this compile,
1693 # which results in a byteorder of '1234' instead of '12345678', which
1694 # can then cause crashes.
1696 if (extract_from_file('Configure', qr/xxx_prompt=y/)) {
1697 # 8e07c86ebc651fe9 or later
1698 # ("This is my patch patch.1n for perl5.001.")
1699 apply_patch(<<'EOPATCH');
1700 diff --git a/Configure b/Configure
1701 index 62249dd..c5c384e 100755
1704 @@ -8247,7 +8247,7 @@ main()
1708 - if $cc $ccflags try.c -o try >/dev/null 2>&1 && ./try > /dev/null; then
1709 + if $cc $ccflags $ldflags try.c -o try >/dev/null 2>&1 && ./try > /dev/null; then
1712 [1-4][1-4][1-4][1-4]|12345678|87654321)
1715 apply_patch(<<'EOPATCH');
1716 diff --git a/Configure b/Configure
1717 index 53649d5..f1cd64a 100755
1720 @@ -6362,7 +6362,7 @@ main()
1724 - if $cc $ccflags try.c -o try >/dev/null 2>&1 ; then
1725 + if $cc $ccflags $ldflags try.c -o try >/dev/null 2>&1 ; then
1728 ????|????????) echo "(The test program ran ok.)";;
1733 if ($major < 6 && !extract_from_file('Configure',
1735 # This adds the -A option to Configure, which is incredibly useful
1736 # Effectively this is commits 02e93a22d20fc9a5, 5f83a3e9d818c3ad,
1737 # bde6b06b2c493fef, f7c3111703e46e0c and 2 lines of trailing whitespace
1738 # removed by 613d6c3e99b9decc, but applied at slightly different
1739 # locations to ensure a clean patch back to 5.000
1740 # Note, if considering patching to the intermediate revisions to fix
1741 # bugs in -A handling, f7c3111703e46e0c is from 2002, and hence
1744 # To add to the fun, early patches add -K and -O options, and it's not
1745 # trivial to get patch to put the C<. ./posthint.sh> in the right place
1746 edit_file('Configure', sub {
1748 $code =~ s/(optstr = ")([^"]+";\s*# getopt-style specification)/$1A:$2/
1749 or die_255("Substitution failed");
1750 $code =~ s!^(: who configured the system)!
1755 or die_255("Substitution failed");
1758 apply_patch(<<'EOPATCH');
1759 diff --git a/Configure b/Configure
1760 index 4b55fa6..60c3c64 100755
1763 @@ -1150,6 +1150,7 @@ set X `for arg in "$@"; do echo "X$arg"; done |
1769 : set up default values
1771 @@ -1172,6 +1173,56 @@ while test $# -gt 0; do
1773 -d) shift; fastread=yes;;
1774 -e) shift; alldone=cont;;
1782 + *=*) zzz=`echo "$yyy"|sed 's!=.*!!'`
1786 + zzz=" "`echo "$yyy"|sed 's!^[^=]*=!!'`
1787 + yyy=`echo "$yyy"|sed 's!=.*!!'` ;;
1792 + '') case "$yyy" in
1793 + *:*) xxx=`echo "$yyy"|sed 's!:.*!!'`
1794 + yyy=`echo "$yyy"|sed 's!^[^:]*:!!'`
1795 + zzz=`echo "$yyy"|sed 's!^[^=]*=!!'`
1796 + yyy=`echo "$yyy"|sed 's!=.*!!'` ;;
1797 + *) xxx=`echo "$yyy"|sed 's!:.*!!'`
1798 + yyy=`echo "$yyy"|sed 's!^[^:]*:!!'` ;;
1804 + echo "$yyy=\"\${$yyy}$zzz\"" >> posthint.sh ;;
1806 + echo "$yyy=''" >> posthint.sh ;;
1811 + echo "$yyy='$zzz'" >> posthint.sh ;;
1813 + echo "eval \"$yyy=$zzz\"" >> posthint.sh ;;
1815 + echo "$yyy=\"$zzz\${$yyy}\"" >> posthint.sh ;;
1820 + echo "$yyy=$zzz" >> posthint.sh ;;
1821 + *) echo "$me: unknown -A command '$xxx', ignoring -A $1" >&2 ;;
1831 if ($major < 8 && $^O eq 'aix') {
1832 edit_file('Configure', sub {
1834 # Replicate commit a8c676c69574838b
1835 # Whitespace allowed at the ends of /lib/syscalls.exp lines
1836 # and half of commit c6912327ae30e6de
1837 # AIX syscalls.exp scan: the syscall might be marked 32, 3264, or 64
1838 $code =~ s{(\bsed\b.*\bsyscall)(?:\[0-9\]\*)?(\$.*/lib/syscalls\.exp)}
1839 {$1 . "[0-9]*[ \t]*" . $2}e;
1844 if ($major < 8 && !extract_from_file('Configure',
1845 qr/^\t\tif test ! -t 0; then$/)) {
1846 # Before dfe9444ca7881e71, Configure would refuse to run if stdin was
1847 # not a tty. With that commit, the tty requirement was dropped for -de
1849 # Commit aaeb8e512e8e9e14 dropped the tty requirement for -S
1850 # For those older versions, it's probably easiest if we simply remove
1852 edit_file('Configure', sub {
1854 $code =~ s/test ! -t 0/test Perl = rules/;
1859 if ($major == 8 || $major == 9) {
1860 # Fix symbol detection to that of commit 373dfab3839ca168 if it's any
1861 # intermediate version 5129fff43c4fe08c or later, as the intermediate
1862 # versions don't work correctly on (at least) Sparc Linux.
1863 # 5129fff43c4fe08c adds the first mention of mistrustnm.
1864 # 373dfab3839ca168 removes the last mention of lc=""
1865 edit_file('Configure', sub {
1868 if $code !~ /\btc="";/; # 373dfab3839ca168 or later
1870 if $code !~ /\bmistrustnm\b/; # before 5129fff43c4fe08c
1871 my $fixed = <<'EOC';
1873 : is a C symbol defined?
1876 -v) tf=libc.tmp; tdc="";;
1877 -a) tf=libc.tmp; tdc="[]";;
1878 *) tlook="^$1\$"; tf=libc.list; tdc="()";;
1881 case "$reuseval-$4" in
1883 true-*) tx=no; eval "tval=\$$4"; case "$tval" in "") tx=yes;; esac;;
1888 if $test "$runnm" = true; then
1889 if $contains $tlook $tf >/dev/null 2>&1; then
1891 elif $test "$mistrustnm" = compile -o "$mistrustnm" = run; then
1892 echo "void *(*(p()))$tdc { extern void *$1$tdc; return &$1; } int main() { if(p()) return(0); else return(1); }"> try.c;
1893 $cc -o try $optimize $ccflags $ldflags try.c >/dev/null 2>&1 $libs && tval=true;
1894 $test "$mistrustnm" = run -a -x try && { $run ./try$_exe >/dev/null 2>&1 || tval=false; };
1895 $rm -f try$_exe try.c core core.* try.core;
1898 echo "void *(*(p()))$tdc { extern void *$1$tdc; return &$1; } int main() { if(p()) return(0); else return(1); }"> try.c;
1899 $cc -o try $optimize $ccflags $ldflags try.c $libs >/dev/null 2>&1 && tval=true;
1900 $rm -f try$_exe try.c;
1905 $define) tval=true;;
1913 $code =~ s/\n: is a C symbol defined\?\n.*?\neval "\$2=\$tval"'\n\n/$fixed/sm
1914 or die_255("substitution failed");
1920 && extract_from_file('Configure', qr/^set malloc\.h i_malloc$/)) {
1921 # This is commit 01d07975f7ef0e7d, trimmed, with $compile inlined as
1922 # prior to bd9b35c97ad661cc Configure had the malloc.h test before the
1923 # definition of $compile.
1924 apply_patch(<<'EOPATCH');
1925 diff --git a/Configure b/Configure
1926 index 3d2e8b9..6ce7766 100755
1929 @@ -6743,5 +6743,22 @@ set d_dosuid
1931 : see if this is a malloc.h system
1932 -set malloc.h i_malloc
1934 +: we want a real compile instead of Inhdr because some systems have a
1935 +: malloc.h that just gives a compile error saying to use stdlib.h instead
1938 +#include <stdlib.h>
1939 +#include <malloc.h>
1940 +int main () { return 0; }
1943 +if $cc $optimize $ccflags $ldflags -o try $* try.c $libs > /dev/null 2>&1; then
1944 + echo "<malloc.h> found." >&4
1947 + echo "<malloc.h> NOT found." >&4
1959 if ($^O eq 'freebsd') {
1960 # There are rather too many version-specific FreeBSD hints fixes to
1961 # patch individually. Also, more than once the FreeBSD hints file has
1962 # been written in what turned out to be a rather non-future-proof style,
1963 # with case statements treating the most recent version as the
1964 # exception, instead of treating previous versions' behaviour explicitly
1965 # and changing the default to cater for the current behaviour. (As
1966 # strangely, future versions inherit the current behaviour.)
1967 checkout_file('hints/freebsd.sh');
1968 } elsif ($^O eq 'darwin') {
1970 # We can't build on darwin without some of the data in the hints
1971 # file. Probably less surprising to use the earliest version of
1972 # hints/darwin.sh and then edit in place just below, than use
1973 # blead's version, as that would create a discontinuity at
1974 # f556e5b971932902 - before it, hints bugs would be "fixed", after
1975 # it they'd resurface. This way, we should give the illusion of
1976 # monotonic bug fixing.
1978 if (!-f 'hints/darwin.sh') {
1979 checkout_file('hints/darwin.sh', 'f556e5b971932902');
1983 edit_file('hints/darwin.sh', sub {
1985 # Part of commit 8f4f83badb7d1ba9, which mostly undoes
1986 # commit 0511a818910f476c.
1987 $code =~ s/^cppflags='-traditional-cpp';$/cppflags="\${cppflags} -no-cpp-precomp"/m;
1988 # commit 14c11978e9b52e08/803bb6cc74d36a3f
1989 # Without this, code in libperl.bundle links against op.o
1990 # in preference to opmini.o on the linker command line,
1991 # and hence miniperl tries to use File::Glob instead of
1993 $code =~ s/^(lddlflags=)/ldflags="\${ldflags} -flat_namespace"\n$1/m;
1994 # f556e5b971932902 also patches Makefile.SH with some
1995 # special case code to deal with useshrplib for darwin.
1996 # Given that post 5.8.0 the darwin hints default was
1997 # changed to false, and it would be very complex to splice
1998 # in that code in various versions of Makefile.SH back
1999 # to 5.002, lets just turn it off.
2000 $code =~ s/^useshrplib='true'/useshrplib='false'/m
2003 # Part of commit d235852b65d51c44
2004 # Don't do this on a case sensitive HFS+ partition, as it
2005 # breaks the build for 5.003 and earlier.
2006 if ($case_insensitive
2007 && $code !~ /^firstmakefile=GNUmakefile/) {
2008 $code .= "\nfirstmakefile=GNUmakefile;\n";
2014 } elsif ($^O eq 'netbsd') {
2016 # These are part of commit 099685bc64c7dbce
2017 edit_file('hints/netbsd.sh', sub {
2019 my $fixed = <<'EOC';
2025 if [ -f /usr/libexec/ld.elf_so ]; then
2028 ccdlflags="-Wl,-E -Wl,-R${PREFIX}/lib $ccdlflags"
2029 cccdlflags="-DPIC -fPIC $cccdlflags"
2030 lddlflags="--whole-archive -shared $lddlflags"
2031 elif [ "`uname -m`" = "pmax" ]; then
2032 # NetBSD 1.3 and 1.3.1 on pmax shipped an 'old' ld.so, which will not work.
2034 elif [ -f /usr/libexec/ld.so ]; then
2037 ccdlflags="-Wl,-R${PREFIX}/lib $ccdlflags"
2038 # we use -fPIC here because -fpic is *NOT* enough for some of the
2039 # extensions like Tk on some netbsd platforms (the sparc is one)
2040 cccdlflags="-DPIC -fPIC $cccdlflags"
2041 lddlflags="-Bforcearchive -Bshareable $lddlflags"
2048 $code =~ s/^case "\$osvers" in\n0\.9\|0\.8.*?^esac\n/$fixed/ms;
2052 } elsif ($^O eq 'openbsd') {
2054 checkout_file('hints/openbsd.sh', '43051805d53a3e4c')
2055 unless -f 'hints/openbsd.sh';
2056 my $which = extract_from_file('hints/openbsd.sh',
2057 qr/# from (2\.8|3\.1) onwards/,
2060 my $was = extract_from_file('hints/openbsd.sh',
2061 qr/(lddlflags="(?:-Bforcearchive )?-Bshareable)/);
2062 # This is commit 154d43cbcf57271c and parts of 5c75dbfa77b0949c
2063 # and 29b5585702e5e025
2064 apply_patch(sprintf <<'EOPATCH', $was);
2065 diff --git a/hints/openbsd.sh b/hints/openbsd.sh
2066 index a7d8bf2..5b79709 100644
2067 --- a/hints/openbsd.sh
2068 +++ b/hints/openbsd.sh
2069 @@ -37,7 +37,25 @@ OpenBSD.alpha|OpenBSD.mips|OpenBSD.powerpc|OpenBSD.vax)
2070 # we use -fPIC here because -fpic is *NOT* enough for some of the
2071 # extensions like Tk on some OpenBSD platforms (ie: sparc)
2072 cccdlflags="-DPIC -fPIC $cccdlflags"
2075 + [01].*|2.[0-7]|2.[0-7].*)
2076 + lddlflags="-Bshareable $lddlflags"
2080 + lddlflags="-shared -fPIC $lddlflags"
2082 + *) # from 3.1 onwards
2084 + lddlflags="-shared -fPIC $lddlflags"
2085 + libswanted=`echo $libswanted | sed 's/ dl / /'`
2089 + # We need to force ld to export symbols on ELF platforms.
2090 + # Without this, dlopen() is crippled.
2091 + ELF=`${cc:-cc} -dM -E - </dev/null | grep __ELF__`
2092 + test -n "$ELF" && ldflags="-Wl,-E $ldflags"
2097 } elsif ($which eq '2.8') {
2098 # This is parts of 5c75dbfa77b0949c and 29b5585702e5e025, and
2099 # possibly eb9cd59d45ad2908
2100 my $was = extract_from_file('hints/openbsd.sh',
2101 qr/lddlflags="(-shared(?: -fPIC)?) \$lddlflags"/);
2103 apply_patch(sprintf <<'EOPATCH', $was);
2104 --- a/hints/openbsd.sh 2011-10-21 17:25:20.000000000 +0200
2105 +++ b/hints/openbsd.sh 2011-10-21 16:58:43.000000000 +0200
2107 [01].*|2.[0-7]|2.[0-7].*)
2108 lddlflags="-Bshareable $lddlflags"
2110 - *) # from 2.8 onwards
2113 - lddlflags="%s $lddlflags"
2114 + lddlflags="-shared -fPIC $lddlflags"
2116 + *) # from 3.1 onwards
2118 + lddlflags="-shared -fPIC $lddlflags"
2119 + libswanted=`echo $libswanted | sed 's/ dl / /'`
2123 + # We need to force ld to export symbols on ELF platforms.
2124 + # Without this, dlopen() is crippled.
2125 + ELF=`${cc:-cc} -dM -E - </dev/null | grep __ELF__`
2126 + test -n "$ELF" && ldflags="-Wl,-E $ldflags"
2131 } elsif ($which eq '3.1'
2132 && !extract_from_file('hints/openbsd.sh',
2133 qr/We need to force ld to export symbols on ELF platforms/)) {
2134 # This is part of 29b5585702e5e025
2135 apply_patch(<<'EOPATCH');
2136 diff --git a/hints/openbsd.sh b/hints/openbsd.sh
2137 index c6b6bc9..4839d04 100644
2138 --- a/hints/openbsd.sh
2139 +++ b/hints/openbsd.sh
2140 @@ -54,6 +54,11 @@ alpha-2.[0-8]|mips-*|vax-*|powerpc-2.[0-7]|m88k-*)
2141 libswanted=`echo $libswanted | sed 's/ dl / /'`
2145 + # We need to force ld to export symbols on ELF platforms.
2146 + # Without this, dlopen() is crippled.
2147 + ELF=`${cc:-cc} -dM -E - </dev/null | grep __ELF__`
2148 + test -n "$ELF" && ldflags="-Wl,-E $ldflags"
2155 } elsif ($^O eq 'linux') {
2157 # sparc linux seems to need the -Dbool=char -DHAS_BOOL part of
2158 # perl5.000 patch.0n: [address Configure and build issues]
2159 edit_file('hints/linux.sh', sub {
2161 $code =~ s!-I/usr/include/bsd!-Dbool=char -DHAS_BOOL!g;
2167 if (`uname -sm` =~ qr/^Linux sparc/) {
2168 if (extract_from_file('hints/linux.sh', qr/sparc-linux/)) {
2169 # Be sure to use -fPIC not -fpic on Linux/SPARC
2170 apply_commit('f6527d0ef0c13ad4');
2171 } elsif(!extract_from_file('hints/linux.sh',
2172 qr/^sparc-linux\)$/)) {
2173 my $fh = open_or_die('hints/linux.sh', '>>');
2174 print $fh <<'EOT' or die_255($!);
2176 case "`uname -m`" in
2178 case "$cccdlflags" in
2179 *-fpic*) cccdlflags="`echo $cccdlflags|sed 's/-fpic/-fPIC/'`" ;;
2180 *) cccdlflags="$cccdlflags -fPIC" ;;
2189 } elsif ($^O eq 'solaris') {
2190 if (($major == 13 || $major == 14)
2191 && extract_from_file('hints/solaris_2.sh', qr/getconfldllflags/)) {
2192 apply_commit('c80bde4388070c45');
2198 # Cwd.xs added in commit 0d2079faa739aaa9. Cwd.pm moved to ext/ 8 years
2199 # later in commit 403f501d5b37ebf0
2200 if ($major > 0 && <*/Cwd/Cwd.xs>) {
2202 && !extract_from_file('Makefile.SH', qr/^extra_dep=''$/)) {
2203 # The Makefile.PL for Unicode::Normalize needs
2204 # lib/unicore/CombiningClass.pl. Even without a parallel build, we
2205 # need a dependency to ensure that it builds. This is a variant of
2206 # commit 9f3ef600c170f61e. Putting this for earlier versions gives
2207 # us a spot on which to hang the edits below
2208 apply_patch(<<'EOPATCH');
2209 diff --git a/Makefile.SH b/Makefile.SH
2210 index f61d0db..6097954 100644
2213 @@ -155,10 +155,20 @@ esac
2215 : Prepare dependency lists for Makefile.
2218 for f in $dynamic_ext; do
2219 : the dependency named here will never exist
2220 base=`echo "$f" | sed 's/.*\///'`
2221 - dynamic_list="$dynamic_list lib/auto/$f/$base.$dlext"
2222 + this_target="lib/auto/$f/$base.$dlext"
2223 + dynamic_list="$dynamic_list $this_target"
2225 + : Parallel makes reveal that we have some interdependencies
2227 + Math/BigInt/FastCalc) extra_dep="$extra_dep
2228 +$this_target: lib/auto/List/Util/Util.$dlext" ;;
2229 + Unicode/Normalize) extra_dep="$extra_dep
2230 +$this_target: lib/unicore/CombiningClass.pl" ;;
2235 @@ -987,2 +997,9 @@ n_dummy $(nonxs_ext): miniperl$(EXE_EXT) preplibrary $(DYNALOADER) FORCE
2236 @$(LDLIBPTH) sh ext/util/make_ext nonxs $@ MAKE=$(MAKE) LIBPERL_A=$(LIBPERL)
2239 +$spitshell >>Makefile <<EOF
2243 +$spitshell >>Makefile <<'!NO!SUBS!'
2248 if ($major == 15 && $^O !~ /^(linux|darwin|.*bsd)$/
2249 && extract_from_file('Makefile.SH', qr/^V.* \?= /)) {
2250 # Remove the GNU-make-ism (which the BSD makes also support, but
2251 # most other makes choke on)
2252 apply_patch(<<'EOPATCH');
2253 diff --git a/Makefile.SH b/Makefile.SH
2254 index 94952bd..13e9001 100755
2257 @@ -338,8 +338,8 @@ linux*|darwin)
2258 $spitshell >>$Makefile <<!GROK!THIS!
2259 # If you're going to use valgrind and it can't be invoked as plain valgrind
2260 # then you'll need to change this, or override it on the make command line.
2261 -VALGRIND ?= valgrind
2262 -VG_TEST ?= ./perl -e 1 2>/dev/null
2263 +VALGRIND = valgrind
2264 +VG_TEST = ./perl -e 1 2>/dev/null
2272 if (extract_from_file('patchlevel.h',
2273 qr/^#include "unpushed\.h"/)) {
2274 # I had thought it easier to detect when building one of the 52
2275 # commits with the original method of incorporating the git
2276 # revision and drop parallel make flags. Commits shown by
2277 # git log 46807d8e809cc127^..dcff826f70bf3f64^ ^d4fb0a1f15d1a1c4
2278 # However, it's not actually possible to make miniperl for that
2279 # configuration as-is, because the file .patchnum is only made
2280 # as a side effect of target 'all'
2281 # I also don't think that it's "safe" to simply run
2282 # make_patchnum.sh before the build. We need the proper
2283 # dependency rules in the Makefile to *stop* it being run again
2284 # at the wrong time.
2285 # This range is important because contains the commit that
2286 # merges Schwern's y2038 work.
2287 apply_patch(<<'EOPATCH');
2288 diff --git a/Makefile.SH b/Makefile.SH
2289 index 9ad8b6f..106e721 100644
2292 @@ -540,9 +544,14 @@ sperl.i: perl.c $(h)
2294 .PHONY: all translators utilities make_patchnum
2297 +make_patchnum: lib/Config_git.pl
2299 +lib/Config_git.pl: make_patchnum.sh
2300 sh $(shellflags) make_patchnum.sh
2302 +# .patchnum, unpushed.h and lib/Config_git.pl are built by make_patchnum.sh
2303 +unpushed.h .patchnum: lib/Config_git.pl
2305 # make sure that we recompile perl.c if .patchnum changes
2306 perl$(OBJ_EXT): .patchnum unpushed.h
2309 } elsif (-f '.gitignore'
2310 && extract_from_file('.gitignore', qr/^\.patchnum$/)) {
2311 # 8565263ab8a47cda to 46807d8e809cc127^ inclusive.
2312 edit_file('Makefile.SH', sub {
2314 $code =~ s/^make_patchnum:\n/make_patchnum: .patchnum
2318 .patchnum: make_patchnum.sh
2322 } elsif (-f 'lib/.gitignore'
2323 && extract_from_file('lib/.gitignore',
2324 qr!^/Config_git.pl!)
2325 && !extract_from_file('Makefile.SH',
2326 qr/^uudmap\.h.*:bitcount.h$/)) {
2327 # Between commits and dcff826f70bf3f64 and 0f13ebd5d71f8177^
2328 edit_file('Makefile.SH', sub {
2330 # Bug introduced by 344af494c35a9f0f
2331 # fixed in 0f13ebd5d71f8177
2332 $code =~ s{^(pod/perlapi\.pod) (pod/perlintern\.pod): }
2334 # Bug introduced by efa50c51e3301a2c
2335 # fixed in 0f13ebd5d71f8177
2336 $code =~ s{^(uudmap\.h) (bitcount\.h): }
2339 # The rats nest of getting git_version.h correct
2341 if ($code =~ s{git_version\.h: stock_git_version\.h
2342 \tcp stock_git_version\.h git_version\.h}
2344 # before 486cd780047ff224
2346 # We probably can't build between
2347 # 953f6acfa20ec275^ and 8565263ab8a47cda
2348 # inclusive, but all commits in that range
2349 # relate to getting make_patchnum.sh working,
2350 # so it is extremely unlikely to be an
2351 # interesting bisect target. They will skip.
2353 # No, don't spawn a submake if
2354 # make_patchnum.sh or make_patchnum.pl fails
2355 $code =~ s{\|\| \$\(MAKE\) miniperl.*}
2357 $code =~ s{^\t(sh.*make_patchnum\.sh.*)}
2360 # Use an external perl to run make_patchnum.pl
2361 # because miniperl still depends on
2363 $code =~ s{^\t.*make_patchnum\.pl}
2364 {\t-$^X make_patchnum.pl}m;
2367 # "Truth in advertising" - running
2368 # make_patchnum generates 2 files.
2369 $code =~ s{^make_patchnum:.*}{
2370 make_patchnum: lib/Config_git.pl
2372 git_version.h: lib/Config_git.pl
2374 perlmini\$(OBJ_EXT): git_version.h
2376 lib/Config_git.pl:}m;
2378 # Right, now we've corrected Makefile.SH to
2379 # correctly describe how lib/Config_git.pl and
2380 # git_version.h are made, we need to fix the rest
2382 # This emulates commit 2b63e250843b907e
2383 # This might duplicate the rule stating that
2384 # git_version.h depends on lib/Config_git.pl
2386 $code =~ s{^(?:lib/Config_git\.pl )?git_version\.h: (.* make_patchnum\.pl.*)}
2387 {git_version.h: lib/Config_git.pl
2389 lib/Config_git.pl: $1}m;
2391 # This emulates commits 0f13ebd5d71f8177 and
2392 # and a04d4598adc57886. It ensures that
2393 # lib/Config_git.pl is built before configpm,
2394 # and that configpm is run exactly once.
2395 $code =~ s{^(\$\(.*?\) )?(\$\(CONFIGPOD\))(: .*? configpm Porting/Glossary)( lib/Config_git\.pl)?}{
2396 # If present, other files depend on $(CONFIGPOD)
2397 ($1 ? "$1: $2\n\n" : '')
2398 # Then the rule we found
2400 # Add dependency if not there
2401 . ($4 ? $4 : ' lib/Config_git.pl')
2410 # Commits dc0655f797469c47 and d11a62fe01f2ecb2
2411 edit_file('Makefile.SH', sub {
2413 foreach my $ext (qw(Encode SDBM_File)) {
2414 next if $code =~ /\b$ext\) extra_dep=/s;
2415 $code =~ s!(\) extra_dep="\$extra_dep
2416 \$this_target: .*?" ;;)
2419 $ext) extra_dep="\$extra_dep
2420 \$this_target: lib/auto/Cwd/Cwd.\$dlext" ;;
2429 # Remove commits 9fec149bb652b6e9 and 5bab1179608f81d8, which add/amend
2430 # rules to automatically run regen scripts that rebuild C headers. These
2431 # cause problems because a git checkout doesn't preserve relative file
2432 # modification times, hence the regen scripts may fire. This will
2433 # obscure whether the repository had the correct generated headers
2435 # Also, the dependency rules for running the scripts were not correct,
2436 # which could cause spurious re-builds on re-running make, and can cause
2437 # complete build failures for a parallel make.
2438 if (extract_from_file('Makefile.SH',
2439 qr/Writing it this way gives make a big hint to always run opcode\.pl before/)) {
2440 apply_commit('70c6e6715e8fec53');
2441 } elsif (extract_from_file('Makefile.SH',
2442 qr/^opcode\.h opnames\.h pp_proto\.h pp\.sym: opcode\.pl$/)) {
2443 revert_commit('9fec149bb652b6e9');
2447 if ($^O eq 'aix' && $major >= 11 && $major <= 15
2448 && extract_from_file('makedef.pl', qr/^use Config/)) {
2449 edit_file('Makefile.SH', sub {
2450 # The AIX part of commit e6807d8ab22b761c
2451 # It's safe to substitute lib/Config.pm for config.sh
2452 # as lib/Config.pm depends on config.sh
2453 # If the tree is post e6807d8ab22b761c, the substitution
2454 # won't match, which is harmless.
2456 $code =~ s{^(perl\.exp:.* )config\.sh(\b.*)}
2457 {$1 . '$(CONFIGPM)' . $2}me;
2462 # There was a bug in makedepend.SH which was fixed in version 96a8704c.
2463 # Symptom was './makedepend: 1: Syntax error: Unterminated quoted string'
2464 # Remove this if you're actually bisecting a problem related to
2466 # If you do this, you may need to add in code to correct the output of older
2467 # makedepends, which don't correctly filter newer gcc output such as
2469 checkout_file('makedepend.SH');
2471 if ($major < 4 && -f 'config.sh'
2472 && !extract_from_file('config.sh', qr/^trnl=/)) {
2473 # This seems to be necessary to avoid makedepend becoming confused,
2474 # and hanging on stdin. Seems that the code after
2475 # make shlist || ...here... is never run.
2476 edit_file('makedepend.SH', sub {
2478 $code =~ s/^trnl='\$trnl'$/trnl='\\n'/m;
2485 # This is ordered by $major, as it's likely that different platforms may
2486 # well want to share code.
2488 if ($major == 2 && extract_from_file('perl.c', qr/^\tfclose\(e_fp\);$/)) {
2489 # need to patch perl.c to avoid calling fclose() twice on e_fp when
2491 # This diff is part of commit ab821d7fdc14a438. The second close was
2492 # introduced with perl-5.002, commit a5f75d667838e8e7
2493 # Might want a6c477ed8d4864e6 too, for the corresponding change to
2494 # pp_ctl.c (likely without this, eval will have "fun")
2495 apply_patch(<<'EOPATCH');
2496 diff --git a/perl.c b/perl.c
2497 index 03c4d48..3c814a2 100644
2500 @@ -252,6 +252,7 @@ setuid perl scripts securely.\n");
2501 #ifndef VMS /* VMS doesn't have environ array */
2502 origenviron = environ;
2504 + e_tmpname = Nullch;
2508 @@ -405,6 +406,7 @@ setuid perl scripts securely.\n");
2510 if (Fflush(e_fp) || ferror(e_fp) || fclose(e_fp))
2511 croak("Can't write to temp file for -e: %s", Strerror(errno));
2514 scriptname = e_tmpname;
2516 @@ -470,10 +472,10 @@ setuid perl scripts securely.\n");
2517 curcop->cop_line = 0;
2518 curstash = defstash;
2524 (void)UNLINK(e_tmpname);
2525 + Safefree(e_tmpname);
2526 + e_tmpname = Nullch;
2529 /* now that script is parsed, we can modify record separator */
2530 @@ -1369,7 +1371,7 @@ SV *sv;
2531 scriptname = xfound;
2534 - origfilename = savepv(e_fp ? "-e" : scriptname);
2535 + origfilename = savepv(e_tmpname ? "-e" : scriptname);
2536 curcop->cop_filegv = gv_fetchfile(origfilename);
2537 if (strEQ(origfilename,"-"))
2543 if ($major < 3 && $^O eq 'openbsd'
2544 && !extract_from_file('pp_sys.c', qr/BSD_GETPGRP/)) {
2545 # Part of commit c3293030fd1b7489
2546 apply_patch(<<'EOPATCH');
2547 diff --git a/pp_sys.c b/pp_sys.c
2548 index 4608a2a..f0c9d1d 100644
2551 @@ -2903,8 +2903,8 @@ PP(pp_getpgrp)
2556 - value = (I32)getpgrp(pid);
2558 + value = (I32)BSD_GETPGRP(pid);
2561 DIE("POSIX getpgrp can't take an argument");
2562 @@ -2933,8 +2933,8 @@ PP(pp_setpgrp)
2565 TAINT_PROPER("setpgrp");
2567 - SETi( setpgrp(pid, pgrp) >= 0 );
2569 + SETi( BSD_SETPGRP(pid, pgrp) >= 0 );
2571 if ((pgrp != 0) || (pid != 0)) {
2572 DIE("POSIX setpgrp can't take an argument");
2576 if ($major < 4 && $^O eq 'openbsd') {
2578 # Need changes from commit a6e633defa583ad5.
2579 # Commits c07a80fdfe3926b5 and f82b3d4130164d5f changed the same part
2582 if (extract_from_file('perl.h',
2583 qr/^#ifdef HAS_GETPGRP2$/)) {
2587 #define TAINT_PROPER(s) if (tainting) taint_proper(no_security, s)
2588 #define TAINT_ENV() if (tainting) taint_env()
2590 ! #ifdef HAS_GETPGRP2
2591 ! # ifndef HAS_GETPGRP
2592 ! # define HAS_GETPGRP
2596 ! #ifdef HAS_SETPGRP2
2597 ! # ifndef HAS_SETPGRP
2598 ! # define HAS_SETPGRP
2603 } elsif (extract_from_file('perl.h',
2604 qr/Gack, you have one but not both of getpgrp2/)) {
2608 #define TAINT_PROPER(s) if (tainting) taint_proper(no_security, s)
2609 #define TAINT_ENV() if (tainting) taint_env()
2611 ! #if defined(HAS_GETPGRP2) && defined(HAS_SETPGRP2)
2612 ! # define getpgrp getpgrp2
2613 ! # define setpgrp setpgrp2
2614 ! # ifndef HAS_GETPGRP
2615 ! # define HAS_GETPGRP
2617 ! # ifndef HAS_SETPGRP
2618 ! # define HAS_SETPGRP
2620 ! # ifndef USE_BSDPGRP
2621 ! # define USE_BSDPGRP
2624 ! # if defined(HAS_GETPGRP2) || defined(HAS_SETPGRP2)
2625 ! #include "Gack, you have one but not both of getpgrp2() and setpgrp2()."
2630 } elsif (extract_from_file('perl.h',
2631 qr/^#ifdef USE_BSDPGRP$/)) {
2635 #define TAINT_PROPER(s) if (tainting) taint_proper(no_security, s)
2636 #define TAINT_ENV() if (tainting) taint_env()
2638 ! #ifdef USE_BSDPGRP
2639 ! # ifdef HAS_GETPGRP
2640 ! # define BSD_GETPGRP(pid) getpgrp((pid))
2642 ! # ifdef HAS_SETPGRP
2643 ! # define BSD_SETPGRP(pid, pgrp) setpgrp((pid), (pgrp))
2646 ! # ifdef HAS_GETPGRP2
2647 ! # define BSD_GETPGRP(pid) getpgrp2((pid))
2648 ! # ifndef HAS_GETPGRP
2649 ! # define HAS_GETPGRP
2652 ! # ifdef HAS_SETPGRP2
2653 ! # define BSD_SETPGRP(pid, pgrp) setpgrp2((pid), (pgrp))
2654 ! # ifndef HAS_SETPGRP
2655 ! # define HAS_SETPGRP
2660 #ifndef _TYPES_ /* If types.h defines this it's easy. */
2664 apply_patch(<<"EOPATCH");
2665 *** a/perl.h 2011-10-21 09:46:12.000000000 +0200
2666 --- b/perl.h 2011-10-21 09:46:12.000000000 +0200
2668 #define TAINT_PROPER(s) if (tainting) taint_proper(no_security, s)
2669 #define TAINT_ENV() if (tainting) taint_env()
2671 ! /* XXX All process group stuff is handled in pp_sys.c. Should these
2672 ! defines move there? If so, I could simplify this a lot. --AD 9/96.
2674 ! /* Process group stuff changed from traditional BSD to POSIX.
2675 ! perlfunc.pod documents the traditional BSD-style syntax, so we'll
2676 ! try to preserve that, if possible.
2678 ! #ifdef HAS_SETPGID
2679 ! # define BSD_SETPGRP(pid, pgrp) setpgid((pid), (pgrp))
2681 ! # if defined(HAS_SETPGRP) && defined(USE_BSD_SETPGRP)
2682 ! # define BSD_SETPGRP(pid, pgrp) setpgrp((pid), (pgrp))
2684 ! # ifdef HAS_SETPGRP2 /* DG/UX */
2685 ! # define BSD_SETPGRP(pid, pgrp) setpgrp2((pid), (pgrp))
2689 ! #if defined(BSD_SETPGRP) && !defined(HAS_SETPGRP)
2690 ! # define HAS_SETPGRP /* Well, effectively it does . . . */
2693 ! /* getpgid isn't POSIX, but at least Solaris and Linux have it, and it makes
2694 ! our life easier :-) so we'll try it.
2696 ! #ifdef HAS_GETPGID
2697 ! # define BSD_GETPGRP(pid) getpgid((pid))
2699 ! # if defined(HAS_GETPGRP) && defined(USE_BSD_GETPGRP)
2700 ! # define BSD_GETPGRP(pid) getpgrp((pid))
2702 ! # ifdef HAS_GETPGRP2 /* DG/UX */
2703 ! # define BSD_GETPGRP(pid) getpgrp2((pid))
2707 ! #if defined(BSD_GETPGRP) && !defined(HAS_GETPGRP)
2708 ! # define HAS_GETPGRP /* Well, effectively it does . . . */
2711 ! /* These are not exact synonyms, since setpgrp() and getpgrp() may
2712 ! have different behaviors, but perl.h used to define USE_BSDPGRP
2713 ! (prior to 5.003_05) so some extension might depend on it.
2715 ! #if defined(USE_BSD_SETPGRP) || defined(USE_BSD_GETPGRP)
2716 ! # ifndef USE_BSDPGRP
2717 ! # define USE_BSDPGRP
2721 #ifndef _TYPES_ /* If types.h defines this it's easy. */
2726 if ($major < 4 && $^O eq 'hpux'
2727 && extract_from_file('sv.c', qr/i = _filbuf\(/)) {
2728 apply_patch(<<'EOPATCH');
2729 diff --git a/sv.c b/sv.c
2730 index a1f1d60..0a806f1 100644
2733 @@ -2641,7 +2641,7 @@ I32 append;
2735 FILE_cnt(fp) = cnt; /* deregisterize cnt and ptr */
2737 - i = _filbuf(fp); /* get more characters */
2738 + i = __filbuf(fp); /* get more characters */
2740 ptr = FILE_ptr(fp); /* reregisterize cnt and ptr */
2746 if ($major == 4 && extract_from_file('scope.c', qr/\(SV\*\)SSPOPINT/)) {
2747 # [PATCH] 5.004_04 +MAINT_TRIAL_1 broken when sizeof(int) != sizeof(void)
2748 # Fixes a bug introduced in 161b7d1635bc830b
2749 apply_commit('9002cb76ec83ef7f');
2752 if ($major == 4 && extract_from_file('av.c', qr/AvARRAY\(av\) = 0;/)) {
2753 # Fixes a bug introduced in 1393e20655efb4bc
2754 apply_commit('e1c148c28bf3335b', 'av.c');
2758 my $rest = extract_from_file('perl.c', qr/delimcpy(.*)/);
2759 if (defined $rest and $rest !~ /,$/) {
2760 # delimcpy added in fc36a67e8855d031, perl.c refactored to use it.
2761 # bug introduced in 2a92aaa05aa1acbf, fixed in 8490252049bf42d3
2762 # code then moved to util.c in commit 491527d0220de34e
2763 apply_patch(<<'EOPATCH');
2764 diff --git a/perl.c b/perl.c
2765 index 4eb69e3..54bbb00 100644
2768 @@ -1735,7 +1735,7 @@ SV *sv;
2769 if (len < sizeof tokenbuf)
2770 tokenbuf[len] = '\0';
2771 #else /* ! (atarist || DOSISH) */
2772 - s = delimcpy(tokenbuf, tokenbuf + sizeof tokenbuf, s, bufend
2773 + s = delimcpy(tokenbuf, tokenbuf + sizeof tokenbuf, s, bufend,
2776 #endif /* ! (atarist || DOSISH) */
2781 if ($major == 4 && $^O eq 'linux') {
2782 # Whilst this is fixed properly in f0784f6a4c3e45e1 which provides the
2783 # Configure probe, it's easier to back out the problematic changes made
2784 # in these previous commits.
2786 # In maint-5.004, the simplest addition is to "correct" the file to
2787 # use the same pre-processor macros as blead had used. Whilst commit
2788 # 9b599b2a63d2324d (reverted below) is described as
2789 # [win32] merge change#887 from maintbranch
2790 # it uses __sun__ and __svr4__ instead of the __sun and __SVR4 of the
2791 # maint branch commit 6cdf74fe31f049dc
2793 edit_file('doio.c', sub {
2795 $code =~ s{defined\(__sun\) && defined\(__SVR4\)}
2796 {defined(__sun__) && defined(__svr4__)}g;
2800 if (extract_from_file('doio.c',
2801 qr!^/\* XXX REALLY need metaconfig test \*/$!)) {
2802 revert_commit('4682965a1447ea44', 'doio.c');
2804 if (my $token = extract_from_file('doio.c',
2805 qr!^#if (defined\(__sun(?:__)?\)) && defined\(__svr4__\) /\* XXX Need metaconfig test \*/$!)) {
2806 my $patch = `git show -R 9b599b2a63d2324d doio.c`;
2807 $patch =~ s/defined\(__sun__\)/$token/g;
2808 apply_patch($patch);
2810 if (extract_from_file('doio.c',
2811 qr!^/\* linux \(and Solaris2\?\) uses :$!)) {
2812 revert_commit('8490252049bf42d3', 'doio.c');
2814 if (extract_from_file('doio.c',
2815 qr/^ unsemds.buf = &semds;$/)) {
2816 revert_commit('8e591e46b4c6543e');
2818 if (extract_from_file('doio.c',
2819 qr!^#ifdef __linux__ /\* XXX Need metaconfig test \*/$!)) {
2820 # Reverts part of commit 3e3baf6d63945cb6
2821 apply_patch(<<'EOPATCH');
2822 diff --git b/doio.c a/doio.c
2823 index 62b7de9..0d57425 100644
2826 @@ -1333,9 +1331,6 @@ SV **sp;
2828 I32 id, n, cmd, infosize, getinfo;
2830 -#ifdef __linux__ /* XXX Need metaconfig test */
2831 - union semun unsemds;
2834 id = SvIVx(*++mark);
2835 n = (optype == OP_SEMCTL) ? SvIVx(*++mark) : 0;
2836 @@ -1364,29 +1359,11 @@ SV **sp;
2837 infosize = sizeof(struct semid_ds);
2838 else if (cmd == GETALL || cmd == SETALL)
2840 -#ifdef __linux__ /* XXX Need metaconfig test */
2842 - int semctl (int semid, int semnun, int cmd, union semun arg)
2846 - struct semid_ds *buf;
2850 - union semun semds;
2851 - if (semctl(id, 0, IPC_STAT, semds) == -1)
2853 struct semid_ds semds;
2854 if (semctl(id, 0, IPC_STAT, &semds) == -1)
2857 getinfo = (cmd == GETALL);
2858 -#ifdef __linux__ /* XXX Need metaconfig test */
2859 - infosize = semds.buf->sem_nsems * sizeof(short);
2861 infosize = semds.sem_nsems * sizeof(short);
2863 /* "short" is technically wrong but much more portable
2864 than guessing about u_?short(_t)? */
2866 @@ -1429,12 +1406,7 @@ SV **sp;
2870 -#ifdef __linux__ /* XXX Need metaconfig test */
2871 - unsemds.buf = (struct semid_ds *)a;
2872 - ret = semctl(id, n, cmd, unsemds);
2874 ret = semctl(id, n, cmd, (struct semid_ds *)a);
2881 # Incorrect prototype added as part of 8ac853655d9b7447, fixed as part
2882 # of commit dc45a647708b6c54, with at least one intermediate
2883 # modification. Correct prototype for gethostbyaddr has socklen_t
2884 # second. Linux has uint32_t first for getnetbyaddr.
2885 # Easiest just to remove, instead of attempting more complex patching.
2886 # Something similar may be needed on other platforms.
2887 edit_file('pp_sys.c', sub {
2889 $code =~ s/^ struct hostent \*(?:PerlSock_)?gethostbyaddr\([^)]+\);$//m;
2890 $code =~ s/^ struct netent \*getnetbyaddr\([^)]+\);$//m;
2895 if ($major < 5 && $^O eq 'aix'
2896 && !extract_from_file('pp_sys.c',
2897 qr/defined\(HOST_NOT_FOUND\) && !defined\(h_errno\)/)) {
2898 # part of commit dc45a647708b6c54
2899 # Andy Dougherty's configuration patches (Config_63-01 up to 04).
2900 apply_patch(<<'EOPATCH')
2901 diff --git a/pp_sys.c b/pp_sys.c
2902 index c2fcb6f..efa39fb 100644
2905 @@ -54,7 +54,7 @@ extern "C" int syscall(unsigned long,...);
2909 -#ifdef HOST_NOT_FOUND
2910 +#if defined(HOST_NOT_FOUND) && !defined(h_errno)
2918 && `git rev-parse HEAD` eq "22c35a8c2392967a5ba6b5370695be464bd7012c\n") {
2919 # Commit 22c35a8c2392967a is significant,
2920 # "phase 1 of somewhat major rearrangement of PERL_OBJECT stuff"
2921 # but doesn't build due to 2 simple errors. blead in this broken state
2922 # was merged to the cfgperl branch, and then these were immediately
2923 # corrected there. cfgperl (with the fixes) was merged back to blead.
2924 # The resultant rather twisty maze of commits looks like this:
2928 * | | commit 137225782c183172f360c827424b9b9f8adbef0e
2929 |\ \ \ Merge: 22c35a8 2a8ee23
2930 | |/ / Author: Gurusamy Sarathy <gsar@cpan.org>
2931 | | | Date: Fri Oct 30 17:38:36 1998 +0000
2933 | | | integrate cfgperl tweaks into mainline
2935 | | | p4raw-id: //depot/perl@2144
2937 | * | commit 2a8ee23279873759693fa83eca279355db2b665c
2938 | | | Author: Jarkko Hietaniemi <jhi@iki.fi>
2939 | | | Date: Fri Oct 30 13:27:39 1998 +0000
2941 | | | There can be multiple yacc/bison errors.
2943 | | | p4raw-id: //depot/cfgperl@2143
2945 | * | commit 93fb2ac393172fc3e2c14edb20b718309198abbc
2946 | | | Author: Jarkko Hietaniemi <jhi@iki.fi>
2947 | | | Date: Fri Oct 30 13:18:43 1998 +0000
2949 | | | README.posix-bc update.
2951 | | | p4raw-id: //depot/cfgperl@2142
2953 | * | commit 4ec43091e8e6657cb260b5e563df30aaa154effe
2954 | | | Author: Jarkko Hietaniemi <jhi@iki.fi>
2955 | | | Date: Fri Oct 30 09:12:59 1998 +0000
2957 | | | #2133 fallout.
2959 | | | p4raw-id: //depot/cfgperl@2141
2961 | * | commit 134ca994cfefe0f613d43505a885e4fc2100b05c
2962 | |\ \ Merge: 7093112 22c35a8
2963 | |/ / Author: Jarkko Hietaniemi <jhi@iki.fi>
2964 |/| | Date: Fri Oct 30 08:43:18 1998 +0000
2966 | | | Integrate from mainperl.
2968 | | | p4raw-id: //depot/cfgperl@2140
2970 * | | commit 22c35a8c2392967a5ba6b5370695be464bd7012c
2971 | | | Author: Gurusamy Sarathy <gsar@cpan.org>
2972 | | | Date: Fri Oct 30 02:51:39 1998 +0000
2974 | | | phase 1 of somewhat major rearrangement of PERL_OBJECT stuff
2975 | | | (objpp.h is gone, embed.pl now does some of that); objXSUB.h
2976 | | | should soon be automated also; the global variables that
2977 | | | escaped the PL_foo conversion are now reined in; renamed
2978 | | | MAGIC in regcomp.h to REG_MAGIC to avoid collision with the
2979 | | | type of same name; duplicated lists of pp_things in various
2980 | | | places is now gone; result has only been tested on win32
2982 | | | p4raw-id: //depot/perl@2133
2988 # and completely confuses git bisect (and at least me), causing it to
2989 # the bisect run to confidently return the wrong answer, an unrelated
2990 # commit on the cfgperl branch.
2992 apply_commit('4ec43091e8e6657c');
2996 && extract_from_file('pp_sys.c', qr/PERL_EFF_ACCESS_R_OK/)
2997 && !extract_from_file('pp_sys.c', qr/XXX Configure test needed for eaccess/)) {
2998 # Between 5ff3f7a4e03a6b10 and c955f1177b2e311d^
2999 # This is the meat of commit c955f1177b2e311d (without the other
3000 # indenting changes that would cause a conflict).
3001 # Without this 538 revisions won't build on (at least) Linux
3002 apply_patch(<<'EOPATCH');
3003 diff --git a/pp_sys.c b/pp_sys.c
3004 index d60c8dc..867dee4 100644
3007 @@ -198,9 +198,18 @@ static char zero_but_true[ZBTLEN + 1] = "0 but true";
3008 # if defined(I_SYS_SECURITY)
3009 # include <sys/security.h>
3011 -# define PERL_EFF_ACCESS_R_OK(p) (eaccess((p), R_OK, ACC_SELF))
3012 -# define PERL_EFF_ACCESS_W_OK(p) (eaccess((p), W_OK, ACC_SELF))
3013 -# define PERL_EFF_ACCESS_X_OK(p) (eaccess((p), X_OK, ACC_SELF))
3014 + /* XXX Configure test needed for eaccess */
3016 + /* HP SecureWare */
3017 +# define PERL_EFF_ACCESS_R_OK(p) (eaccess((p), R_OK, ACC_SELF))
3018 +# define PERL_EFF_ACCESS_W_OK(p) (eaccess((p), W_OK, ACC_SELF))
3019 +# define PERL_EFF_ACCESS_X_OK(p) (eaccess((p), X_OK, ACC_SELF))
3022 +# define PERL_EFF_ACCESS_R_OK(p) (eaccess((p), R_OK))
3023 +# define PERL_EFF_ACCESS_W_OK(p) (eaccess((p), W_OK))
3024 +# define PERL_EFF_ACCESS_X_OK(p) (eaccess((p), X_OK))
3028 #if !defined(PERL_EFF_ACCESS_R_OK) && defined(HAS_ACCESSX) && defined(ACC_SELF)
3033 && extract_from_file('mg.c', qr/If we're still on top of the stack, pop us off/)
3034 && !extract_from_file('mg.c', qr/PL_savestack_ix -= popval/)) {
3035 # Fix up commit 455ece5e082708b1:
3036 # SSNEW() API for allocating memory on the savestack
3037 # Message-Id: <tqemtae338.fsf@puma.genscan.com>
3038 # Subject: [PATCH 5.005_51] (was: why SAVEDESTRUCTOR()...)
3039 apply_commit('3c8a44569607336e', 'mg.c');
3043 if (extract_from_file('doop.c', qr/croak\(no_modify\);/)
3044 && extract_from_file('doop.c', qr/croak\(PL_no_modify\);/)) {
3045 # Whilst the log suggests that this would only fix 5 commits, in
3046 # practice this area of history is a complete tarpit, and git bisect
3047 # gets very confused by the skips in the middle of the back and
3048 # forth merging between //depot/perl and //depot/cfgperl
3049 apply_commit('6393042b638dafd3');
3052 # One error "fixed" with another:
3053 if (extract_from_file('pp_ctl.c',
3054 qr/\Qstatic void *docatch_body _((void *o));\E/)) {
3055 apply_commit('5b51e982882955fe');
3057 # Which is then fixed by this:
3058 if (extract_from_file('pp_ctl.c',
3059 qr/\Qstatic void *docatch_body _((valist\E/)) {
3060 apply_commit('47aa779ee4c1a50e');
3063 if (extract_from_file('thrdvar.h', qr/PERLVARI\(Tprotect/)
3064 && !extract_from_file('embedvar.h', qr/PL_protect/)) {
3065 # Commit 312caa8e97f1c7ee didn't update embedvar.h
3066 apply_commit('e0284a306d2de082', 'embedvar.h');
3071 && extract_from_file('sv.c',
3072 qr/PerlDir_close\(IoDIRP\((?:\(IO\*\))?sv\)\);/)
3073 && !(extract_from_file('toke.c',
3074 qr/\QIoDIRP(FILTER_DATA(AvFILLp(PL_rsfp_filters))) = NULL\E/)
3075 || extract_from_file('toke.c',
3076 qr/\QIoDIRP(datasv) = (DIR*)NULL;\E/))) {
3077 # Commit 93578b34124e8a3b, //depot/perl@3298
3078 # close directory handles properly when localized,
3079 # tweaked slightly by commit 1236053a2c722e2b,
3080 # add test case for change#3298
3082 # The fix is the last part of:
3084 # various fixes for clean build and test on win32; configpm broken,
3085 # needed to open myconfig.SH rather than myconfig; sundry adjustments
3086 # to bytecode stuff; tweaks to DYNAMIC_ENV_FETCH code to make it
3087 # work under win32; getenv_sv() changed to getenv_len() since SVs
3088 # aren't visible in the lower echelons; remove bogus exports from
3089 # config.sym; PERL_OBJECT-ness for C++ exception support; null out
3090 # IoDIRP in filter_del() or sv_free() will attempt to close it
3092 # The changed code is modified subsequently by commit e0c198038146b7a4
3093 apply_commit('a6c403648ecd5cc7', 'toke.c');
3096 if ($major < 6 && $^O eq 'netbsd'
3097 && !extract_from_file('unixish.h',
3098 qr/defined\(NSIG\).*defined\(__NetBSD__\)/)) {
3099 apply_patch(<<'EOPATCH')
3100 diff --git a/unixish.h b/unixish.h
3101 index 2a6cbcd..eab2de1 100644
3106 /* #define ALTERNATE_SHEBANG "#!" / **/
3108 -#if !defined(NSIG) || defined(M_UNIX) || defined(M_XENIX)
3109 +#if !defined(NSIG) || defined(M_UNIX) || defined(M_XENIX) || defined(__NetBSD__)
3110 # include <signal.h>
3116 if ($major == 7 && $^O eq 'aix' &&
3117 extract_from_file('ext/List/Util/Util.xs', qr/PUSHBLOCK/)
3118 && !extract_from_file('makedef.pl', qr/^Perl_cxinc/)) {
3119 # Need this to get List::Utils 1.03 and later to compile.
3120 # 1.03 also expects to call Perl_pp_rand. Commit d3632a54487acc5f
3121 # fixes this (for the unthreaded case), but it's not until 1.05,
3122 # two days later, that this is fixed properly.
3123 apply_commit('cbb96eed3f175499');
3126 if (($major >= 7 || $major <= 9) && $^O eq 'openbsd'
3127 && `uname -m` eq "sparc64\n"
3128 # added in 2000 by commit cb434fcc98ac25f5:
3129 && extract_from_file('regexec.c',
3130 qr!/\* No need to save/restore up to this paren \*/!)
3131 # re-indented in 2006 by commit 95b2444054382532:
3132 && extract_from_file('regexec.c', qr/^\t\tCURCUR cc;$/)) {
3133 # Need to work around a bug in (at least) OpenBSD's 4.6's sparc64 #
3134 # compiler ["gcc (GCC) 3.3.5 (propolice)"]. Between commits
3135 # 3ec562b0bffb8b8b (2002) and 1a4fad37125bac3e^ (2005) the darling thing
3136 # fails to compile any code for the statement cc.oldcc = PL_regcc;
3138 # If you refactor the code to "fix" that, or force the issue using set
3139 # in the debugger, the stack smashing detection code fires on return
3140 # from S_regmatch(). Turns out that the compiler doesn't allocate any
3141 # (or at least enough) space for cc.
3143 # Restore the "uninitialised" value for cc before function exit, and the
3144 # stack smashing code is placated. "Fix" 3ec562b0bffb8b8b (which
3145 # changes the size of auto variables used elsewhere in S_regmatch), and
3146 # the crash is visible back to bc517b45fdfb539b (which also changes
3147 # buffer sizes). "Unfix" 1a4fad37125bac3e and the crash is visible until
3148 # 5b47454deb66294b. Problem goes away if you compile with -O, or hack
3149 # the code as below.
3151 # Hence this turns out to be a bug in (old) gcc. Not a security bug we
3152 # still need to fix.
3153 apply_patch(<<'EOPATCH');
3154 diff --git a/regexec.c b/regexec.c
3155 index 900b491..6251a0b 100644
3158 @@ -2958,7 +2958,11 @@ S_regmatch(pTHX_ regnode *prog)
3160 *******************************************************************/
3165 + char hack_buff[sizeof(CURCUR) + 1];
3167 +#define cc hack.hack_cc
3168 CHECKPOINT cp = PL_savestack_ix;
3169 /* No need to save/restore up to this paren */
3170 I32 parenfloor = scan->flags;
3171 @@ -2983,6 +2987,7 @@ S_regmatch(pTHX_ regnode *prog)
3172 n = regmatch(PREVOPER(next)); /* start on the WHILEM */
3174 PL_regcc = cc.oldcc;
3182 if ($major < 8 && $^O eq 'openbsd'
3183 && !extract_from_file('perl.h', qr/include <unistd\.h>/)) {
3184 # This is part of commit 3f270f98f9305540, applied at a slightly
3185 # different location in perl.h, where the context is stable back to
3187 apply_patch(<<'EOPATCH');
3188 diff --git a/perl.h b/perl.h
3189 index 9418b52..b8b1a7c 100644
3192 @@ -496,6 +496,10 @@ register struct op *Perl_op asm(stringify(OP_IN_REGISTER));
3193 # include <sys/param.h>
3196 +/* If this causes problems, set i_unistd=undef in the hint file. */
3198 +# include <unistd.h>
3201 /* Use all the "standard" definitions? */
3202 #if defined(STANDARD_C) && defined(I_STDLIB)
3208 if (-f 'ext/POSIX/Makefile.PL'
3209 && extract_from_file('ext/POSIX/Makefile.PL',
3210 qr/Explicitly avoid including/)) {
3211 # commit 6695a346c41138df, which effectively reverts 170888cff5e2ffb7
3213 # PERL5LIB is populated by make_ext.pl with paths to the modules we need
3214 # to run, don't override this with "../../lib" since that may not have
3215 # been populated yet in a parallel build.
3216 apply_commit('6695a346c41138df');
3219 if (-f 'ext/Hash/Util/Makefile.PL'
3220 && extract_from_file('ext/Hash/Util/Makefile.PL',
3221 qr/\bDIR\b.*'FieldHash'/)) {
3222 # ext/Hash/Util/Makefile.PL should not recurse to FieldHash's Makefile.PL
3223 # *nix, VMS and Win32 all know how to (and have to) call the latter directly.
3224 # As is, targets in ext/Hash/Util/FieldHash get called twice, which may result
3225 # in race conditions, and certainly messes up make clean; make distclean;
3226 apply_commit('550428fe486b1888');
3229 if ($major < 8 && $^O eq 'darwin' && !-f 'ext/DynaLoader/dl_dyld.xs') {
3230 checkout_file('ext/DynaLoader/dl_dyld.xs', 'f556e5b971932902');
3231 apply_patch(<<'EOPATCH');
3232 diff -u a/ext/DynaLoader/dl_dyld.xs~ a/ext/DynaLoader/dl_dyld.xs
3233 --- a/ext/DynaLoader/dl_dyld.xs~ 2011-10-11 21:41:27.000000000 +0100
3234 +++ b/ext/DynaLoader/dl_dyld.xs 2011-10-11 21:42:20.000000000 +0100
3248 +# define dTHXa(a) extern int Perl___notused(void)
3249 +# define dTHX extern int Perl___notused(void)
3252 +#ifndef Perl_form_nocontext
3253 +# define Perl_form_nocontext form
3256 +#ifndef Perl_warn_nocontext
3257 +# define Perl_warn_nocontext warn
3261 +# define PTR2IV(p) (IV)(p)
3265 +# define get_av perl_get_av
3268 #define DL_LOADONCEONLY
3270 #include "dlutils.c" /* SaveError() etc */
3273 DLDEBUG(1,PerlIO_printf(Perl_debug_log, "dl_load_file(%s,%x):\n", filename,flags));
3275 - Perl_warn(aTHX_ "Can't make loaded symbols global on this platform while loading %s",filename);
3276 + Perl_warn_nocontext("Can't make loaded symbols global on this platform while loading %s",filename);
3277 RETVAL = dlopen(filename, mode) ;
3278 DLDEBUG(2,PerlIO_printf(Perl_debug_log, " libref=%x\n", RETVAL));
3279 ST(0) = sv_newmortal() ;
3281 if ($major < 4 && !extract_from_file('util.c', qr/^form/m)) {
3282 apply_patch(<<'EOPATCH');
3283 diff -u a/ext/DynaLoader/dl_dyld.xs~ a/ext/DynaLoader/dl_dyld.xs
3284 --- a/ext/DynaLoader/dl_dyld.xs~ 2011-10-11 21:56:25.000000000 +0100
3285 +++ b/ext/DynaLoader/dl_dyld.xs 2011-10-11 22:00:00.000000000 +0100
3287 # define get_av perl_get_av
3291 +form(char *pat, ...)
3295 + va_start(args, pat);
3296 + vasprintf(&retval, pat, &args);
3298 + SAVEFREEPV(retval);
3302 #define DL_LOADONCEONLY
3304 #include "dlutils.c" /* SaveError() etc */
3310 if ($unfixable_db_file) {
3311 # Nothing we can do.
3312 } elsif (!extract_from_file('ext/DB_File/DB_File.xs',
3313 qr/^#ifdef AT_LEAST_DB_4_1$/)) {
3314 # This line is changed by commit 3245f0580c13b3ab
3315 my $line = extract_from_file('ext/DB_File/DB_File.xs',
3316 qr/^( status = \(?RETVAL->dbp->open\)?\(RETVAL->dbp, name, NULL, RETVAL->type, $)/);
3317 apply_patch(<<"EOPATCH");
3318 diff --git a/ext/DB_File/DB_File.xs b/ext/DB_File/DB_File.xs
3319 index 489ba96..fba8ded 100644
3320 --- a/ext/DB_File/DB_File.xs
3321 +++ b/ext/DB_File/DB_File.xs
3322 \@\@ -183,4 +187,8 \@\@
3325 +#if DB_VERSION_MAJOR > 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 1)
3326 +# define AT_LEAST_DB_4_1
3329 /* map version 2 features & constants onto their version 1 equivalent */
3331 \@\@ -1334,7 +1419,12 \@\@ SV * sv ;
3334 +#ifdef AT_LEAST_DB_4_1
3335 + status = (RETVAL->dbp->open)(RETVAL->dbp, NULL, name, NULL, RETVAL->type,
3341 /* printf("open returned %d %s\\n", status, db_strerror(status)) ; */
3347 if ($major < 10 and -f 'ext/IPC/SysV/SysV.xs') {
3348 edit_file('ext/IPC/SysV/SysV.xs', sub {
3350 my $fixed = <<'EOFIX';
3352 #include <sys/types.h>
3353 #if defined(HAS_MSG) || defined(HAS_SEM) || defined(HAS_SHM)
3355 # include <sys/ipc.h>
3358 # include <sys/msg.h>
3361 # if defined(PERL_SCO) || defined(PERL_ISC)
3362 # include <sys/sysmacros.h> /* SHMLBA */
3364 # include <sys/shm.h>
3365 # ifndef HAS_SHMAT_PROTOTYPE
3366 extern Shmat_t shmat (int, char *, int);
3368 # if defined(HAS_SYSCONF) && defined(_SC_PAGESIZE)
3369 # undef SHMLBA /* not static: determined at boot time */
3370 # define SHMLBA sysconf(_SC_PAGESIZE)
3371 # elif defined(HAS_GETPAGESIZE)
3372 # undef SHMLBA /* not static: determined at boot time */
3373 # define SHMLBA getpagesize()
3379 #include <sys/types\.h>
3381 (#ifdef newCONSTSUB|/\* Required)!$fixed$1!ms;
3389 return unless $fixups;
3390 foreach my $file (@$fixups) {
3391 my $fh = open_or_die($file);
3394 if ($line =~ /^#!perl\b/) {
3396 and die_255("$^X $file failed: \$!=$!, \$?=$?");
3397 } elsif ($line =~ /^#!(\/\S+)/) {
3399 and die_255("$file failed: \$!=$!, \$?=$?");
3401 if (my ($target, $action, $pattern)
3402 = $line =~ m#^(\S+) ([=!])~ /(.*)/#) {
3403 if (length $pattern) {
3404 next unless -f $target;
3405 if ($action eq '=') {
3406 next unless extract_from_file($target, $pattern);
3408 next if extract_from_file($target, $pattern);
3411 # Avoid the special case meaning of the empty pattern,
3412 # and instead use this to simply test for the file being
3414 if ($action eq '=') {
3415 next unless -f $target;
3421 system_or_die("patch -p1 <$file");
3427 # cperl-indent-level: 4
3428 # indent-tabs-mode: nil
3431 # ex: set ts=8 sts=4 sw=4 et: