4 use Getopt::Long qw(:config bundling no_auto_abbrev);
10 = qw(config.sh config.h miniperl lib/Config.pm Fcntl perl test_prep);
13 if (open my $fh, '<', '/proc/cpuinfo') {
15 ++$cpus if /^processor\s+:\s+\d+$/;
17 } elsif (-x '/sbin/sysctl') {
18 $cpus = 1 + $1 if `/sbin/sysctl hw.ncpu` =~ /^hw\.ncpu: (\d+)$/;
19 } elsif (-x '/usr/bin/getconf') {
20 $cpus = 1 + $1 if `/usr/bin/getconf _NPROCESSORS_ONLN` =~ /^(\d+)$/;
25 jobs => defined $cpus ? $cpus + 1 : 2,
27 clean => 1, # mostly for debugging this
30 my $linux64 = `uname -sm` eq "Linux x86_64\n" ? '64' : '';
35 # This is the search logic for a multi-arch library layout
36 # added to linux.sh in commits 40f026236b9959b7 and dcffd848632af2c7.
37 my $gcc = -x '/usr/bin/gcc' ? '/usr/bin/gcc' : 'gcc';
39 foreach (`$gcc -print-search-dirs`) {
40 next unless /^libraries: =(.*)/;
41 foreach (split ':', $1) {
50 push @paths, map {$_ . $linux64} qw(/usr/local/lib /lib /usr/lib);
58 ($linux64 ? (libpth => \@paths) : ()),
61 unless(GetOptions(\%options,
62 'target=s', 'jobs|j=i', 'expect-pass=i',
63 'expect-fail' => sub { $options{'expect-pass'} = 0; },
64 'clean!', 'one-liner|e=s', 'match=s', 'force-manifest',
65 'test-build', 'check-args', 'A=s@', 'usage|help|?',
67 my (undef, $val) = @_;
68 if ($val =~ /\A([^=]+)=(.*)/s) {
69 $defines{$1} = length $2 ? $2 : "\0";
75 $defines{$_[1]} = undef;
78 pod2usage(exitval => 255, verbose => 1);
81 my ($target, $j, $match) = @options{qw(target jobs match)};
83 pod2usage(exitval => 255, verbose => 1) if $options{usage};
84 pod2usage(exitval => 255, verbose => 1)
85 unless @ARGV || $match || $options{'test-build'} || defined $options{'one-liner'};
87 exit 0 if $options{'check-args'};
91 bisect.pl - use git bisect to pinpoint changes
95 # When did this become an error?
96 .../Porting/bisect.pl -e 'my $a := 2;'
97 # When did this stop being an error?
98 .../Porting/bisect.pl --expect-fail -e '1 // 2'
99 # When did this stop matching?
100 .../Porting/bisect.pl --match '\b(?:PL_)hash_seed_set\b'
101 # When did this start matching?
102 .../Porting/bisect.pl --expect-fail --match '\buseithreads\b'
103 # When did this test program stop working?
104 .../Porting/bisect.pl -- ./perl -Ilib ../test_prog.pl
105 # When did this first become valid syntax?
106 .../Porting/bisect.pl --target=miniperl --end=v5.10.0 \
107 --expect-fail -e 'my $a := 2;'
108 # What was the last revision to build with these options?
109 .../Porting/bisect.pl --test-build -Dd_dosuid
113 Together F<bisect.pl> and F<bisect-runner.pl> attempt to automate the use
114 of C<git bisect> as much as possible. With one command (and no other files)
115 it's easy to find out
121 Which commit caused this example code to break?
125 Which commit caused this example code to start working?
129 Which commit added the first to match this regex?
133 Which commit removed the last to match this regex?
137 usually without needing to know which versions of perl to use as start and
140 By default F<bisect.pl> will process all options, then use the rest of the
141 command line as arguments to list C<system> to run a test case. By default,
142 the test case should pass (exit with 0) on earlier perls, and fail (exit
143 non-zero) on I<blead>. F<bisect.pl> will use F<bisect-runner.pl> to find the
144 earliest stable perl version on which the test case passes, check that it
145 fails on blead, and then use F<bisect-runner.pl> with C<git bisect run> to
146 find the commit which caused the failure.
148 Because the test case is the complete argument to C<system>, it is easy to
149 run something other than the F<perl> built, if necessary. If you need to run
150 the perl built, you'll probably need to invoke it as C<./perl -Ilib ...>
152 You need a clean checkout to run a bisect, and you can't use the checkout
153 which contains F<Porting/bisect.pl> (because C<git bisect>) will check out
154 a revision before F<Porting/bisect-runner.pl> was added, which
155 C<git bisect run> needs). If your working checkout is called F<perl>, the
156 simplest solution is to make a local clone, and run from that. I<i.e.>:
161 ../perl/Porting/bisect.pl ...
163 By default, F<bisect-runner.pl> will automatically disable the build of
164 L<DB_File> for commits earlier than ccb44e3bf3be2c30, as it's not practical
165 to patch DB_File 1.70 and earlier to build with current Berkeley DB headers.
166 (ccb44e3bf3be2c30 was in September 1999, between 5.005_62 and 5.005_63.)
167 If your F<db.h> is old enough you can override this with C<-Unoextensions>.
175 --start I<commit-ish>
177 Earliest revision to test, as a I<commit-ish> (a tag, commit or anything
178 else C<git> understands as a revision). If not specified, F<bisect.pl> will
179 search stable perl releases from 5.002 to 5.14.0 until it finds one where
180 the test case passes.
186 Most recent revision to test, as a I<commit-ish>. If not specified, defaults
193 F<Makefile> target (or equivalent) needed, to run the test case. If specified,
194 this should be one of
202 Just run F<./Configure>
208 Run the various F<*.SH> files to generate F<Makefile>, F<config.h>, I<etc>.
220 Use F<miniperl> to build F<lib/Config.pm>
226 Build F<lib/auto/Fcntl/Fnctl.so> (strictly, C<.$Config{so}>). As L<Fcntl>
227 is simple XS module present since 5.000, this provides a fast test of
228 whether XS modules can be built. Note, XS modules are built by F<miniperl>,
229 hence this target will not build F<perl>.
235 Build F<perl>. This also builds pure-Perl modules in F<cpan>, F<dist> and
236 F<ext>. XS modules (such as L<Fcntl>) are not built.
242 Build everything needed to run the tests. This is the default if we're
243 running test code, but is time consuming, as it means building all
244 XS modules. For older F<Makefile>s, the previous name of C<test-prep>
245 is automatically substituted. For very old F<Makefile>s, C<make test> is
246 run, as there is no target provided to just get things ready, and for 5.004
247 and earlier the tests run very quickly.
253 --one-liner 'code to run'
259 Example code to run, just like you'd use with C<perl -e>.
261 This prepends C<./perl -Ilib -e 'code to run'> to the test case given,
262 or F<./miniperl> if I<target> is C<miniperl>.
264 (Usually you'll use C<-e> instead of providing a test case in the
265 non-option arguments to F<bisect.pl>)
267 C<-E> intentionally isn't supported, as it's an error in 5.8.0 and earlier,
268 which interferes with detecting errors in the example code itself.
274 The test case should fail for the I<start> revision, and pass for the I<end>
275 revision. The bisect run will find the first commit where it passes.
279 -Dnoextensions=Encode
287 -Accflags=-DNO_MATHOMS
289 Arguments to pass to F<Configure>. Repeated C<-A> arguments are passed
290 through as is. C<-D> and C<-U> are processed in order, and override
291 previous settings for the same parameter. F<bisect-runner.pl> emulates
292 C<-Dnoextensions> when F<Configure> itself does not provide it, as it's
293 often very useful to be able to disable some XS extensions.
303 Number of C<make> jobs to run in parallel. If F</proc/cpuinfo> exists and
304 can be parsed, or F</sbin/sysctl> exists and reports C<hw.ncpu>, or
305 F</usr/bin/getconf> exists and reports C<_NPROCESSORS_ONLN> defaults to 1 +
306 I<number of CPUs>. Otherwise defaults to 2.
312 Instead of running a test program to determine I<pass> or I<fail>, pass
313 if the given regex matches, and hence search for the commit that removes
314 the last matching file.
316 If no I<target> is specified, the match is against all files in the
317 repository (which is fast). If a I<target> is specified, that target is
318 built, and the match is against only the built files. C<--expect-fail> can
319 be used with C<--match> to search for a commit that adds files that match.
325 Test that the build completes, without running any test case.
327 By default, if the build for the desired I<target> fails to complete,
328 F<bisect-runner.pl> reports a I<skip> back to C<git bisect>, the assumption
329 being that one wants to find a commit which changed state "builds && passes"
330 to "builds && fails". If instead one is interested in which commit broke the
331 build (possibly for particular F<Configure> options), use I<--test-build>
332 to treat a build failure as a failure, not a "skip".
334 Often this option isn't as useful as it first seems, because I<any> build
335 failure will be reported to C<git bisect> as a failure, not just the failure
336 that you're interested in. Generally, to debug a particular problem, it's
337 more useful to use a I<target> that builds properly at the point of interest,
338 and then a test case that runs C<make>. For example:
340 .../Porting/bisect.pl --start=perl-5.000 --end=perl-5.002 \
341 --expect-fail --force-manifest --target=miniperl make perl
343 will find the first revision capable of building L<DynaLoader> and then
344 F<perl>, without becoming confused by revisions where F<miniperl> won't
351 By default, a build will "skip" if any files listed in F<MANIFEST> are not
352 present. Usually this is useful, as it avoids false-failures. However, there
353 are some long ranges of commits where listed files are missing, which can
354 cause a bisect to abort because all that remain are skipped revisions.
356 In these cases, particularly if the test case uses F<miniperl> and no modules,
357 it may be more useful to force the build to continue, even if files
358 F<MANIFEST> are missing.
364 C<--expect-pass=0> is equivalent to C<--expect-fail>. I<1> is the default.
370 Tell F<bisect-runner.pl> not to clean up after the build. This allows one
371 to use F<bisect-runner.pl> to build the current particular perl revision for
372 interactive testing, or for debugging F<bisect-runner.pl>.
374 Passing this to F<bisect.pl> will likely cause the bisect to fail badly.
380 Test that all stable revisions can be built. Attempts to build I<blead>,
381 I<v5.14.0> .. I<perl-5.002>. Stops at the first failure, without cleaning
382 the checkout. Ignores I<--start> and I<--end>. Useful for validating a new
383 OS/CPU/compiler combination. For example
385 ../perl/Porting/bisect.pl --validate -e'print "Hello from $]\n"'
391 Validate the options and arguments, and exit silently if they are valid.
405 Display the usage information and exit.
411 die "$0: Can't build $target" if defined $target && !grep {@targets} $target;
413 $j = "-j$j" if $j =~ /\A\d+\z/;
415 # Sadly, however hard we try, I don't think that it will be possible to build
416 # modules in ext/ on x86_64 Linux before commit e1666bf5602ae794 on 1999/12/29,
417 # which updated to MakeMaker 3.7, which changed from using a hard coded ld
418 # in the Makefile to $(LD). On x86_64 Linux the "linker" is gcc.
422 my $mode = @_ ? shift : '<';
423 open my $fh, $mode, $file or croak("Can't open $file: $!");
424 ${*$fh{SCALAR}} = $file;
431 croak("Can't close: $!") unless ref $fh eq 'GLOB';
432 croak("Can't close ${*$fh{SCALAR}}: $!");
435 sub extract_from_file {
436 my ($file, $rx, $default) = @_;
437 my $fh = open_or_die($file);
440 return wantarray ? @got : $got[0]
443 return $default if defined $default;
448 my ($file, $munger) = @_;
450 my $fh = open_or_die($file);
452 die "Can't read $file: $!" unless defined $orig && close $fh;
453 my $new = $munger->($orig);
454 return if $new eq $orig;
455 $fh = open_or_die($file, '>');
456 print $fh $new or die "Can't print to $file: $!";
463 my ($file) = $patch =~ qr!^--- a/(\S+)\n\+\+\+ b/\1!sm;
464 open my $fh, '|-', 'patch', '-p1' or die "Can't run patch: $!";
467 print STDERR "Patch is <<'EOPATCH'\n${patch}EOPATCH\n";
468 die "Can't patch $file: $?, $!";
472 my ($commit, @files) = @_;
473 return unless system "git show $commit @files | patch -p1";
474 die "Can't apply commit $commit to @files" if @files;
475 die "Can't apply commit $commit";
479 my ($commit, @files) = @_;
480 return unless system "git show -R $commit @files | patch -p1";
481 die "Can't apply revert $commit from @files" if @files;
482 die "Can't apply revert $commit";
486 my ($file, $commit) = @_;
488 system "git show $commit:$file > $file </dev/null"
489 and die "Could not extract $file at revision $commit";
493 if ($options{clean}) {
494 # Needed, because files that are build products in this checked out
495 # version might be in git in the next desired version.
496 system 'git clean -dxf </dev/null';
497 # Needed, because at some revisions the build alters checked out files.
498 # (eg pod/perlapi.pod). Also undoes any changes to makedepend.SH
499 system 'git reset --hard HEAD </dev/null';
506 warn "skipping - $reason";
510 sub report_and_exit {
511 my ($ret, $pass, $fail, $desc) = @_;
515 my $got = ($options{'expect-pass'} ? !$ret : $ret) ? 'good' : 'bad';
517 print "$got - $fail $desc\n";
519 print "$got - $pass $desc\n";
533 @files = defined $target ? `git ls-files -o -z`: `git ls-files -z`;
537 foreach my $file (@files) {
538 my $fh = open_or_die($file);
542 if (tr/\t\r\n -~\200-\377//c) {
543 print "Binary file $file matches\n";
545 $_ .= "\n" unless /\n\z/;
552 report_and_exit(!$matches,
553 $matches == 1 ? '1 match for' : "$matches matches for",
554 'no matches for', $match);
557 # Not going to assume that system perl is yet new enough to have autodie
558 system 'git clean -dxf </dev/null' and die;
560 if (!defined $target) {
561 match_and_exit() if $match;
562 $target = 'test_prep';
565 skip('no Configure - is this the //depot/perlext/Compiler branch?')
566 unless -f 'Configure';
568 # This changes to PERL_VERSION in 4d8076ea25903dcb in 1999
570 = extract_from_file('patchlevel.h',
571 qr/^#define\s+(?:PERL_VERSION|PATCHLEVEL)\s+(\d+)\s/,
577 if ($^O eq 'darwin') {
580 # We can't build on darwin without some of the data in the hints file.
581 foreach ('ext/DynaLoader/dl_dyld.xs') {
584 checkout_file($_, 'f556e5b971932902');
587 apply_patch(<<'EOPATCH');
588 diff -u a/ext/DynaLoader/dl_dyld.xs~ a/ext/DynaLoader/dl_dyld.xs
589 --- a/ext/DynaLoader/dl_dyld.xs~ 2011-10-11 21:41:27.000000000 +0100
590 +++ b/ext/DynaLoader/dl_dyld.xs 2011-10-11 21:42:20.000000000 +0100
604 +# define dTHXa(a) extern int Perl___notused(void)
605 +# define dTHX extern int Perl___notused(void)
608 +#ifndef Perl_form_nocontext
609 +# define Perl_form_nocontext form
612 +#ifndef Perl_warn_nocontext
613 +# define Perl_warn_nocontext warn
617 +# define PTR2IV(p) (IV)(p)
621 +# define get_av perl_get_av
624 #define DL_LOADONCEONLY
626 #include "dlutils.c" /* SaveError() etc */
629 DLDEBUG(1,PerlIO_printf(Perl_debug_log, "dl_load_file(%s,%x):\n", filename,flags));
631 - Perl_warn(aTHX_ "Can't make loaded symbols global on this platform while loading %s",filename);
632 + Perl_warn_nocontext("Can't make loaded symbols global on this platform while loading %s",filename);
633 RETVAL = dlopen(filename, mode) ;
634 DLDEBUG(2,PerlIO_printf(Perl_debug_log, " libref=%x\n", RETVAL));
635 ST(0) = sv_newmortal() ;
637 if ($major < 4 && !extract_from_file('util.c', qr/^form/m)) {
638 apply_patch(<<'EOPATCH');
639 diff -u a/ext/DynaLoader/dl_dyld.xs~ a/ext/DynaLoader/dl_dyld.xs
640 --- a/ext/DynaLoader/dl_dyld.xs~ 2011-10-11 21:56:25.000000000 +0100
641 +++ b/ext/DynaLoader/dl_dyld.xs 2011-10-11 22:00:00.000000000 +0100
643 # define get_av perl_get_av
647 +form(char *pat, ...)
651 + va_start(args, pat);
652 + vasprintf(&retval, pat, &args);
654 + SAVEFREEPV(retval);
658 #define DL_LOADONCEONLY
660 #include "dlutils.c" /* SaveError() etc */
668 if (!extract_from_file('ext/DB_File/DB_File.xs',
669 qr!^#else /\* Berkeley DB Version > 2 \*/$!)) {
670 # This DB_File.xs is really too old to patch up.
671 # Skip DB_File, unless we're invoked with an explicit -Unoextensions
672 if (!exists $defines{noextensions}) {
673 $defines{noextensions} = 'DB_File';
674 } elsif (defined $defines{noextensions}) {
675 $defines{noextensions} .= ' DB_File';
677 } elsif (!extract_from_file('ext/DB_File/DB_File.xs',
678 qr/^#ifdef AT_LEAST_DB_4_1$/)) {
679 # This line is changed by commit 3245f0580c13b3ab
680 my $line = extract_from_file('ext/DB_File/DB_File.xs',
681 qr/^( status = \(?RETVAL->dbp->open\)?\(RETVAL->dbp, name, NULL, RETVAL->type, $)/);
682 apply_patch(<<"EOPATCH");
683 diff --git a/ext/DB_File/DB_File.xs b/ext/DB_File/DB_File.xs
684 index 489ba96..fba8ded 100644
685 --- a/ext/DB_File/DB_File.xs
686 +++ b/ext/DB_File/DB_File.xs
687 \@\@ -183,4 +187,8 \@\@
690 +#if DB_VERSION_MAJOR > 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 1)
691 +# define AT_LEAST_DB_4_1
694 /* map version 2 features & constants onto their version 1 equivalent */
696 \@\@ -1334,7 +1419,12 \@\@ SV * sv ;
699 +#ifdef AT_LEAST_DB_4_1
700 + status = (RETVAL->dbp->open)(RETVAL->dbp, NULL, name, NULL, RETVAL->type,
706 /* printf("open returned %d %s\\n", status, db_strerror(status)) ; */
712 # if Encode is not needed for the test, you can speed up the bisect by
713 # excluding it from the runs with -Dnoextensions=Encode
714 # ccache is an easy win. Remove it if it causes problems.
715 # Commit 1cfa4ec74d4933da adds ignore_versioned_solibs to Configure, and sets it
716 # to true in hints/linux.sh
717 # On dromedary, from that point on, Configure (by default) fails to find any
718 # libraries, because it scans /usr/local/lib /lib /usr/lib, which only contain
719 # versioned libraries. Without -lm, the build fails.
720 # Telling /usr/local/lib64 /lib64 /usr/lib64 works from that commit onwards,
721 # until commit faae14e6e968e1c0 adds it to the hints.
722 # However, prior to 1cfa4ec74d4933da telling Configure the truth doesn't work,
723 # because it will spot versioned libraries, pass them to the compiler, and then
724 # bail out pretty early on. Configure won't let us override libswanted, but it
725 # will let us override the entire libs list.
727 unless (extract_from_file('Configure', 'ignore_versioned_solibs')) {
728 # Before 1cfa4ec74d4933da, so force the libs list.
731 # This is the current libswanted list from Configure, less the libs removed
732 # by current hints/linux.sh
733 foreach my $lib (qw(sfio socket inet nsl nm ndbm gdbm dbm db malloc dl dld
734 ld sun m crypt sec util c cposix posix ucb BSD)) {
735 foreach my $dir (@paths) {
736 next unless -f "$dir/lib$lib.so";
737 push @libs, "-l$lib";
741 $defines{libs} = \@libs unless exists $defines{libs};
744 $defines{usenm} = undef
745 if $major < 2 && !exists $defines{usenm};
747 my (@missing, @created_dirs);
749 if ($options{'force-manifest'}) {
750 my $fh = open_or_die('MANIFEST');
752 next unless /^(\S+)/;
753 # -d is special case needed (at least) between 27332437a2ed1941 and
754 # bf3d9ec563d25054^ inclusive, as manifest contains ext/Thread/Thread
756 unless -f $1 || -d $1;
760 foreach my $pathname (@missing) {
761 my @parts = split '/', $pathname;
762 my $leaf = pop @parts;
765 $path .= '/' . shift @parts;
767 mkdir $path, 0700 or die "Can't create $path: $!";
768 unshift @created_dirs, $path;
770 $fh = open_or_die($pathname, '>');
772 chmod 0, $pathname or die "Can't chmod 0 $pathname: $!";
777 foreach my $key (sort keys %defines) {
778 my $val = $defines{$key};
780 push @ARGS, "-D$key=@$val";
781 } elsif (!defined $val) {
782 push @ARGS, "-U$key";
783 } elsif (!length $val) {
784 push @ARGS, "-D$key";
786 $val = "" if $val eq "\0";
787 push @ARGS, "-D$key=$val";
790 push @ARGS, map {"-A$_"} @{$options{A}};
792 # </dev/null because it seems that some earlier versions of Configure can
793 # call commands in a way that now has them reading from stdin (and hanging)
795 die "Can't fork: $!" unless defined $pid;
797 open STDIN, '<', '/dev/null';
798 # If a file in MANIFEST is missing, Configure asks if you want to
799 # continue (the default being 'n'). With stdin closed or /dev/null,
800 # it exits immediately and the check for config.sh below will skip.
801 exec './Configure', @ARGS;
802 die "Failed to start Configure: $!";
805 or die "wait for Configure, pid $pid failed: $!";
809 # Emulate noextensions if Configure doesn't support it.
810 if (-f 'config.sh') {
811 if ($major < 10 && $defines{noextensions}) {
812 edit_file('config.sh', sub {
813 my @lines = split /\n/, shift;
814 my @ext = split /\s+/, $defines{noextensions};
816 next unless /^extensions=/ || /^dynamic_ext/;
817 foreach my $ext (@ext) {
821 return join "\n", @lines;
824 system './Configure -S </dev/null' and die;
827 if ($target =~ /config\.s?h/) {
828 match_and_exit($target) if $match && -f $target;
829 report_and_exit(!-f $target, 'could build', 'could not build', $target)
830 if $options{'test-build'};
832 my $ret = system @ARGV;
833 report_and_exit($ret, 'zero exit from', 'non-zero exit from', "@ARGV");
834 } elsif (!-f 'config.sh') {
835 # Skip if something went wrong with Configure
837 skip('could not build config.sh');
840 # This is probably way too paranoid:
844 foreach my $file (@missing) {
845 my (undef, undef, $mode, undef, undef, undef, undef, $size)
847 if (!defined $mode) {
848 push @errors, "Added file $file has been deleted by Configure";
851 if (Fcntl::S_IMODE($mode) != 0) {
853 sprintf 'Added file %s had mode changed by Configure to %03o',
858 "Added file $file had sized changed by Configure to $size";
860 unlink $file or die "Can't unlink $file: $!";
862 foreach my $dir (@created_dirs) {
863 rmdir $dir or die "Can't rmdir $dir: $!";
871 if ($major < 10 and -f 'ext/IPC/SysV/SysV.xs') {
872 edit_file('ext/IPC/SysV/SysV.xs', sub {
874 my $fixed = <<'EOFIX';
876 #include <sys/types.h>
877 #if defined(HAS_MSG) || defined(HAS_SEM) || defined(HAS_SHM)
879 # include <sys/ipc.h>
882 # include <sys/msg.h>
885 # if defined(PERL_SCO) || defined(PERL_ISC)
886 # include <sys/sysmacros.h> /* SHMLBA */
888 # include <sys/shm.h>
889 # ifndef HAS_SHMAT_PROTOTYPE
890 extern Shmat_t shmat (int, char *, int);
892 # if defined(HAS_SYSCONF) && defined(_SC_PAGESIZE)
893 # undef SHMLBA /* not static: determined at boot time */
894 # define SHMLBA sysconf(_SC_PAGESIZE)
895 # elif defined(HAS_GETPAGESIZE)
896 # undef SHMLBA /* not static: determined at boot time */
897 # define SHMLBA getpagesize()
903 #include <sys/types\.h>
905 (#ifdef newCONSTSUB|/\* Required)!$fixed$1!ms;
910 if (-f 'ext/POSIX/Makefile.PL'
911 && extract_from_file('ext/POSIX/Makefile.PL',
912 qr/Explicitly avoid including/)) {
913 # commit 6695a346c41138df, which effectively reverts 170888cff5e2ffb7
915 # PERL5LIB is populated by make_ext.pl with paths to the modules we need
916 # to run, don't override this with "../../lib" since that may not have
917 # been populated yet in a parallel build.
918 apply_commit('6695a346c41138df');
921 # Parallel build for miniperl is safe
922 system "make $j miniperl </dev/null";
924 my $expected = $target =~ /^test/ ? 't/perl'
925 : $target eq 'Fcntl' ? "lib/auto/Fcntl/Fcntl.$Config{so}"
927 my $real_target = $target eq 'Fcntl' ? $expected : $target;
929 if ($target ne 'miniperl') {
930 # Nearly all parallel build issues fixed by 5.10.0. Untrustworthy before that.
931 $j = '' if $major < 10;
933 if ($real_target eq 'test_prep') {
935 # test-prep was added in 5.004_01, 3e3baf6d63945cb6.
936 # renamed to test_prep in 2001 in 5fe84fd29acaf55c.
937 # earlier than that, just make test. It will be fast enough.
938 $real_target = extract_from_file('Makefile.SH',
939 qr/^(test[-_]prep):/,
944 system "make $j $real_target </dev/null";
947 my $missing_target = $expected =~ /perl$/ ? !-x $expected : !-r $expected;
949 if ($options{'test-build'}) {
950 report_and_exit($missing_target, 'could build', 'could not build',
952 } elsif ($missing_target) {
953 skip("could not build $real_target");
956 match_and_exit($real_target) if $match;
958 if (defined $options{'one-liner'}) {
959 my $exe = $target =~ /^(?:perl$|test)/ ? 'perl' : 'miniperl';
960 unshift @ARGV, "./$exe", '-Ilib', '-e', $options{'one-liner'};
963 # This is what we came here to run:
965 if (exists $Config{ldlibpthname}) {
967 my $varname = $Config{ldlibpthname};
968 my $cwd = Cwd::getcwd();
969 if (defined $ENV{$varname}) {
970 $ENV{$varname} = $cwd . $Config{path_sep} . $ENV{$varname};
972 $ENV{$varname} = $cwd;
976 my $ret = system @ARGV;
978 report_and_exit($ret, 'zero exit from', 'non-zero exit from', "@ARGV");
980 sub patch_Configure {
982 if (extract_from_file('Configure',
983 qr/^\t\t\*=\*\) echo "\$1" >> \$optdef;;$/)) {
984 # This is " Spaces now allowed in -D command line options.",
985 # part of commit ecfc54246c2a6f42
986 apply_patch(<<'EOPATCH');
987 diff --git a/Configure b/Configure
988 index 3d3b38d..78ffe16 100755
991 @@ -652,7 +777,8 @@ while test $# -gt 0; do
992 echo "$me: use '-U symbol=', not '-D symbol='." >&2
993 echo "$me: ignoring -D $1" >&2
995 - *=*) echo "$1" >> $optdef;;
997 + sed -e "s/'/'\"'\"'/g" -e "s/=\(.*\)/='\1'/" >> $optdef;;
998 *) echo "$1='define'" >> $optdef;;
1004 if (extract_from_file('Configure', qr/^if \$contains 'd_namlen' \$xinc\b/)) {
1005 # Configure's original simple "grep" for d_namlen falls foul of the
1006 # approach taken by the glibc headers:
1007 # #ifdef _DIRENT_HAVE_D_NAMLEN
1008 # # define _D_EXACT_NAMLEN(d) ((d)->d_namlen)
1010 # where _DIRENT_HAVE_D_NAMLEN is not defined on Linux.
1011 # This is also part of commit ecfc54246c2a6f42
1012 apply_patch(<<'EOPATCH');
1013 diff --git a/Configure b/Configure
1014 index 3d3b38d..78ffe16 100755
1017 @@ -3935,7 +4045,8 @@ $rm -f try.c
1019 : see if the directory entry stores field length
1021 -if $contains 'd_namlen' $xinc >/dev/null 2>&1; then
1022 +$cppstdin $cppflags $cppminus < "$xinc" > try.c
1023 +if $contains 'd_namlen' try.c >/dev/null 2>&1; then
1024 echo "Good, your directory entry keeps length information in d_namlen." >&4
1032 && !extract_from_file('Configure',
1033 qr/Try to guess additional flags to pick up local libraries/)) {
1034 my $mips = extract_from_file('Configure',
1035 qr!(''\) if (?:\./)?mips; then)!);
1036 # This is part of perl-5.001n. It's needed, to add -L/usr/local/lib to
1037 # theld flags if libraries are found there. It shifts the code to set up
1038 # libpth earlier, and then adds the code to add libpth entries to
1040 # mips was changed to ./mips in ecfc54246c2a6f42, perl5.000 patch.0g
1041 apply_patch(sprintf <<'EOPATCH', $mips);
1042 diff --git a/Configure b/Configure
1043 index 53649d5..0635a6e 100755
1046 @@ -2749,6 +2749,52 @@ EOM
1050 +: Set private lib path
1052 +'') if ./mips; then
1053 + plibpth="$incpath/usr/lib /usr/local/lib /usr/ccs/lib"
1058 +'') dlist="$plibpth $glibpth";;
1059 +*) dlist="$libpth";;
1062 +: Now check and see which directories actually exist, avoiding duplicates
1066 + if $test -d $xxx; then
1067 + case " $libpth " in
1069 + *) libpth="$libpth $xxx";;
1075 +Some systems have incompatible or broken versions of libraries. Among
1076 +the directories listed in the question below, please remove any you
1077 +know not to be holding relevant libraries, and add any that are needed.
1078 +Say "none" for none.
1089 +rp="Directories to use for library searches?"
1096 : flags used in final linking phase
1098 '') if ./venix; then
1099 @@ -2765,6 +2811,23 @@ case "$ldflags" in
1101 *) dflt="$ldflags";;
1104 +: Possible local library directories to search.
1105 +loclibpth="/usr/local/lib /opt/local/lib /usr/gnu/lib"
1106 +loclibpth="$loclibpth /opt/gnu/lib /usr/GNU/lib /opt/GNU/lib"
1108 +: Try to guess additional flags to pick up local libraries.
1109 +for thislibdir in $libpth; do
1110 + case " $loclibpth " in
1111 + *" $thislibdir "*)
1113 + "-L$thislibdir ") ;;
1114 + *) dflt="$dflt -L$thislibdir" ;;
1121 rp="Any additional ld flags (NOT including libraries)?"
1123 @@ -2828,52 +2891,6 @@ n) echo "OK, that should do.";;
1125 $rm -f try try.* core
1127 -: Set private lib path
1130 - plibpth="$incpath/usr/lib /usr/local/lib /usr/ccs/lib"
1135 -'') dlist="$plibpth $glibpth";;
1136 -*) dlist="$libpth";;
1139 -: Now check and see which directories actually exist, avoiding duplicates
1143 - if $test -d $xxx; then
1144 - case " $libpth " in
1146 - *) libpth="$libpth $xxx";;
1152 -Some systems have incompatible or broken versions of libraries. Among
1153 -the directories listed in the question below, please remove any you
1154 -know not to be holding relevant libraries, and add any that are needed.
1155 -Say "none" for none.
1166 -rp="Directories to use for library searches?"
1173 : compute shared library extension
1179 if ($major < 5 && extract_from_file('Configure',
1180 qr!if \$cc \$ccflags try\.c -o try >/dev/null 2>&1; then!)) {
1181 # Analogous to the more general fix of dfe9444ca7881e71
1182 # Without this flags such as -m64 may not be passed to this compile,
1183 # which results in a byteorder of '1234' instead of '12345678', which
1184 # can then cause crashes.
1186 if (extract_from_file('Configure', qr/xxx_prompt=y/)) {
1187 # 8e07c86ebc651fe9 or later
1188 # ("This is my patch patch.1n for perl5.001.")
1189 apply_patch(<<'EOPATCH');
1190 diff --git a/Configure b/Configure
1191 index 62249dd..c5c384e 100755
1194 @@ -8247,7 +8247,7 @@ main()
1198 - if $cc $ccflags try.c -o try >/dev/null 2>&1 && ./try > /dev/null; then
1199 + if $cc $ccflags $ldflags try.c -o try >/dev/null 2>&1 && ./try > /dev/null; then
1202 [1-4][1-4][1-4][1-4]|12345678|87654321)
1205 apply_patch(<<'EOPATCH');
1206 diff --git a/Configure b/Configure
1207 index 53649d5..f1cd64a 100755
1210 @@ -6362,7 +6362,7 @@ main()
1214 - if $cc $ccflags try.c -o try >/dev/null 2>&1 ; then
1215 + if $cc $ccflags $ldflags try.c -o try >/dev/null 2>&1 ; then
1218 ????|????????) echo "(The test program ran ok.)";;
1223 if ($major < 6 && !extract_from_file('Configure',
1225 # This adds the -A option to Configure, which is incredibly useful
1226 # Effectively this is commits 02e93a22d20fc9a5, 5f83a3e9d818c3ad,
1227 # bde6b06b2c493fef, f7c3111703e46e0c and 2 lines of trailing whitespace
1228 # removed by 613d6c3e99b9decc, but applied at slightly different
1229 # locations to ensure a clean patch back to 5.000
1230 # Note, if considering patching to the intermediate revisions to fix
1231 # bugs in -A handling, f7c3111703e46e0c is from 2002, and hence
1234 # To add to the fun, early patches add -K and -O options, and it's not
1235 # trivial to get patch to put the C<. ./posthint.sh> in the right place
1236 edit_file('Configure', sub {
1238 $code =~ s/(optstr = ")([^"]+";\s*# getopt-style specification)/$1A:$2/
1239 or die "Substitution failed";
1240 $code =~ s!^(: who configured the system)!
1245 or die "Substitution failed";
1248 apply_patch(<<'EOPATCH');
1249 diff --git a/Configure b/Configure
1250 index 4b55fa6..60c3c64 100755
1253 @@ -1150,6 +1150,7 @@ set X `for arg in "$@"; do echo "X$arg"; done |
1259 : set up default values
1261 @@ -1172,6 +1173,56 @@ while test $# -gt 0; do
1263 -d) shift; fastread=yes;;
1264 -e) shift; alldone=cont;;
1272 + *=*) zzz=`echo "$yyy"|sed 's!=.*!!'`
1276 + zzz=" "`echo "$yyy"|sed 's!^[^=]*=!!'`
1277 + yyy=`echo "$yyy"|sed 's!=.*!!'` ;;
1282 + '') case "$yyy" in
1283 + *:*) xxx=`echo "$yyy"|sed 's!:.*!!'`
1284 + yyy=`echo "$yyy"|sed 's!^[^:]*:!!'`
1285 + zzz=`echo "$yyy"|sed 's!^[^=]*=!!'`
1286 + yyy=`echo "$yyy"|sed 's!=.*!!'` ;;
1287 + *) xxx=`echo "$yyy"|sed 's!:.*!!'`
1288 + yyy=`echo "$yyy"|sed 's!^[^:]*:!!'` ;;
1294 + echo "$yyy=\"\${$yyy}$zzz\"" >> posthint.sh ;;
1296 + echo "$yyy=''" >> posthint.sh ;;
1301 + echo "$yyy='$zzz'" >> posthint.sh ;;
1303 + echo "eval \"$yyy=$zzz\"" >> posthint.sh ;;
1305 + echo "$yyy=\"$zzz\${$yyy}\"" >> posthint.sh ;;
1310 + echo "$yyy=$zzz" >> posthint.sh ;;
1311 + *) echo "$me: unknown -A command '$xxx', ignoring -A $1" >&2 ;;
1321 if ($major < 8 && !extract_from_file('Configure',
1322 qr/^\t\tif test ! -t 0; then$/)) {
1323 # Before dfe9444ca7881e71, Configure would refuse to run if stdin was
1324 # not a tty. With that commit, the tty requirement was dropped for -de
1326 # Commit aaeb8e512e8e9e14 dropped the tty requirement for -S
1327 # For those older versions, it's probably easiest if we simply remove
1329 edit_file('Configure', sub {
1331 $code =~ s/test ! -t 0/test Perl = rules/;
1336 if ($major == 8 || $major == 9) {
1337 # Fix symbol detection to that of commit 373dfab3839ca168 if it's any
1338 # intermediate version 5129fff43c4fe08c or later, as the intermediate
1339 # versions don't work correctly on (at least) Sparc Linux.
1340 # 5129fff43c4fe08c adds the first mention of mistrustnm.
1341 # 373dfab3839ca168 removes the last mention of lc=""
1342 edit_file('Configure', sub {
1345 if $code !~ /\btc="";/; # 373dfab3839ca168 or later
1347 if $code !~ /\bmistrustnm\b/; # before 5129fff43c4fe08c
1348 my $fixed = <<'EOC';
1350 : is a C symbol defined?
1353 -v) tf=libc.tmp; tdc="";;
1354 -a) tf=libc.tmp; tdc="[]";;
1355 *) tlook="^$1\$"; tf=libc.list; tdc="()";;
1358 case "$reuseval-$4" in
1360 true-*) tx=no; eval "tval=\$$4"; case "$tval" in "") tx=yes;; esac;;
1365 if $test "$runnm" = true; then
1366 if $contains $tlook $tf >/dev/null 2>&1; then
1368 elif $test "$mistrustnm" = compile -o "$mistrustnm" = run; then
1369 echo "void *(*(p()))$tdc { extern void *$1$tdc; return &$1; } int main() { if(p()) return(0); else return(1); }"> try.c;
1370 $cc -o try $optimize $ccflags $ldflags try.c >/dev/null 2>&1 $libs && tval=true;
1371 $test "$mistrustnm" = run -a -x try && { $run ./try$_exe >/dev/null 2>&1 || tval=false; };
1372 $rm -f try$_exe try.c core core.* try.core;
1375 echo "void *(*(p()))$tdc { extern void *$1$tdc; return &$1; } int main() { if(p()) return(0); else return(1); }"> try.c;
1376 $cc -o try $optimize $ccflags $ldflags try.c $libs >/dev/null 2>&1 && tval=true;
1377 $rm -f try$_exe try.c;
1382 $define) tval=true;;
1390 $code =~ s/\n: is a C symbol defined\?\n.*?\neval "\$2=\$tval"'\n\n/$fixed/sm
1391 or die "substitution failed";
1397 && extract_from_file('Configure', qr/^set malloc\.h i_malloc$/)) {
1398 # This is commit 01d07975f7ef0e7d, trimmed, with $compile inlined as
1399 # prior to bd9b35c97ad661cc Configure had the malloc.h test before the
1400 # definition of $compile.
1401 apply_patch(<<'EOPATCH');
1402 diff --git a/Configure b/Configure
1403 index 3d2e8b9..6ce7766 100755
1406 @@ -6743,5 +6743,22 @@ set d_dosuid
1408 : see if this is a malloc.h system
1409 -set malloc.h i_malloc
1411 +: we want a real compile instead of Inhdr because some systems have a
1412 +: malloc.h that just gives a compile error saying to use stdlib.h instead
1415 +#include <stdlib.h>
1416 +#include <malloc.h>
1417 +int main () { return 0; }
1420 +if $cc $optimize $ccflags $ldflags -o try $* try.c $libs > /dev/null 2>&1; then
1421 + echo "<malloc.h> found." >&4
1424 + echo "<malloc.h> NOT found." >&4
1436 if ($^O eq 'freebsd') {
1437 # There are rather too many version-specific FreeBSD hints fixes to
1438 # patch individually. Also, more than once the FreeBSD hints file has
1439 # been written in what turned out to be a rather non-future-proof style,
1440 # with case statements treating the most recent version as the
1441 # exception, instead of treating previous versions' behaviour explicitly
1442 # and changing the default to cater for the current behaviour. (As
1443 # strangely, future versions inherit the current behaviour.)
1444 checkout_file('hints/freebsd.sh');
1445 } elsif ($^O eq 'darwin') {
1447 # We can't build on darwin without some of the data in the hints
1448 # file. Probably less surprising to use the earliest version of
1449 # hints/darwin.sh and then edit in place just below, than use
1450 # blead's version, as that would create a discontinuity at
1451 # f556e5b971932902 - before it, hints bugs would be "fixed", after
1452 # it they'd resurface. This way, we should give the illusion of
1453 # monotonic bug fixing.
1455 if (!-f 'hints/darwin.sh') {
1456 checkout_file('hints/darwin.sh', 'f556e5b971932902');
1460 edit_file('hints/darwin.sh', sub {
1462 # Part of commit 8f4f83badb7d1ba9, which mostly undoes
1463 # commit 0511a818910f476c.
1464 $code =~ s/^cppflags='-traditional-cpp';$/cppflags="\${cppflags} -no-cpp-precomp"/m;
1465 # commit 14c11978e9b52e08/803bb6cc74d36a3f
1466 # Without this, code in libperl.bundle links against op.o
1467 # in preference to opmini.o on the linker command line,
1468 # and hence miniperl tries to use File::Glob instead of
1470 $code =~ s/^(lddlflags=)/ldflags="\${ldflags} -flat_namespace"\n$1/m;
1471 # f556e5b971932902 also patches Makefile.SH with some
1472 # special case code to deal with useshrplib for darwin.
1473 # Given that post 5.8.0 the darwin hints default was
1474 # changed to false, and it would be very complex to splice
1475 # in that code in various versions of Makefile.SH back
1476 # to 5.002, lets just turn it off.
1477 $code =~ s/^useshrplib='true'/useshrplib='false'/m
1482 } elsif ($^O eq 'netbsd') {
1484 # These are part of commit 099685bc64c7dbce
1485 edit_file('hints/netbsd.sh', sub {
1487 my $fixed = <<'EOC';
1493 if [ -f /usr/libexec/ld.elf_so ]; then
1496 ccdlflags="-Wl,-E -Wl,-R${PREFIX}/lib $ccdlflags"
1497 cccdlflags="-DPIC -fPIC $cccdlflags"
1498 lddlflags="--whole-archive -shared $lddlflags"
1499 elif [ "`uname -m`" = "pmax" ]; then
1500 # NetBSD 1.3 and 1.3.1 on pmax shipped an `old' ld.so, which will not work.
1502 elif [ -f /usr/libexec/ld.so ]; then
1505 ccdlflags="-Wl,-R${PREFIX}/lib $ccdlflags"
1506 # we use -fPIC here because -fpic is *NOT* enough for some of the
1507 # extensions like Tk on some netbsd platforms (the sparc is one)
1508 cccdlflags="-DPIC -fPIC $cccdlflags"
1509 lddlflags="-Bforcearchive -Bshareable $lddlflags"
1516 $code =~ s/^case "\$osvers" in\n0\.9\|0\.8.*?^esac\n/$fixed/ms;
1520 } elsif ($^O eq 'openbsd') {
1522 checkout_file('hints/openbsd.sh', '43051805d53a3e4c')
1523 unless -f 'hints/openbsd.sh';
1524 my $which = extract_from_file('hints/openbsd.sh',
1525 qr/# from (2\.8|3\.1) onwards/,
1528 my $was = extract_from_file('hints/openbsd.sh',
1529 qr/(lddlflags="(?:-Bforcearchive )?-Bshareable)/);
1530 # This is commit 154d43cbcf57271c and parts of 5c75dbfa77b0949c
1531 # and 29b5585702e5e025
1532 apply_patch(sprintf <<'EOPATCH', $was);
1533 diff --git a/hints/openbsd.sh b/hints/openbsd.sh
1534 index a7d8bf2..5b79709 100644
1535 --- a/hints/openbsd.sh
1536 +++ b/hints/openbsd.sh
1537 @@ -37,7 +37,25 @@ OpenBSD.alpha|OpenBSD.mips|OpenBSD.powerpc|OpenBSD.vax)
1538 # we use -fPIC here because -fpic is *NOT* enough for some of the
1539 # extensions like Tk on some OpenBSD platforms (ie: sparc)
1540 cccdlflags="-DPIC -fPIC $cccdlflags"
1543 + [01].*|2.[0-7]|2.[0-7].*)
1544 + lddlflags="-Bshareable $lddlflags"
1548 + lddlflags="-shared -fPIC $lddlflags"
1550 + *) # from 3.1 onwards
1552 + lddlflags="-shared -fPIC $lddlflags"
1553 + libswanted=`echo $libswanted | sed 's/ dl / /'`
1557 + # We need to force ld to export symbols on ELF platforms.
1558 + # Without this, dlopen() is crippled.
1559 + ELF=`${cc:-cc} -dM -E - </dev/null | grep __ELF__`
1560 + test -n "$ELF" && ldflags="-Wl,-E $ldflags"
1565 } elsif ($which eq '2.8') {
1566 # This is parts of 5c75dbfa77b0949c and 29b5585702e5e025, and
1567 # possibly eb9cd59d45ad2908
1568 my $was = extract_from_file('hints/openbsd.sh',
1569 qr/lddlflags="(-shared(?: -fPIC)?) \$lddlflags"/);
1571 apply_patch(sprintf <<'EOPATCH', $was);
1572 --- a/hints/openbsd.sh 2011-10-21 17:25:20.000000000 +0200
1573 +++ b/hints/openbsd.sh 2011-10-21 16:58:43.000000000 +0200
1575 [01].*|2.[0-7]|2.[0-7].*)
1576 lddlflags="-Bshareable $lddlflags"
1578 - *) # from 2.8 onwards
1581 - lddlflags="%s $lddlflags"
1582 + lddlflags="-shared -fPIC $lddlflags"
1584 + *) # from 3.1 onwards
1586 + lddlflags="-shared -fPIC $lddlflags"
1587 + libswanted=`echo $libswanted | sed 's/ dl / /'`
1591 + # We need to force ld to export symbols on ELF platforms.
1592 + # Without this, dlopen() is crippled.
1593 + ELF=`${cc:-cc} -dM -E - </dev/null | grep __ELF__`
1594 + test -n "$ELF" && ldflags="-Wl,-E $ldflags"
1599 } elsif ($which eq '3.1'
1600 && !extract_from_file('hints/openbsd.sh',
1601 qr/We need to force ld to export symbols on ELF platforms/)) {
1602 # This is part of 29b5585702e5e025
1603 apply_patch(<<'EOPATCH');
1604 diff --git a/hints/openbsd.sh b/hints/openbsd.sh
1605 index c6b6bc9..4839d04 100644
1606 --- a/hints/openbsd.sh
1607 +++ b/hints/openbsd.sh
1608 @@ -54,6 +54,11 @@ alpha-2.[0-8]|mips-*|vax-*|powerpc-2.[0-7]|m88k-*)
1609 libswanted=`echo $libswanted | sed 's/ dl / /'`
1613 + # We need to force ld to export symbols on ELF platforms.
1614 + # Without this, dlopen() is crippled.
1615 + ELF=`${cc:-cc} -dM -E - </dev/null | grep __ELF__`
1616 + test -n "$ELF" && ldflags="-Wl,-E $ldflags"
1623 } elsif ($^O eq 'linux') {
1625 # sparc linux seems to need the -Dbool=char -DHAS_BOOL part of
1626 # perl5.000 patch.0n: [address Configure and build issues]
1627 edit_file('hints/linux.sh', sub {
1629 $code =~ s!-I/usr/include/bsd!-Dbool=char -DHAS_BOOL!g;
1635 if (`uname -sm` =~ qr/^Linux sparc/) {
1636 if (extract_from_file('hints/linux.sh', qr/sparc-linux/)) {
1637 # Be sure to use -fPIC not -fpic on Linux/SPARC
1638 apply_commit('f6527d0ef0c13ad4');
1639 } elsif(!extract_from_file('hints/linux.sh',
1640 qr/^sparc-linux\)$/)) {
1641 my $fh = open_or_die('hints/linux.sh', '>>');
1642 print $fh <<'EOT' or die $!;
1644 case "`uname -m`" in
1646 case "$cccdlflags" in
1647 *-fpic*) cccdlflags="`echo $cccdlflags|sed 's/-fpic/-fPIC/'`" ;;
1648 *) cccdlflags="$cccdlflags -fPIC" ;;
1661 # Cwd.xs added in commit 0d2079faa739aaa9. Cwd.pm moved to ext/ 8 years
1662 # later in commit 403f501d5b37ebf0
1663 if ($major > 0 && <*/Cwd/Cwd.xs>) {
1665 && !extract_from_file('Makefile.SH', qr/^extra_dep=''$/)) {
1666 # The Makefile.PL for Unicode::Normalize needs
1667 # lib/unicore/CombiningClass.pl. Even without a parallel build, we
1668 # need a dependency to ensure that it builds. This is a variant of
1669 # commit 9f3ef600c170f61e. Putting this for earlier versions gives
1670 # us a spot on which to hang the edits below
1671 apply_patch(<<'EOPATCH');
1672 diff --git a/Makefile.SH b/Makefile.SH
1673 index f61d0db..6097954 100644
1676 @@ -155,10 +155,20 @@ esac
1678 : Prepare dependency lists for Makefile.
1681 for f in $dynamic_ext; do
1682 : the dependency named here will never exist
1683 base=`echo "$f" | sed 's/.*\///'`
1684 - dynamic_list="$dynamic_list lib/auto/$f/$base.$dlext"
1685 + this_target="lib/auto/$f/$base.$dlext"
1686 + dynamic_list="$dynamic_list $this_target"
1688 + : Parallel makes reveal that we have some interdependencies
1690 + Math/BigInt/FastCalc) extra_dep="$extra_dep
1691 +$this_target: lib/auto/List/Util/Util.$dlext" ;;
1692 + Unicode/Normalize) extra_dep="$extra_dep
1693 +$this_target: lib/unicore/CombiningClass.pl" ;;
1698 @@ -987,2 +997,9 @@ n_dummy $(nonxs_ext): miniperl$(EXE_EXT) preplibrary $(DYNALOADER) FORCE
1699 @$(LDLIBPTH) sh ext/util/make_ext nonxs $@ MAKE=$(MAKE) LIBPERL_A=$(LIBPERL)
1702 +$spitshell >>Makefile <<EOF
1706 +$spitshell >>Makefile <<'!NO!SUBS!'
1711 # Commits dc0655f797469c47 and d11a62fe01f2ecb2
1712 edit_file('Makefile.SH', sub {
1714 foreach my $ext (qw(Encode SDBM_File)) {
1715 next if $code =~ /\b$ext\) extra_dep=/s;
1716 $code =~ s!(\) extra_dep="\$extra_dep
1717 \$this_target: .*?" ;;)
1720 $ext) extra_dep="\$extra_dep
1721 \$this_target: lib/auto/Cwd/Cwd.\$dlext" ;;
1730 # Remove commits 9fec149bb652b6e9 and 5bab1179608f81d8, which add/amend
1731 # rules to automatically run regen scripts that rebuild C headers. These
1732 # cause problems because a git checkout doesn't preserve relative file
1733 # modification times, hence the regen scripts may fire. This will
1734 # obscure whether the repository had the correct generated headers
1736 # Also, the dependency rules for running the scripts were not correct,
1737 # which could cause spurious re-builds on re-running make, and can cause
1738 # complete build failures for a parallel make.
1739 if (extract_from_file('Makefile.SH',
1740 qr/Writing it this way gives make a big hint to always run opcode\.pl before/)) {
1741 apply_commit('70c6e6715e8fec53');
1742 } elsif (extract_from_file('Makefile.SH',
1743 qr/^opcode\.h opnames\.h pp_proto\.h pp\.sym: opcode\.pl$/)) {
1744 revert_commit('9fec149bb652b6e9');
1748 # There was a bug in makedepend.SH which was fixed in version 96a8704c.
1749 # Symptom was './makedepend: 1: Syntax error: Unterminated quoted string'
1750 # Remove this if you're actually bisecting a problem related to
1752 # If you do this, you may need to add in code to correct the output of older
1753 # makedepends, which don't correctly filter newer gcc output such as
1755 checkout_file('makedepend.SH');
1757 if ($major < 4 && -f 'config.sh'
1758 && !extract_from_file('config.sh', qr/^trnl=/)) {
1759 # This seems to be necessary to avoid makedepend becoming confused,
1760 # and hanging on stdin. Seems that the code after
1761 # make shlist || ...here... is never run.
1762 edit_file('makedepend.SH', sub {
1764 $code =~ s/^trnl='\$trnl'$/trnl='\\n'/m;
1771 # This is ordered by $major, as it's likely that different platforms may
1772 # well want to share code.
1774 if ($major == 2 && extract_from_file('perl.c', qr/^\tfclose\(e_fp\);$/)) {
1775 # need to patch perl.c to avoid calling fclose() twice on e_fp when
1777 # This diff is part of commit ab821d7fdc14a438. The second close was
1778 # introduced with perl-5.002, commit a5f75d667838e8e7
1779 # Might want a6c477ed8d4864e6 too, for the corresponding change to
1780 # pp_ctl.c (likely without this, eval will have "fun")
1781 apply_patch(<<'EOPATCH');
1782 diff --git a/perl.c b/perl.c
1783 index 03c4d48..3c814a2 100644
1786 @@ -252,6 +252,7 @@ setuid perl scripts securely.\n");
1787 #ifndef VMS /* VMS doesn't have environ array */
1788 origenviron = environ;
1790 + e_tmpname = Nullch;
1794 @@ -405,6 +406,7 @@ setuid perl scripts securely.\n");
1796 if (Fflush(e_fp) || ferror(e_fp) || fclose(e_fp))
1797 croak("Can't write to temp file for -e: %s", Strerror(errno));
1800 scriptname = e_tmpname;
1802 @@ -470,10 +472,10 @@ setuid perl scripts securely.\n");
1803 curcop->cop_line = 0;
1804 curstash = defstash;
1810 (void)UNLINK(e_tmpname);
1811 + Safefree(e_tmpname);
1812 + e_tmpname = Nullch;
1815 /* now that script is parsed, we can modify record separator */
1816 @@ -1369,7 +1371,7 @@ SV *sv;
1817 scriptname = xfound;
1820 - origfilename = savepv(e_fp ? "-e" : scriptname);
1821 + origfilename = savepv(e_tmpname ? "-e" : scriptname);
1822 curcop->cop_filegv = gv_fetchfile(origfilename);
1823 if (strEQ(origfilename,"-"))
1829 if ($major < 3 && $^O eq 'openbsd'
1830 && !extract_from_file('pp_sys.c', qr/BSD_GETPGRP/)) {
1831 # Part of commit c3293030fd1b7489
1832 apply_patch(<<'EOPATCH');
1833 diff --git a/pp_sys.c b/pp_sys.c
1834 index 4608a2a..f0c9d1d 100644
1837 @@ -2903,8 +2903,8 @@ PP(pp_getpgrp)
1842 - value = (I32)getpgrp(pid);
1844 + value = (I32)BSD_GETPGRP(pid);
1847 DIE("POSIX getpgrp can't take an argument");
1848 @@ -2933,8 +2933,8 @@ PP(pp_setpgrp)
1851 TAINT_PROPER("setpgrp");
1853 - SETi( setpgrp(pid, pgrp) >= 0 );
1855 + SETi( BSD_SETPGRP(pid, pgrp) >= 0 );
1857 if ((pgrp != 0) || (pid != 0)) {
1858 DIE("POSIX setpgrp can't take an argument");
1862 if ($major < 4 && $^O eq 'openbsd') {
1864 # Need changes from commit a6e633defa583ad5.
1865 # Commits c07a80fdfe3926b5 and f82b3d4130164d5f changed the same part
1868 if (extract_from_file('perl.h',
1869 qr/^#ifdef HAS_GETPGRP2$/)) {
1873 #define TAINT_PROPER(s) if (tainting) taint_proper(no_security, s)
1874 #define TAINT_ENV() if (tainting) taint_env()
1876 ! #ifdef HAS_GETPGRP2
1877 ! # ifndef HAS_GETPGRP
1878 ! # define HAS_GETPGRP
1882 ! #ifdef HAS_SETPGRP2
1883 ! # ifndef HAS_SETPGRP
1884 ! # define HAS_SETPGRP
1889 } elsif (extract_from_file('perl.h',
1890 qr/Gack, you have one but not both of getpgrp2/)) {
1894 #define TAINT_PROPER(s) if (tainting) taint_proper(no_security, s)
1895 #define TAINT_ENV() if (tainting) taint_env()
1897 ! #if defined(HAS_GETPGRP2) && defined(HAS_SETPGRP2)
1898 ! # define getpgrp getpgrp2
1899 ! # define setpgrp setpgrp2
1900 ! # ifndef HAS_GETPGRP
1901 ! # define HAS_GETPGRP
1903 ! # ifndef HAS_SETPGRP
1904 ! # define HAS_SETPGRP
1906 ! # ifndef USE_BSDPGRP
1907 ! # define USE_BSDPGRP
1910 ! # if defined(HAS_GETPGRP2) || defined(HAS_SETPGRP2)
1911 ! #include "Gack, you have one but not both of getpgrp2() and setpgrp2()."
1916 } elsif (extract_from_file('perl.h',
1917 qr/^#ifdef USE_BSDPGRP$/)) {
1921 #define TAINT_PROPER(s) if (tainting) taint_proper(no_security, s)
1922 #define TAINT_ENV() if (tainting) taint_env()
1924 ! #ifdef USE_BSDPGRP
1925 ! # ifdef HAS_GETPGRP
1926 ! # define BSD_GETPGRP(pid) getpgrp((pid))
1928 ! # ifdef HAS_SETPGRP
1929 ! # define BSD_SETPGRP(pid, pgrp) setpgrp((pid), (pgrp))
1932 ! # ifdef HAS_GETPGRP2
1933 ! # define BSD_GETPGRP(pid) getpgrp2((pid))
1934 ! # ifndef HAS_GETPGRP
1935 ! # define HAS_GETPGRP
1938 ! # ifdef HAS_SETPGRP2
1939 ! # define BSD_SETPGRP(pid, pgrp) setpgrp2((pid), (pgrp))
1940 ! # ifndef HAS_SETPGRP
1941 ! # define HAS_SETPGRP
1946 #ifndef _TYPES_ /* If types.h defines this it's easy. */
1950 apply_patch(<<"EOPATCH");
1951 *** a/perl.h 2011-10-21 09:46:12.000000000 +0200
1952 --- b/perl.h 2011-10-21 09:46:12.000000000 +0200
1954 #define TAINT_PROPER(s) if (tainting) taint_proper(no_security, s)
1955 #define TAINT_ENV() if (tainting) taint_env()
1957 ! /* XXX All process group stuff is handled in pp_sys.c. Should these
1958 ! defines move there? If so, I could simplify this a lot. --AD 9/96.
1960 ! /* Process group stuff changed from traditional BSD to POSIX.
1961 ! perlfunc.pod documents the traditional BSD-style syntax, so we'll
1962 ! try to preserve that, if possible.
1964 ! #ifdef HAS_SETPGID
1965 ! # define BSD_SETPGRP(pid, pgrp) setpgid((pid), (pgrp))
1967 ! # if defined(HAS_SETPGRP) && defined(USE_BSD_SETPGRP)
1968 ! # define BSD_SETPGRP(pid, pgrp) setpgrp((pid), (pgrp))
1970 ! # ifdef HAS_SETPGRP2 /* DG/UX */
1971 ! # define BSD_SETPGRP(pid, pgrp) setpgrp2((pid), (pgrp))
1975 ! #if defined(BSD_SETPGRP) && !defined(HAS_SETPGRP)
1976 ! # define HAS_SETPGRP /* Well, effectively it does . . . */
1979 ! /* getpgid isn't POSIX, but at least Solaris and Linux have it, and it makes
1980 ! our life easier :-) so we'll try it.
1982 ! #ifdef HAS_GETPGID
1983 ! # define BSD_GETPGRP(pid) getpgid((pid))
1985 ! # if defined(HAS_GETPGRP) && defined(USE_BSD_GETPGRP)
1986 ! # define BSD_GETPGRP(pid) getpgrp((pid))
1988 ! # ifdef HAS_GETPGRP2 /* DG/UX */
1989 ! # define BSD_GETPGRP(pid) getpgrp2((pid))
1993 ! #if defined(BSD_GETPGRP) && !defined(HAS_GETPGRP)
1994 ! # define HAS_GETPGRP /* Well, effectively it does . . . */
1997 ! /* These are not exact synonyms, since setpgrp() and getpgrp() may
1998 ! have different behaviors, but perl.h used to define USE_BSDPGRP
1999 ! (prior to 5.003_05) so some extension might depend on it.
2001 ! #if defined(USE_BSD_SETPGRP) || defined(USE_BSD_GETPGRP)
2002 ! # ifndef USE_BSDPGRP
2003 ! # define USE_BSDPGRP
2007 #ifndef _TYPES_ /* If types.h defines this it's easy. */
2012 if ($major == 4 && extract_from_file('scope.c', qr/\(SV\*\)SSPOPINT/)) {
2013 # [PATCH] 5.004_04 +MAINT_TRIAL_1 broken when sizeof(int) != sizeof(void)
2014 # Fixes a bug introduced in 161b7d1635bc830b
2015 apply_commit('9002cb76ec83ef7f');
2018 if ($major == 4 && extract_from_file('av.c', qr/AvARRAY\(av\) = 0;/)) {
2019 # Fixes a bug introduced in 1393e20655efb4bc
2020 apply_commit('e1c148c28bf3335b', 'av.c');
2023 if ($major == 4 && !extract_from_file('perl.c', qr/delimcpy.*,$/)) {
2024 # bug introduced in 2a92aaa05aa1acbf, fixed in 8490252049bf42d3
2025 apply_patch(<<'EOPATCH');
2026 diff --git a/perl.c b/perl.c
2027 index 4eb69e3..54bbb00 100644
2030 @@ -1735,7 +1735,7 @@ SV *sv;
2031 if (len < sizeof tokenbuf)
2032 tokenbuf[len] = '\0';
2033 #else /* ! (atarist || DOSISH) */
2034 - s = delimcpy(tokenbuf, tokenbuf + sizeof tokenbuf, s, bufend
2035 + s = delimcpy(tokenbuf, tokenbuf + sizeof tokenbuf, s, bufend,
2038 #endif /* ! (atarist || DOSISH) */
2042 if ($major == 4 && $^O eq 'linux') {
2043 # Whilst this is fixed properly in f0784f6a4c3e45e1 which provides the
2044 # Configure probe, it's easier to back out the problematic changes made
2045 # in these previous commits:
2046 if (extract_from_file('doio.c',
2047 qr!^/\* XXX REALLY need metaconfig test \*/$!)) {
2048 revert_commit('4682965a1447ea44', 'doio.c');
2050 if (my $token = extract_from_file('doio.c',
2051 qr!^#if (defined\(__sun(?:__)?\)) && defined\(__svr4__\) /\* XXX Need metaconfig test \*/$!)) {
2052 my $patch = `git show -R 9b599b2a63d2324d doio.c`;
2053 $patch =~ s/defined\(__sun__\)/$token/g;
2054 apply_patch($patch);
2056 if (extract_from_file('doio.c',
2057 qr!^/\* linux \(and Solaris2\?\) uses :$!)) {
2058 revert_commit('8490252049bf42d3', 'doio.c');
2060 if (extract_from_file('doio.c',
2061 qr/^ unsemds.buf = &semds;$/)) {
2062 revert_commit('8e591e46b4c6543e');
2064 if (extract_from_file('doio.c',
2065 qr!^#ifdef __linux__ /\* XXX Need metaconfig test \*/$!)) {
2066 # Reverts part of commit 3e3baf6d63945cb6
2067 apply_patch(<<'EOPATCH');
2068 diff --git b/doio.c a/doio.c
2069 index 62b7de9..0d57425 100644
2072 @@ -1333,9 +1331,6 @@ SV **sp;
2074 I32 id, n, cmd, infosize, getinfo;
2076 -#ifdef __linux__ /* XXX Need metaconfig test */
2077 - union semun unsemds;
2080 id = SvIVx(*++mark);
2081 n = (optype == OP_SEMCTL) ? SvIVx(*++mark) : 0;
2082 @@ -1364,29 +1359,11 @@ SV **sp;
2083 infosize = sizeof(struct semid_ds);
2084 else if (cmd == GETALL || cmd == SETALL)
2086 -#ifdef __linux__ /* XXX Need metaconfig test */
2088 - int semctl (int semid, int semnun, int cmd, union semun arg)
2092 - struct semid_ds *buf;
2096 - union semun semds;
2097 - if (semctl(id, 0, IPC_STAT, semds) == -1)
2099 struct semid_ds semds;
2100 if (semctl(id, 0, IPC_STAT, &semds) == -1)
2103 getinfo = (cmd == GETALL);
2104 -#ifdef __linux__ /* XXX Need metaconfig test */
2105 - infosize = semds.buf->sem_nsems * sizeof(short);
2107 infosize = semds.sem_nsems * sizeof(short);
2109 /* "short" is technically wrong but much more portable
2110 than guessing about u_?short(_t)? */
2112 @@ -1429,12 +1406,7 @@ SV **sp;
2116 -#ifdef __linux__ /* XXX Need metaconfig test */
2117 - unsemds.buf = (struct semid_ds *)a;
2118 - ret = semctl(id, n, cmd, unsemds);
2120 ret = semctl(id, n, cmd, (struct semid_ds *)a);
2127 # Incorrect prototype added as part of 8ac853655d9b7447, fixed as part
2128 # of commit dc45a647708b6c54, with at least one intermediate
2129 # modification. Correct prototype for gethostbyaddr has socklen_t
2130 # second. Linux has uint32_t first for getnetbyaddr.
2131 # Easiest just to remove, instead of attempting more complex patching.
2132 # Something similar may be needed on other platforms.
2133 edit_file('pp_sys.c', sub {
2135 $code =~ s/^ struct hostent \*(?:PerlSock_)?gethostbyaddr\([^)]+\);$//m;
2136 $code =~ s/^ struct netent \*getnetbyaddr\([^)]+\);$//m;
2141 if ($major < 6 && $^O eq 'netbsd'
2142 && !extract_from_file('unixish.h',
2143 qr/defined\(NSIG\).*defined\(__NetBSD__\)/)) {
2144 apply_patch(<<'EOPATCH')
2145 diff --git a/unixish.h b/unixish.h
2146 index 2a6cbcd..eab2de1 100644
2151 /* #define ALTERNATE_SHEBANG "#!" / **/
2153 -#if !defined(NSIG) || defined(M_UNIX) || defined(M_XENIX)
2154 +#if !defined(NSIG) || defined(M_UNIX) || defined(M_XENIX) || defined(__NetBSD__)
2155 # include <signal.h>
2161 if (($major >= 7 || $major <= 9) && $^O eq 'openbsd'
2162 && `uname -m` eq "sparc64\n"
2163 # added in 2000 by commit cb434fcc98ac25f5:
2164 && extract_from_file('regexec.c',
2165 qr!/\* No need to save/restore up to this paren \*/!)
2166 # re-indented in 2006 by commit 95b2444054382532:
2167 && extract_from_file('regexec.c', qr/^\t\tCURCUR cc;$/)) {
2168 # Need to work around a bug in (at least) OpenBSD's 4.6's sparc64 #
2169 # compiler ["gcc (GCC) 3.3.5 (propolice)"]. Between commits
2170 # 3ec562b0bffb8b8b (2002) and 1a4fad37125bac3e^ (2005) the darling thing
2171 # fails to compile any code for the statement cc.oldcc = PL_regcc;
2173 # If you refactor the code to "fix" that, or force the issue using set
2174 # in the debugger, the stack smashing detection code fires on return
2175 # from S_regmatch(). Turns out that the compiler doesn't allocate any
2176 # (or at least enough) space for cc.
2178 # Restore the "uninitialised" value for cc before function exit, and the
2179 # stack smashing code is placated. "Fix" 3ec562b0bffb8b8b (which
2180 # changes the size of auto variables used elsewhere in S_regmatch), and
2181 # the crash is visible back to bc517b45fdfb539b (which also changes
2182 # buffer sizes). "Unfix" 1a4fad37125bac3e and the crash is visible until
2183 # 5b47454deb66294b. Problem goes away if you compile with -O, or hack
2184 # the code as below.
2186 # Hence this turns out to be a bug in (old) gcc. Not a security bug we
2187 # still need to fix.
2188 apply_patch(<<'EOPATCH');
2189 diff --git a/regexec.c b/regexec.c
2190 index 900b491..6251a0b 100644
2193 @@ -2958,7 +2958,11 @@ S_regmatch(pTHX_ regnode *prog)
2195 *******************************************************************/
2200 + char hack_buff[sizeof(CURCUR) + 1];
2202 +#define cc hack.hack_cc
2203 CHECKPOINT cp = PL_savestack_ix;
2204 /* No need to save/restore up to this paren */
2205 I32 parenfloor = scan->flags;
2206 @@ -2983,6 +2987,7 @@ S_regmatch(pTHX_ regnode *prog)
2207 n = regmatch(PREVOPER(next)); /* start on the WHILEM */
2209 PL_regcc = cc.oldcc;
2217 if ($major < 8 && $^O eq 'openbsd'
2218 && !extract_from_file('perl.h', qr/include <unistd\.h>/)) {
2219 # This is part of commit 3f270f98f9305540, applied at a slightly
2220 # different location in perl.h, where the context is stable back to
2222 apply_patch(<<'EOPATCH');
2223 diff --git a/perl.h b/perl.h
2224 index 9418b52..b8b1a7c 100644
2227 @@ -496,6 +496,10 @@ register struct op *Perl_op asm(stringify(OP_IN_REGISTER));
2228 # include <sys/param.h>
2231 +/* If this causes problems, set i_unistd=undef in the hint file. */
2233 +# include <unistd.h>
2236 /* Use all the "standard" definitions? */
2237 #if defined(STANDARD_C) && defined(I_STDLIB)
2243 # cperl-indent-level: 4
2244 # indent-tabs-mode: nil
2247 # ex: set ts=8 sts=4 sw=4 et: