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);
56 cc => (`ccache --version`, $?) ? 'cc' : 'ccache cc',
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 'force-regen', 'test-build', 'A=s@', 'l', 'w',
66 'check-args', 'check-shebang!', 'usage|help|?',
68 my (undef, $val) = @_;
69 if ($val =~ /\A([^=]+)=(.*)/s) {
70 $defines{$1} = length $2 ? $2 : "\0";
76 $defines{$_[1]} = undef;
79 pod2usage(exitval => 255, verbose => 1);
82 my ($target, $j, $match) = @options{qw(target jobs match)};
84 pod2usage(exitval => 255, verbose => 1) if $options{usage};
85 pod2usage(exitval => 255, verbose => 1)
86 unless @ARGV || $match || $options{'test-build'} || defined $options{'one-liner'};
87 pod2usage(exitval => 255, verbose => 1)
88 if !$options{'one-liner'} && ($options{l} || $options{w});
90 check_shebang($ARGV[0]) if $options{'check-shebang'} && @ARGV;
92 exit 0 if $options{'check-args'};
96 bisect.pl - use git bisect to pinpoint changes
100 # When did this become an error?
101 .../Porting/bisect.pl -e 'my $a := 2;'
102 # When did this stop being an error?
103 .../Porting/bisect.pl --expect-fail -e '1 // 2'
104 # When did this stop matching?
105 .../Porting/bisect.pl --match '\b(?:PL_)hash_seed_set\b'
106 # When did this start matching?
107 .../Porting/bisect.pl --expect-fail --match '\buseithreads\b'
108 # When did this test program stop working?
109 .../Porting/bisect.pl -- ./perl -Ilib ../test_prog.pl
110 # When did this first become valid syntax?
111 .../Porting/bisect.pl --target=miniperl --end=v5.10.0 \
112 --expect-fail -e 'my $a := 2;'
113 # What was the last revision to build with these options?
114 .../Porting/bisect.pl --test-build -Dd_dosuid
118 Together F<bisect.pl> and F<bisect-runner.pl> attempt to automate the use
119 of C<git bisect> as much as possible. With one command (and no other files)
120 it's easy to find out
126 Which commit caused this example code to break?
130 Which commit caused this example code to start working?
134 Which commit added the first to match this regex?
138 Which commit removed the last to match this regex?
142 usually without needing to know which versions of perl to use as start and
145 By default F<bisect.pl> will process all options, then use the rest of the
146 command line as arguments to list C<system> to run a test case. By default,
147 the test case should pass (exit with 0) on earlier perls, and fail (exit
148 non-zero) on I<blead>. F<bisect.pl> will use F<bisect-runner.pl> to find the
149 earliest stable perl version on which the test case passes, check that it
150 fails on blead, and then use F<bisect-runner.pl> with C<git bisect run> to
151 find the commit which caused the failure.
153 Because the test case is the complete argument to C<system>, it is easy to
154 run something other than the F<perl> built, if necessary. If you need to run
155 the perl built, you'll probably need to invoke it as C<./perl -Ilib ...>
157 You need a clean checkout to run a bisect, and you can't use the checkout
158 which contains F<Porting/bisect.pl> (because C<git bisect>) will check out
159 a revision before F<Porting/bisect-runner.pl> was added, which
160 C<git bisect run> needs). If your working checkout is called F<perl>, the
161 simplest solution is to make a local clone, and run from that. I<i.e.>:
166 ../perl/Porting/bisect.pl ...
168 By default, F<bisect-runner.pl> will automatically disable the build of
169 L<DB_File> for commits earlier than ccb44e3bf3be2c30, as it's not practical
170 to patch DB_File 1.70 and earlier to build with current Berkeley DB headers.
171 (ccb44e3bf3be2c30 was in September 1999, between 5.005_62 and 5.005_63.)
172 If your F<db.h> is old enough you can override this with C<-Unoextensions>.
180 --start I<commit-ish>
182 Earliest revision to test, as a I<commit-ish> (a tag, commit or anything
183 else C<git> understands as a revision). If not specified, F<bisect.pl> will
184 search stable perl releases from 5.002 to 5.14.0 until it finds one where
185 the test case passes.
191 Most recent revision to test, as a I<commit-ish>. If not specified, defaults
198 F<Makefile> target (or equivalent) needed, to run the test case. If specified,
199 this should be one of
207 Just run F<./Configure>
213 Run the various F<*.SH> files to generate F<Makefile>, F<config.h>, I<etc>.
225 Use F<miniperl> to build F<lib/Config.pm>
231 Build F<lib/auto/Fcntl/Fnctl.so> (strictly, C<.$Config{so}>). As L<Fcntl>
232 is simple XS module present since 5.000, this provides a fast test of
233 whether XS modules can be built. Note, XS modules are built by F<miniperl>,
234 hence this target will not build F<perl>.
240 Build F<perl>. This also builds pure-Perl modules in F<cpan>, F<dist> and
241 F<ext>. XS modules (such as L<Fcntl>) are not built.
247 Build everything needed to run the tests. This is the default if we're
248 running test code, but is time consuming, as it means building all
249 XS modules. For older F<Makefile>s, the previous name of C<test-prep>
250 is automatically substituted. For very old F<Makefile>s, C<make test> is
251 run, as there is no target provided to just get things ready, and for 5.004
252 and earlier the tests run very quickly.
258 --one-liner 'code to run'
264 Example code to run, just like you'd use with C<perl -e>.
266 This prepends C<./perl -Ilib -e 'code to run'> to the test case given,
267 or F<./miniperl> if I<target> is C<miniperl>.
269 (Usually you'll use C<-e> instead of providing a test case in the
270 non-option arguments to F<bisect.pl>)
272 C<-E> intentionally isn't supported, as it's an error in 5.8.0 and earlier,
273 which interferes with detecting errors in the example code itself.
279 Add C<-l> to the command line with C<-e>
281 This will automatically append a newline to every output line of your testcase.
282 Note that you can't specify an argument to F<perl>'s C<-l> with this, as it's
283 not feasible to emulate F<perl>'s somewhat quirky switch parsing with
284 L<Getopt::Long>. If you need the full flexibility of C<-l>, you need to write
285 a full test case, instead of using C<bisect.pl>'s C<-e> shortcut.
291 Add C<-w> to the command line with C<-e>
293 It's not valid to pass C<-l> or C<-w> to C<bisect.pl> unless you are also
300 The test case should fail for the I<start> revision, and pass for the I<end>
301 revision. The bisect run will find the first commit where it passes.
305 -Dnoextensions=Encode
313 -Accflags=-DNO_MATHOMS
315 Arguments to pass to F<Configure>. Repeated C<-A> arguments are passed
316 through as is. C<-D> and C<-U> are processed in order, and override
317 previous settings for the same parameter. F<bisect-runner.pl> emulates
318 C<-Dnoextensions> when F<Configure> itself does not provide it, as it's
319 often very useful to be able to disable some XS extensions.
329 Number of C<make> jobs to run in parallel. If F</proc/cpuinfo> exists and
330 can be parsed, or F</sbin/sysctl> exists and reports C<hw.ncpu>, or
331 F</usr/bin/getconf> exists and reports C<_NPROCESSORS_ONLN> defaults to 1 +
332 I<number of CPUs>. Otherwise defaults to 2.
338 Instead of running a test program to determine I<pass> or I<fail>, pass
339 if the given regex matches, and hence search for the commit that removes
340 the last matching file.
342 If no I<target> is specified, the match is against all files in the
343 repository (which is fast). If a I<target> is specified, that target is
344 built, and the match is against only the built files. C<--expect-fail> can
345 be used with C<--match> to search for a commit that adds files that match.
351 Test that the build completes, without running any test case.
353 By default, if the build for the desired I<target> fails to complete,
354 F<bisect-runner.pl> reports a I<skip> back to C<git bisect>, the assumption
355 being that one wants to find a commit which changed state "builds && passes"
356 to "builds && fails". If instead one is interested in which commit broke the
357 build (possibly for particular F<Configure> options), use I<--test-build>
358 to treat a build failure as a failure, not a "skip".
360 Often this option isn't as useful as it first seems, because I<any> build
361 failure will be reported to C<git bisect> as a failure, not just the failure
362 that you're interested in. Generally, to debug a particular problem, it's
363 more useful to use a I<target> that builds properly at the point of interest,
364 and then a test case that runs C<make>. For example:
366 .../Porting/bisect.pl --start=perl-5.000 --end=perl-5.002 \
367 --expect-fail --force-manifest --target=miniperl make perl
369 will find the first revision capable of building L<DynaLoader> and then
370 F<perl>, without becoming confused by revisions where F<miniperl> won't
377 By default, a build will "skip" if any files listed in F<MANIFEST> are not
378 present. Usually this is useful, as it avoids false-failures. However, there
379 are some long ranges of commits where listed files are missing, which can
380 cause a bisect to abort because all that remain are skipped revisions.
382 In these cases, particularly if the test case uses F<miniperl> and no modules,
383 it may be more useful to force the build to continue, even if files
384 F<MANIFEST> are missing.
390 Run C<make regen_headers> before building F<miniperl>. This may fix a build
391 that otherwise would skip because the generated headers at that revision
392 are stale. It's not the default because it conceals this error in the true
393 state of such revisions.
399 C<--expect-pass=0> is equivalent to C<--expect-fail>. I<1> is the default.
405 Tell F<bisect-runner.pl> not to clean up after the build. This allows one
406 to use F<bisect-runner.pl> to build the current particular perl revision for
407 interactive testing, or for debugging F<bisect-runner.pl>.
409 Passing this to F<bisect.pl> will likely cause the bisect to fail badly.
415 Test that all stable revisions can be built. By default, attempts to build
416 I<blead>, I<v5.14.0> .. I<perl-5.002>. Stops at the first failure, without
417 cleaning the checkout. Use I<--start> to specify the earliest revision to
418 test, I<--end> to specify the most recent. Useful for validating a new
419 OS/CPU/compiler combination. For example
421 ../perl/Porting/bisect.pl --validate -le 'print "Hello from $]"'
423 If no testcase is specified, the default is to use F<t/TEST> to run
430 Validate the options and arguments, and exit silently if they are valid.
436 Validate that the test case isn't an executable file with a
437 C<#!/usr/bin/perl> line (or similar). As F<bisect-runner.pl> does B<not>
438 prepend C<./perl> to the test case, a I<#!> line specifying an external
439 F<perl> binary will cause the test case to always run with I<that> F<perl>,
440 not the F<perl> built by the bisect runner. Likely this is not what you
441 wanted. If your test case is actually a wrapper script to run other
442 commands, you should run it with an explicit interpreter, to be clear. For
443 example, instead of C<../perl/Porting/bisect.pl ~/test/testcase.pl> you'd
444 run C<../perl/Porting/bisect.pl /usr/bin/perl ~/test/testcase.pl>
458 Display the usage information and exit.
464 die "$0: Can't build $target" if defined $target && !grep {@targets} $target;
466 $j = "-j$j" if $j =~ /\A\d+\z/;
468 # Sadly, however hard we try, I don't think that it will be possible to build
469 # modules in ext/ on x86_64 Linux before commit e1666bf5602ae794 on 1999/12/29,
470 # which updated to MakeMaker 3.7, which changed from using a hard coded ld
471 # in the Makefile to $(LD). On x86_64 Linux the "linker" is gcc.
475 my $mode = @_ ? shift : '<';
476 open my $fh, $mode, $file or croak("Can't open $file: $!");
477 ${*$fh{SCALAR}} = $file;
484 croak("Can't close: $!") unless ref $fh eq 'GLOB';
485 croak("Can't close ${*$fh{SCALAR}}: $!");
488 sub extract_from_file {
489 my ($file, $rx, $default) = @_;
490 my $fh = open_or_die($file);
493 return wantarray ? @got : $got[0]
496 return $default if defined $default;
501 my ($file, $munger) = @_;
503 my $fh = open_or_die($file);
505 die "Can't read $file: $!" unless defined $orig && close $fh;
506 my $new = $munger->($orig);
507 return if $new eq $orig;
508 $fh = open_or_die($file, '>');
509 print $fh $new or die "Can't print to $file: $!";
516 my ($file) = $patch =~ qr!^--- a/(\S+)\n\+\+\+ b/\1!sm;
517 open my $fh, '|-', 'patch', '-p1' or die "Can't run patch: $!";
520 print STDERR "Patch is <<'EOPATCH'\n${patch}EOPATCH\n";
521 die "Can't patch $file: $?, $!";
525 my ($commit, @files) = @_;
526 return unless system "git show $commit @files | patch -p1";
527 die "Can't apply commit $commit to @files" if @files;
528 die "Can't apply commit $commit";
532 my ($commit, @files) = @_;
533 return unless system "git show -R $commit @files | patch -p1";
534 die "Can't apply revert $commit from @files" if @files;
535 die "Can't apply revert $commit";
539 my ($file, $commit) = @_;
541 system "git show $commit:$file > $file </dev/null"
542 and die "Could not extract $file at revision $commit";
547 return unless -e $file;
549 die "$file is not executable.
550 system($file, ...) is always going to fail.
554 my $fh = open_or_die($file);
556 return unless $line =~ m{\A#!(/\S+/perl\S*)\s};
557 die "$file will always be run by $1
558 It won't be tested by the ./perl we build.
559 If you intended to run it with that perl binary, please change your
564 If you intended to test it with the ./perl we build, please change your
569 [You may also need to add -- before ./perl to prevent that -Ilib as being
570 parsed as an argument to bisect.pl]
576 if ($options{clean}) {
577 # Needed, because files that are build products in this checked out
578 # version might be in git in the next desired version.
579 system 'git clean -dxf </dev/null';
580 # Needed, because at some revisions the build alters checked out files.
581 # (eg pod/perlapi.pod). Also undoes any changes to makedepend.SH
582 system 'git reset --hard HEAD </dev/null';
589 warn "skipping - $reason";
593 sub report_and_exit {
594 my ($ret, $pass, $fail, $desc) = @_;
598 my $got = ($options{'expect-pass'} ? !$ret : $ret) ? 'good' : 'bad';
600 print "$got - $fail $desc\n";
602 print "$got - $pass $desc\n";
616 @files = defined $target ? `git ls-files -o -z`: `git ls-files -z`;
620 foreach my $file (@files) {
621 my $fh = open_or_die($file);
625 if (tr/\t\r\n -~\200-\377//c) {
626 print "Binary file $file matches\n";
628 $_ .= "\n" unless /\n\z/;
635 report_and_exit(!$matches,
636 $matches == 1 ? '1 match for' : "$matches matches for",
637 'no matches for', $match);
640 # Not going to assume that system perl is yet new enough to have autodie
641 system 'git clean -dxf </dev/null' and die;
643 if (!defined $target) {
644 match_and_exit() if $match;
645 $target = 'test_prep';
648 skip('no Configure - is this the //depot/perlext/Compiler branch?')
649 unless -f 'Configure';
651 # This changes to PERL_VERSION in 4d8076ea25903dcb in 1999
653 = extract_from_file('patchlevel.h',
654 qr/^#define\s+(?:PERL_VERSION|PATCHLEVEL)\s+(\d+)\s/,
660 # if Encode is not needed for the test, you can speed up the bisect by
661 # excluding it from the runs with -Dnoextensions=Encode
662 # ccache is an easy win. Remove it if it causes problems.
663 # Commit 1cfa4ec74d4933da adds ignore_versioned_solibs to Configure, and sets it
664 # to true in hints/linux.sh
665 # On dromedary, from that point on, Configure (by default) fails to find any
666 # libraries, because it scans /usr/local/lib /lib /usr/lib, which only contain
667 # versioned libraries. Without -lm, the build fails.
668 # Telling /usr/local/lib64 /lib64 /usr/lib64 works from that commit onwards,
669 # until commit faae14e6e968e1c0 adds it to the hints.
670 # However, prior to 1cfa4ec74d4933da telling Configure the truth doesn't work,
671 # because it will spot versioned libraries, pass them to the compiler, and then
672 # bail out pretty early on. Configure won't let us override libswanted, but it
673 # will let us override the entire libs list.
675 unless (extract_from_file('Configure', 'ignore_versioned_solibs')) {
676 # Before 1cfa4ec74d4933da, so force the libs list.
679 # This is the current libswanted list from Configure, less the libs removed
680 # by current hints/linux.sh
681 foreach my $lib (qw(sfio socket inet nsl nm ndbm gdbm dbm db malloc dl dld
682 ld sun m crypt sec util c cposix posix ucb BSD)) {
683 foreach my $dir (@paths) {
684 next unless -f "$dir/lib$lib.so";
685 push @libs, "-l$lib";
689 $defines{libs} = \@libs unless exists $defines{libs};
692 $defines{usenm} = undef
693 if $major < 2 && !exists $defines{usenm};
695 my ($missing, $created_dirs);
696 ($missing, $created_dirs) = force_manifest()
697 if $options{'force-manifest'};
700 foreach my $key (sort keys %defines) {
701 my $val = $defines{$key};
703 push @ARGS, "-D$key=@$val";
704 } elsif (!defined $val) {
705 push @ARGS, "-U$key";
706 } elsif (!length $val) {
707 push @ARGS, "-D$key";
709 $val = "" if $val eq "\0";
710 push @ARGS, "-D$key=$val";
713 push @ARGS, map {"-A$_"} @{$options{A}};
715 # </dev/null because it seems that some earlier versions of Configure can
716 # call commands in a way that now has them reading from stdin (and hanging)
718 die "Can't fork: $!" unless defined $pid;
720 open STDIN, '<', '/dev/null';
721 # If a file in MANIFEST is missing, Configure asks if you want to
722 # continue (the default being 'n'). With stdin closed or /dev/null,
723 # it exits immediately and the check for config.sh below will skip.
724 exec './Configure', @ARGS;
725 die "Failed to start Configure: $!";
728 or die "wait for Configure, pid $pid failed: $!";
732 if (-f 'config.sh') {
733 # Emulate noextensions if Configure doesn't support it.
735 if $major < 10 && $defines{noextensions};
736 system './Configure -S </dev/null' and die;
739 if ($target =~ /config\.s?h/) {
740 match_and_exit($target) if $match && -f $target;
741 report_and_exit(!-f $target, 'could build', 'could not build', $target)
742 if $options{'test-build'};
744 my $ret = system @ARGV;
745 report_and_exit($ret, 'zero exit from', 'non-zero exit from', "@ARGV");
746 } elsif (!-f 'config.sh') {
747 # Skip if something went wrong with Configure
749 skip('could not build config.sh');
752 force_manifest_cleanup($missing, $created_dirs)
755 if($options{'force-regen'}
756 && extract_from_file('Makefile', qr/\bregen_headers\b/)) {
757 # regen_headers was added in e50aee73b3d4c555, patch.1m for perl5.001
758 # It's not worth faking it for earlier revisions.
759 system "make regen_headers </dev/null"
766 # Parallel build for miniperl is safe
767 system "make $j miniperl </dev/null";
769 my $expected = $target =~ /^test/ ? 't/perl'
770 : $target eq 'Fcntl' ? "lib/auto/Fcntl/Fcntl.$Config{so}"
772 my $real_target = $target eq 'Fcntl' ? $expected : $target;
774 if ($target ne 'miniperl') {
775 # Nearly all parallel build issues fixed by 5.10.0. Untrustworthy before that.
776 $j = '' if $major < 10;
778 if ($real_target eq 'test_prep') {
780 # test-prep was added in 5.004_01, 3e3baf6d63945cb6.
781 # renamed to test_prep in 2001 in 5fe84fd29acaf55c.
782 # earlier than that, just make test. It will be fast enough.
783 $real_target = extract_from_file('Makefile.SH',
784 qr/^(test[-_]prep):/,
789 system "make $j $real_target </dev/null";
792 my $missing_target = $expected =~ /perl$/ ? !-x $expected : !-r $expected;
794 if ($options{'test-build'}) {
795 report_and_exit($missing_target, 'could build', 'could not build',
797 } elsif ($missing_target) {
798 skip("could not build $real_target");
801 match_and_exit($real_target) if $match;
803 if (defined $options{'one-liner'}) {
804 my $exe = $target =~ /^(?:perl$|test)/ ? 'perl' : 'miniperl';
805 unshift @ARGV, '-e', $options{'one-liner'};
806 unshift @ARGV, '-l' if $options{l};
807 unshift @ARGV, '-w' if $options{w};
808 unshift @ARGV, "./$exe", '-Ilib';
811 # This is what we came here to run:
813 if (exists $Config{ldlibpthname}) {
815 my $varname = $Config{ldlibpthname};
816 my $cwd = Cwd::getcwd();
817 if (defined $ENV{$varname}) {
818 $ENV{$varname} = $cwd . $Config{path_sep} . $ENV{$varname};
820 $ENV{$varname} = $cwd;
824 my $ret = system @ARGV;
826 report_and_exit($ret, 'zero exit from', 'non-zero exit from', "@ARGV");
828 ############################################################################
830 # Patching, editing and faking routines only below here.
832 ############################################################################
834 sub fake_noextensions {
835 edit_file('config.sh', sub {
836 my @lines = split /\n/, shift;
837 my @ext = split /\s+/, $defines{noextensions};
839 next unless /^extensions=/ || /^dynamic_ext/;
840 foreach my $ext (@ext) {
844 return join "\n", @lines;
849 my (@missing, @created_dirs);
850 my $fh = open_or_die('MANIFEST');
852 next unless /^(\S+)/;
853 # -d is special case needed (at least) between 27332437a2ed1941 and
854 # bf3d9ec563d25054^ inclusive, as manifest contains ext/Thread/Thread
856 unless -f $1 || -d $1;
860 foreach my $pathname (@missing) {
861 my @parts = split '/', $pathname;
862 my $leaf = pop @parts;
865 $path .= '/' . shift @parts;
867 mkdir $path, 0700 or die "Can't create $path: $!";
868 unshift @created_dirs, $path;
870 $fh = open_or_die($pathname, '>');
872 chmod 0, $pathname or die "Can't chmod 0 $pathname: $!";
874 return \@missing, \@created_dirs;
877 sub force_manifest_cleanup {
878 my ($missing, $created_dirs) = @_;
879 # This is probably way too paranoid:
882 foreach my $file (@$missing) {
883 my (undef, undef, $mode, undef, undef, undef, undef, $size)
885 if (!defined $mode) {
886 push @errors, "Added file $file has been deleted by Configure";
889 if (Fcntl::S_IMODE($mode) != 0) {
891 sprintf 'Added file %s had mode changed by Configure to %03o',
896 "Added file $file had sized changed by Configure to $size";
898 unlink $file or die "Can't unlink $file: $!";
900 foreach my $dir (@$created_dirs) {
901 rmdir $dir or die "Can't rmdir $dir: $!";
907 sub patch_Configure {
909 if (extract_from_file('Configure',
910 qr/^\t\t\*=\*\) echo "\$1" >> \$optdef;;$/)) {
911 # This is " Spaces now allowed in -D command line options.",
912 # part of commit ecfc54246c2a6f42
913 apply_patch(<<'EOPATCH');
914 diff --git a/Configure b/Configure
915 index 3d3b38d..78ffe16 100755
918 @@ -652,7 +777,8 @@ while test $# -gt 0; do
919 echo "$me: use '-U symbol=', not '-D symbol='." >&2
920 echo "$me: ignoring -D $1" >&2
922 - *=*) echo "$1" >> $optdef;;
924 + sed -e "s/'/'\"'\"'/g" -e "s/=\(.*\)/='\1'/" >> $optdef;;
925 *) echo "$1='define'" >> $optdef;;
931 if (extract_from_file('Configure', qr/^if \$contains 'd_namlen' \$xinc\b/)) {
932 # Configure's original simple "grep" for d_namlen falls foul of the
933 # approach taken by the glibc headers:
934 # #ifdef _DIRENT_HAVE_D_NAMLEN
935 # # define _D_EXACT_NAMLEN(d) ((d)->d_namlen)
937 # where _DIRENT_HAVE_D_NAMLEN is not defined on Linux.
938 # This is also part of commit ecfc54246c2a6f42
939 apply_patch(<<'EOPATCH');
940 diff --git a/Configure b/Configure
941 index 3d3b38d..78ffe16 100755
944 @@ -3935,7 +4045,8 @@ $rm -f try.c
946 : see if the directory entry stores field length
948 -if $contains 'd_namlen' $xinc >/dev/null 2>&1; then
949 +$cppstdin $cppflags $cppminus < "$xinc" > try.c
950 +if $contains 'd_namlen' try.c >/dev/null 2>&1; then
951 echo "Good, your directory entry keeps length information in d_namlen." >&4
959 && !extract_from_file('Configure',
960 qr/Try to guess additional flags to pick up local libraries/)) {
961 my $mips = extract_from_file('Configure',
962 qr!(''\) if (?:\./)?mips; then)!);
963 # This is part of perl-5.001n. It's needed, to add -L/usr/local/lib to
964 # theld flags if libraries are found there. It shifts the code to set up
965 # libpth earlier, and then adds the code to add libpth entries to
967 # mips was changed to ./mips in ecfc54246c2a6f42, perl5.000 patch.0g
968 apply_patch(sprintf <<'EOPATCH', $mips);
969 diff --git a/Configure b/Configure
970 index 53649d5..0635a6e 100755
973 @@ -2749,6 +2749,52 @@ EOM
977 +: Set private lib path
980 + plibpth="$incpath/usr/lib /usr/local/lib /usr/ccs/lib"
985 +'') dlist="$plibpth $glibpth";;
986 +*) dlist="$libpth";;
989 +: Now check and see which directories actually exist, avoiding duplicates
993 + if $test -d $xxx; then
994 + case " $libpth " in
996 + *) libpth="$libpth $xxx";;
1002 +Some systems have incompatible or broken versions of libraries. Among
1003 +the directories listed in the question below, please remove any you
1004 +know not to be holding relevant libraries, and add any that are needed.
1005 +Say "none" for none.
1016 +rp="Directories to use for library searches?"
1023 : flags used in final linking phase
1025 '') if ./venix; then
1026 @@ -2765,6 +2811,23 @@ case "$ldflags" in
1028 *) dflt="$ldflags";;
1031 +: Possible local library directories to search.
1032 +loclibpth="/usr/local/lib /opt/local/lib /usr/gnu/lib"
1033 +loclibpth="$loclibpth /opt/gnu/lib /usr/GNU/lib /opt/GNU/lib"
1035 +: Try to guess additional flags to pick up local libraries.
1036 +for thislibdir in $libpth; do
1037 + case " $loclibpth " in
1038 + *" $thislibdir "*)
1040 + "-L$thislibdir ") ;;
1041 + *) dflt="$dflt -L$thislibdir" ;;
1048 rp="Any additional ld flags (NOT including libraries)?"
1050 @@ -2828,52 +2891,6 @@ n) echo "OK, that should do.";;
1052 $rm -f try try.* core
1054 -: Set private lib path
1057 - plibpth="$incpath/usr/lib /usr/local/lib /usr/ccs/lib"
1062 -'') dlist="$plibpth $glibpth";;
1063 -*) dlist="$libpth";;
1066 -: Now check and see which directories actually exist, avoiding duplicates
1070 - if $test -d $xxx; then
1071 - case " $libpth " in
1073 - *) libpth="$libpth $xxx";;
1079 -Some systems have incompatible or broken versions of libraries. Among
1080 -the directories listed in the question below, please remove any you
1081 -know not to be holding relevant libraries, and add any that are needed.
1082 -Say "none" for none.
1093 -rp="Directories to use for library searches?"
1100 : compute shared library extension
1106 if ($major < 5 && extract_from_file('Configure',
1107 qr!if \$cc \$ccflags try\.c -o try >/dev/null 2>&1; then!)) {
1108 # Analogous to the more general fix of dfe9444ca7881e71
1109 # Without this flags such as -m64 may not be passed to this compile,
1110 # which results in a byteorder of '1234' instead of '12345678', which
1111 # can then cause crashes.
1113 if (extract_from_file('Configure', qr/xxx_prompt=y/)) {
1114 # 8e07c86ebc651fe9 or later
1115 # ("This is my patch patch.1n for perl5.001.")
1116 apply_patch(<<'EOPATCH');
1117 diff --git a/Configure b/Configure
1118 index 62249dd..c5c384e 100755
1121 @@ -8247,7 +8247,7 @@ main()
1125 - if $cc $ccflags try.c -o try >/dev/null 2>&1 && ./try > /dev/null; then
1126 + if $cc $ccflags $ldflags try.c -o try >/dev/null 2>&1 && ./try > /dev/null; then
1129 [1-4][1-4][1-4][1-4]|12345678|87654321)
1132 apply_patch(<<'EOPATCH');
1133 diff --git a/Configure b/Configure
1134 index 53649d5..f1cd64a 100755
1137 @@ -6362,7 +6362,7 @@ main()
1141 - if $cc $ccflags try.c -o try >/dev/null 2>&1 ; then
1142 + if $cc $ccflags $ldflags try.c -o try >/dev/null 2>&1 ; then
1145 ????|????????) echo "(The test program ran ok.)";;
1150 if ($major < 6 && !extract_from_file('Configure',
1152 # This adds the -A option to Configure, which is incredibly useful
1153 # Effectively this is commits 02e93a22d20fc9a5, 5f83a3e9d818c3ad,
1154 # bde6b06b2c493fef, f7c3111703e46e0c and 2 lines of trailing whitespace
1155 # removed by 613d6c3e99b9decc, but applied at slightly different
1156 # locations to ensure a clean patch back to 5.000
1157 # Note, if considering patching to the intermediate revisions to fix
1158 # bugs in -A handling, f7c3111703e46e0c is from 2002, and hence
1161 # To add to the fun, early patches add -K and -O options, and it's not
1162 # trivial to get patch to put the C<. ./posthint.sh> in the right place
1163 edit_file('Configure', sub {
1165 $code =~ s/(optstr = ")([^"]+";\s*# getopt-style specification)/$1A:$2/
1166 or die "Substitution failed";
1167 $code =~ s!^(: who configured the system)!
1172 or die "Substitution failed";
1175 apply_patch(<<'EOPATCH');
1176 diff --git a/Configure b/Configure
1177 index 4b55fa6..60c3c64 100755
1180 @@ -1150,6 +1150,7 @@ set X `for arg in "$@"; do echo "X$arg"; done |
1186 : set up default values
1188 @@ -1172,6 +1173,56 @@ while test $# -gt 0; do
1190 -d) shift; fastread=yes;;
1191 -e) shift; alldone=cont;;
1199 + *=*) zzz=`echo "$yyy"|sed 's!=.*!!'`
1203 + zzz=" "`echo "$yyy"|sed 's!^[^=]*=!!'`
1204 + yyy=`echo "$yyy"|sed 's!=.*!!'` ;;
1209 + '') case "$yyy" in
1210 + *:*) xxx=`echo "$yyy"|sed 's!:.*!!'`
1211 + yyy=`echo "$yyy"|sed 's!^[^:]*:!!'`
1212 + zzz=`echo "$yyy"|sed 's!^[^=]*=!!'`
1213 + yyy=`echo "$yyy"|sed 's!=.*!!'` ;;
1214 + *) xxx=`echo "$yyy"|sed 's!:.*!!'`
1215 + yyy=`echo "$yyy"|sed 's!^[^:]*:!!'` ;;
1221 + echo "$yyy=\"\${$yyy}$zzz\"" >> posthint.sh ;;
1223 + echo "$yyy=''" >> posthint.sh ;;
1228 + echo "$yyy='$zzz'" >> posthint.sh ;;
1230 + echo "eval \"$yyy=$zzz\"" >> posthint.sh ;;
1232 + echo "$yyy=\"$zzz\${$yyy}\"" >> posthint.sh ;;
1237 + echo "$yyy=$zzz" >> posthint.sh ;;
1238 + *) echo "$me: unknown -A command '$xxx', ignoring -A $1" >&2 ;;
1248 if ($major < 8 && !extract_from_file('Configure',
1249 qr/^\t\tif test ! -t 0; then$/)) {
1250 # Before dfe9444ca7881e71, Configure would refuse to run if stdin was
1251 # not a tty. With that commit, the tty requirement was dropped for -de
1253 # Commit aaeb8e512e8e9e14 dropped the tty requirement for -S
1254 # For those older versions, it's probably easiest if we simply remove
1256 edit_file('Configure', sub {
1258 $code =~ s/test ! -t 0/test Perl = rules/;
1263 if ($major == 8 || $major == 9) {
1264 # Fix symbol detection to that of commit 373dfab3839ca168 if it's any
1265 # intermediate version 5129fff43c4fe08c or later, as the intermediate
1266 # versions don't work correctly on (at least) Sparc Linux.
1267 # 5129fff43c4fe08c adds the first mention of mistrustnm.
1268 # 373dfab3839ca168 removes the last mention of lc=""
1269 edit_file('Configure', sub {
1272 if $code !~ /\btc="";/; # 373dfab3839ca168 or later
1274 if $code !~ /\bmistrustnm\b/; # before 5129fff43c4fe08c
1275 my $fixed = <<'EOC';
1277 : is a C symbol defined?
1280 -v) tf=libc.tmp; tdc="";;
1281 -a) tf=libc.tmp; tdc="[]";;
1282 *) tlook="^$1\$"; tf=libc.list; tdc="()";;
1285 case "$reuseval-$4" in
1287 true-*) tx=no; eval "tval=\$$4"; case "$tval" in "") tx=yes;; esac;;
1292 if $test "$runnm" = true; then
1293 if $contains $tlook $tf >/dev/null 2>&1; then
1295 elif $test "$mistrustnm" = compile -o "$mistrustnm" = run; then
1296 echo "void *(*(p()))$tdc { extern void *$1$tdc; return &$1; } int main() { if(p()) return(0); else return(1); }"> try.c;
1297 $cc -o try $optimize $ccflags $ldflags try.c >/dev/null 2>&1 $libs && tval=true;
1298 $test "$mistrustnm" = run -a -x try && { $run ./try$_exe >/dev/null 2>&1 || tval=false; };
1299 $rm -f try$_exe try.c core core.* try.core;
1302 echo "void *(*(p()))$tdc { extern void *$1$tdc; return &$1; } int main() { if(p()) return(0); else return(1); }"> try.c;
1303 $cc -o try $optimize $ccflags $ldflags try.c $libs >/dev/null 2>&1 && tval=true;
1304 $rm -f try$_exe try.c;
1309 $define) tval=true;;
1317 $code =~ s/\n: is a C symbol defined\?\n.*?\neval "\$2=\$tval"'\n\n/$fixed/sm
1318 or die "substitution failed";
1324 && extract_from_file('Configure', qr/^set malloc\.h i_malloc$/)) {
1325 # This is commit 01d07975f7ef0e7d, trimmed, with $compile inlined as
1326 # prior to bd9b35c97ad661cc Configure had the malloc.h test before the
1327 # definition of $compile.
1328 apply_patch(<<'EOPATCH');
1329 diff --git a/Configure b/Configure
1330 index 3d2e8b9..6ce7766 100755
1333 @@ -6743,5 +6743,22 @@ set d_dosuid
1335 : see if this is a malloc.h system
1336 -set malloc.h i_malloc
1338 +: we want a real compile instead of Inhdr because some systems have a
1339 +: malloc.h that just gives a compile error saying to use stdlib.h instead
1342 +#include <stdlib.h>
1343 +#include <malloc.h>
1344 +int main () { return 0; }
1347 +if $cc $optimize $ccflags $ldflags -o try $* try.c $libs > /dev/null 2>&1; then
1348 + echo "<malloc.h> found." >&4
1351 + echo "<malloc.h> NOT found." >&4
1363 if ($^O eq 'freebsd') {
1364 # There are rather too many version-specific FreeBSD hints fixes to
1365 # patch individually. Also, more than once the FreeBSD hints file has
1366 # been written in what turned out to be a rather non-future-proof style,
1367 # with case statements treating the most recent version as the
1368 # exception, instead of treating previous versions' behaviour explicitly
1369 # and changing the default to cater for the current behaviour. (As
1370 # strangely, future versions inherit the current behaviour.)
1371 checkout_file('hints/freebsd.sh');
1372 } elsif ($^O eq 'darwin') {
1374 # We can't build on darwin without some of the data in the hints
1375 # file. Probably less surprising to use the earliest version of
1376 # hints/darwin.sh and then edit in place just below, than use
1377 # blead's version, as that would create a discontinuity at
1378 # f556e5b971932902 - before it, hints bugs would be "fixed", after
1379 # it they'd resurface. This way, we should give the illusion of
1380 # monotonic bug fixing.
1382 if (!-f 'hints/darwin.sh') {
1383 checkout_file('hints/darwin.sh', 'f556e5b971932902');
1387 edit_file('hints/darwin.sh', sub {
1389 # Part of commit 8f4f83badb7d1ba9, which mostly undoes
1390 # commit 0511a818910f476c.
1391 $code =~ s/^cppflags='-traditional-cpp';$/cppflags="\${cppflags} -no-cpp-precomp"/m;
1392 # commit 14c11978e9b52e08/803bb6cc74d36a3f
1393 # Without this, code in libperl.bundle links against op.o
1394 # in preference to opmini.o on the linker command line,
1395 # and hence miniperl tries to use File::Glob instead of
1397 $code =~ s/^(lddlflags=)/ldflags="\${ldflags} -flat_namespace"\n$1/m;
1398 # f556e5b971932902 also patches Makefile.SH with some
1399 # special case code to deal with useshrplib for darwin.
1400 # Given that post 5.8.0 the darwin hints default was
1401 # changed to false, and it would be very complex to splice
1402 # in that code in various versions of Makefile.SH back
1403 # to 5.002, lets just turn it off.
1404 $code =~ s/^useshrplib='true'/useshrplib='false'/m
1409 } elsif ($^O eq 'netbsd') {
1411 # These are part of commit 099685bc64c7dbce
1412 edit_file('hints/netbsd.sh', sub {
1414 my $fixed = <<'EOC';
1420 if [ -f /usr/libexec/ld.elf_so ]; then
1423 ccdlflags="-Wl,-E -Wl,-R${PREFIX}/lib $ccdlflags"
1424 cccdlflags="-DPIC -fPIC $cccdlflags"
1425 lddlflags="--whole-archive -shared $lddlflags"
1426 elif [ "`uname -m`" = "pmax" ]; then
1427 # NetBSD 1.3 and 1.3.1 on pmax shipped an 'old' ld.so, which will not work.
1429 elif [ -f /usr/libexec/ld.so ]; then
1432 ccdlflags="-Wl,-R${PREFIX}/lib $ccdlflags"
1433 # we use -fPIC here because -fpic is *NOT* enough for some of the
1434 # extensions like Tk on some netbsd platforms (the sparc is one)
1435 cccdlflags="-DPIC -fPIC $cccdlflags"
1436 lddlflags="-Bforcearchive -Bshareable $lddlflags"
1443 $code =~ s/^case "\$osvers" in\n0\.9\|0\.8.*?^esac\n/$fixed/ms;
1447 } elsif ($^O eq 'openbsd') {
1449 checkout_file('hints/openbsd.sh', '43051805d53a3e4c')
1450 unless -f 'hints/openbsd.sh';
1451 my $which = extract_from_file('hints/openbsd.sh',
1452 qr/# from (2\.8|3\.1) onwards/,
1455 my $was = extract_from_file('hints/openbsd.sh',
1456 qr/(lddlflags="(?:-Bforcearchive )?-Bshareable)/);
1457 # This is commit 154d43cbcf57271c and parts of 5c75dbfa77b0949c
1458 # and 29b5585702e5e025
1459 apply_patch(sprintf <<'EOPATCH', $was);
1460 diff --git a/hints/openbsd.sh b/hints/openbsd.sh
1461 index a7d8bf2..5b79709 100644
1462 --- a/hints/openbsd.sh
1463 +++ b/hints/openbsd.sh
1464 @@ -37,7 +37,25 @@ OpenBSD.alpha|OpenBSD.mips|OpenBSD.powerpc|OpenBSD.vax)
1465 # we use -fPIC here because -fpic is *NOT* enough for some of the
1466 # extensions like Tk on some OpenBSD platforms (ie: sparc)
1467 cccdlflags="-DPIC -fPIC $cccdlflags"
1470 + [01].*|2.[0-7]|2.[0-7].*)
1471 + lddlflags="-Bshareable $lddlflags"
1475 + lddlflags="-shared -fPIC $lddlflags"
1477 + *) # from 3.1 onwards
1479 + lddlflags="-shared -fPIC $lddlflags"
1480 + libswanted=`echo $libswanted | sed 's/ dl / /'`
1484 + # We need to force ld to export symbols on ELF platforms.
1485 + # Without this, dlopen() is crippled.
1486 + ELF=`${cc:-cc} -dM -E - </dev/null | grep __ELF__`
1487 + test -n "$ELF" && ldflags="-Wl,-E $ldflags"
1492 } elsif ($which eq '2.8') {
1493 # This is parts of 5c75dbfa77b0949c and 29b5585702e5e025, and
1494 # possibly eb9cd59d45ad2908
1495 my $was = extract_from_file('hints/openbsd.sh',
1496 qr/lddlflags="(-shared(?: -fPIC)?) \$lddlflags"/);
1498 apply_patch(sprintf <<'EOPATCH', $was);
1499 --- a/hints/openbsd.sh 2011-10-21 17:25:20.000000000 +0200
1500 +++ b/hints/openbsd.sh 2011-10-21 16:58:43.000000000 +0200
1502 [01].*|2.[0-7]|2.[0-7].*)
1503 lddlflags="-Bshareable $lddlflags"
1505 - *) # from 2.8 onwards
1508 - lddlflags="%s $lddlflags"
1509 + lddlflags="-shared -fPIC $lddlflags"
1511 + *) # from 3.1 onwards
1513 + lddlflags="-shared -fPIC $lddlflags"
1514 + libswanted=`echo $libswanted | sed 's/ dl / /'`
1518 + # We need to force ld to export symbols on ELF platforms.
1519 + # Without this, dlopen() is crippled.
1520 + ELF=`${cc:-cc} -dM -E - </dev/null | grep __ELF__`
1521 + test -n "$ELF" && ldflags="-Wl,-E $ldflags"
1526 } elsif ($which eq '3.1'
1527 && !extract_from_file('hints/openbsd.sh',
1528 qr/We need to force ld to export symbols on ELF platforms/)) {
1529 # This is part of 29b5585702e5e025
1530 apply_patch(<<'EOPATCH');
1531 diff --git a/hints/openbsd.sh b/hints/openbsd.sh
1532 index c6b6bc9..4839d04 100644
1533 --- a/hints/openbsd.sh
1534 +++ b/hints/openbsd.sh
1535 @@ -54,6 +54,11 @@ alpha-2.[0-8]|mips-*|vax-*|powerpc-2.[0-7]|m88k-*)
1536 libswanted=`echo $libswanted | sed 's/ dl / /'`
1540 + # We need to force ld to export symbols on ELF platforms.
1541 + # Without this, dlopen() is crippled.
1542 + ELF=`${cc:-cc} -dM -E - </dev/null | grep __ELF__`
1543 + test -n "$ELF" && ldflags="-Wl,-E $ldflags"
1550 } elsif ($^O eq 'linux') {
1552 # sparc linux seems to need the -Dbool=char -DHAS_BOOL part of
1553 # perl5.000 patch.0n: [address Configure and build issues]
1554 edit_file('hints/linux.sh', sub {
1556 $code =~ s!-I/usr/include/bsd!-Dbool=char -DHAS_BOOL!g;
1562 if (`uname -sm` =~ qr/^Linux sparc/) {
1563 if (extract_from_file('hints/linux.sh', qr/sparc-linux/)) {
1564 # Be sure to use -fPIC not -fpic on Linux/SPARC
1565 apply_commit('f6527d0ef0c13ad4');
1566 } elsif(!extract_from_file('hints/linux.sh',
1567 qr/^sparc-linux\)$/)) {
1568 my $fh = open_or_die('hints/linux.sh', '>>');
1569 print $fh <<'EOT' or die $!;
1571 case "`uname -m`" in
1573 case "$cccdlflags" in
1574 *-fpic*) cccdlflags="`echo $cccdlflags|sed 's/-fpic/-fPIC/'`" ;;
1575 *) cccdlflags="$cccdlflags -fPIC" ;;
1588 # Cwd.xs added in commit 0d2079faa739aaa9. Cwd.pm moved to ext/ 8 years
1589 # later in commit 403f501d5b37ebf0
1590 if ($major > 0 && <*/Cwd/Cwd.xs>) {
1592 && !extract_from_file('Makefile.SH', qr/^extra_dep=''$/)) {
1593 # The Makefile.PL for Unicode::Normalize needs
1594 # lib/unicore/CombiningClass.pl. Even without a parallel build, we
1595 # need a dependency to ensure that it builds. This is a variant of
1596 # commit 9f3ef600c170f61e. Putting this for earlier versions gives
1597 # us a spot on which to hang the edits below
1598 apply_patch(<<'EOPATCH');
1599 diff --git a/Makefile.SH b/Makefile.SH
1600 index f61d0db..6097954 100644
1603 @@ -155,10 +155,20 @@ esac
1605 : Prepare dependency lists for Makefile.
1608 for f in $dynamic_ext; do
1609 : the dependency named here will never exist
1610 base=`echo "$f" | sed 's/.*\///'`
1611 - dynamic_list="$dynamic_list lib/auto/$f/$base.$dlext"
1612 + this_target="lib/auto/$f/$base.$dlext"
1613 + dynamic_list="$dynamic_list $this_target"
1615 + : Parallel makes reveal that we have some interdependencies
1617 + Math/BigInt/FastCalc) extra_dep="$extra_dep
1618 +$this_target: lib/auto/List/Util/Util.$dlext" ;;
1619 + Unicode/Normalize) extra_dep="$extra_dep
1620 +$this_target: lib/unicore/CombiningClass.pl" ;;
1625 @@ -987,2 +997,9 @@ n_dummy $(nonxs_ext): miniperl$(EXE_EXT) preplibrary $(DYNALOADER) FORCE
1626 @$(LDLIBPTH) sh ext/util/make_ext nonxs $@ MAKE=$(MAKE) LIBPERL_A=$(LIBPERL)
1629 +$spitshell >>Makefile <<EOF
1633 +$spitshell >>Makefile <<'!NO!SUBS!'
1639 if (extract_from_file('patchlevel.h',
1640 qr/^#include "unpushed\.h"/)) {
1641 # I had thought it easier to detect when building one of the 52
1642 # commits with the original method of incorporating the git
1643 # revision and drop parallel make flags. Commits shown by
1644 # git log 46807d8e809cc127^..dcff826f70bf3f64^ ^d4fb0a1f15d1a1c4
1645 # However, it's not actually possible to make miniperl for that
1646 # configuration as-is, because the file .patchnum is only made
1647 # as a side effect of target 'all'
1648 # I also don't think that it's "safe" to simply run
1649 # make_patchnum.sh before the build. We need the proper
1650 # dependency rules in the Makefile to *stop* it being run again
1651 # at the wrong time.
1652 # This range is important because contains the commit that
1653 # merges Schwern's y2038 work.
1654 apply_patch(<<'EOPATCH');
1655 diff --git a/Makefile.SH b/Makefile.SH
1656 index 9ad8b6f..106e721 100644
1659 @@ -540,9 +544,14 @@ sperl.i: perl.c $(h)
1661 .PHONY: all translators utilities make_patchnum
1664 +make_patchnum: lib/Config_git.pl
1666 +lib/Config_git.pl: make_patchnum.sh
1667 sh $(shellflags) make_patchnum.sh
1669 +# .patchnum, unpushed.h and lib/Config_git.pl are built by make_patchnum.sh
1670 +unpushed.h .patchnum: lib/Config_git.pl
1672 # make sure that we recompile perl.c if .patchnum changes
1673 perl$(OBJ_EXT): .patchnum unpushed.h
1676 } elsif (-f '.gitignore'
1677 && extract_from_file('.gitignore', qr/^\.patchnum$/)) {
1678 # 8565263ab8a47cda to 46807d8e809cc127^ inclusive.
1679 edit_file('Makefile.SH', sub {
1681 $code =~ s/^make_patchnum:\n/make_patchnum: .patchnum
1685 .patchnum: make_patchnum.sh
1689 } elsif (-f 'lib/.gitignore'
1690 && extract_from_file('lib/.gitignore',
1691 qr!^/Config_git.pl!)
1692 && !extract_from_file('Makefile.SH',
1693 qr/^uudmap\.h.*:bitcount.h$/)) {
1694 # Between commits and dcff826f70bf3f64 and 0f13ebd5d71f8177^
1695 edit_file('Makefile.SH', sub {
1697 # Bug introduced by 344af494c35a9f0f
1698 # fixed in 0f13ebd5d71f8177
1699 $code =~ s{^(pod/perlapi\.pod) (pod/perlintern\.pod): }
1701 # Bug introduced by efa50c51e3301a2c
1702 # fixed in 0f13ebd5d71f8177
1703 $code =~ s{^(uudmap\.h) (bitcount\.h): }
1706 # The rats nest of getting git_version.h correct
1708 if ($code =~ s{git_version\.h: stock_git_version\.h
1709 \tcp stock_git_version\.h git_version\.h}
1711 # before 486cd780047ff224
1713 # We probably can't build between
1714 # 953f6acfa20ec275^ and 8565263ab8a47cda
1715 # inclusive, but all commits in that range
1716 # relate to getting make_patchnum.sh working,
1717 # so it is extremely unlikely to be an
1718 # interesting bisect target. They will skip.
1720 # No, don't spawn a submake if
1721 # make_patchnum.sh or make_patchnum.pl fails
1722 $code =~ s{\|\| \$\(MAKE\) miniperl.*}
1724 $code =~ s{^\t(sh.*make_patchnum\.sh.*)}
1727 # Use an external perl to run make_patchnum.pl
1728 # because miniperl still depends on
1730 $code =~ s{^\t.*make_patchnum\.pl}
1731 {\t-$^X make_patchnum.pl}m;
1734 # "Truth in advertising" - running
1735 # make_patchnum generates 2 files.
1736 $code =~ s{^make_patchnum:.*}{
1737 make_patchnum: lib/Config_git.pl
1739 git_version.h: lib/Config_git.pl
1741 perlmini\$(OBJ_EXT): git_version.h
1743 lib/Config_git.pl:}m;
1745 # Right, now we've corrected Makefile.SH to
1746 # correctly describe how lib/Config_git.pl and
1747 # git_version.h are made, we need to fix the rest
1749 # This emulates commit 2b63e250843b907e
1750 # This might duplicate the rule stating that
1751 # git_version.h depends on lib/Config_git.pl
1753 $code =~ s{^(?:lib/Config_git\.pl )?git_version\.h: (.* make_patchnum\.pl.*)}
1754 {git_version.h: lib/Config_git.pl
1756 lib/Config_git.pl: $1}m;
1758 # This emulates commits 0f13ebd5d71f8177 and
1759 # and a04d4598adc57886. It ensures that
1760 # lib/Config_git.pl is built before configpm,
1761 # and that configpm is run exactly once.
1762 $code =~ s{^(\$\(.*?\) )?(\$\(CONFIGPOD\))(: .*? configpm Porting/Glossary)( lib/Config_git\.pl)?}{
1763 # If present, other files depend on $(CONFIGPOD)
1764 ($1 ? "$1: $2\n\n" : '')
1765 # Then the rule we found
1767 # Add dependency if not there
1768 . ($4 ? $4 : ' lib/Config_git.pl')
1777 # Commits dc0655f797469c47 and d11a62fe01f2ecb2
1778 edit_file('Makefile.SH', sub {
1780 foreach my $ext (qw(Encode SDBM_File)) {
1781 next if $code =~ /\b$ext\) extra_dep=/s;
1782 $code =~ s!(\) extra_dep="\$extra_dep
1783 \$this_target: .*?" ;;)
1786 $ext) extra_dep="\$extra_dep
1787 \$this_target: lib/auto/Cwd/Cwd.\$dlext" ;;
1796 # Remove commits 9fec149bb652b6e9 and 5bab1179608f81d8, which add/amend
1797 # rules to automatically run regen scripts that rebuild C headers. These
1798 # cause problems because a git checkout doesn't preserve relative file
1799 # modification times, hence the regen scripts may fire. This will
1800 # obscure whether the repository had the correct generated headers
1802 # Also, the dependency rules for running the scripts were not correct,
1803 # which could cause spurious re-builds on re-running make, and can cause
1804 # complete build failures for a parallel make.
1805 if (extract_from_file('Makefile.SH',
1806 qr/Writing it this way gives make a big hint to always run opcode\.pl before/)) {
1807 apply_commit('70c6e6715e8fec53');
1808 } elsif (extract_from_file('Makefile.SH',
1809 qr/^opcode\.h opnames\.h pp_proto\.h pp\.sym: opcode\.pl$/)) {
1810 revert_commit('9fec149bb652b6e9');
1814 # There was a bug in makedepend.SH which was fixed in version 96a8704c.
1815 # Symptom was './makedepend: 1: Syntax error: Unterminated quoted string'
1816 # Remove this if you're actually bisecting a problem related to
1818 # If you do this, you may need to add in code to correct the output of older
1819 # makedepends, which don't correctly filter newer gcc output such as
1821 checkout_file('makedepend.SH');
1823 if ($major < 4 && -f 'config.sh'
1824 && !extract_from_file('config.sh', qr/^trnl=/)) {
1825 # This seems to be necessary to avoid makedepend becoming confused,
1826 # and hanging on stdin. Seems that the code after
1827 # make shlist || ...here... is never run.
1828 edit_file('makedepend.SH', sub {
1830 $code =~ s/^trnl='\$trnl'$/trnl='\\n'/m;
1837 # This is ordered by $major, as it's likely that different platforms may
1838 # well want to share code.
1840 if ($major == 2 && extract_from_file('perl.c', qr/^\tfclose\(e_fp\);$/)) {
1841 # need to patch perl.c to avoid calling fclose() twice on e_fp when
1843 # This diff is part of commit ab821d7fdc14a438. The second close was
1844 # introduced with perl-5.002, commit a5f75d667838e8e7
1845 # Might want a6c477ed8d4864e6 too, for the corresponding change to
1846 # pp_ctl.c (likely without this, eval will have "fun")
1847 apply_patch(<<'EOPATCH');
1848 diff --git a/perl.c b/perl.c
1849 index 03c4d48..3c814a2 100644
1852 @@ -252,6 +252,7 @@ setuid perl scripts securely.\n");
1853 #ifndef VMS /* VMS doesn't have environ array */
1854 origenviron = environ;
1856 + e_tmpname = Nullch;
1860 @@ -405,6 +406,7 @@ setuid perl scripts securely.\n");
1862 if (Fflush(e_fp) || ferror(e_fp) || fclose(e_fp))
1863 croak("Can't write to temp file for -e: %s", Strerror(errno));
1866 scriptname = e_tmpname;
1868 @@ -470,10 +472,10 @@ setuid perl scripts securely.\n");
1869 curcop->cop_line = 0;
1870 curstash = defstash;
1876 (void)UNLINK(e_tmpname);
1877 + Safefree(e_tmpname);
1878 + e_tmpname = Nullch;
1881 /* now that script is parsed, we can modify record separator */
1882 @@ -1369,7 +1371,7 @@ SV *sv;
1883 scriptname = xfound;
1886 - origfilename = savepv(e_fp ? "-e" : scriptname);
1887 + origfilename = savepv(e_tmpname ? "-e" : scriptname);
1888 curcop->cop_filegv = gv_fetchfile(origfilename);
1889 if (strEQ(origfilename,"-"))
1895 if ($major < 3 && $^O eq 'openbsd'
1896 && !extract_from_file('pp_sys.c', qr/BSD_GETPGRP/)) {
1897 # Part of commit c3293030fd1b7489
1898 apply_patch(<<'EOPATCH');
1899 diff --git a/pp_sys.c b/pp_sys.c
1900 index 4608a2a..f0c9d1d 100644
1903 @@ -2903,8 +2903,8 @@ PP(pp_getpgrp)
1908 - value = (I32)getpgrp(pid);
1910 + value = (I32)BSD_GETPGRP(pid);
1913 DIE("POSIX getpgrp can't take an argument");
1914 @@ -2933,8 +2933,8 @@ PP(pp_setpgrp)
1917 TAINT_PROPER("setpgrp");
1919 - SETi( setpgrp(pid, pgrp) >= 0 );
1921 + SETi( BSD_SETPGRP(pid, pgrp) >= 0 );
1923 if ((pgrp != 0) || (pid != 0)) {
1924 DIE("POSIX setpgrp can't take an argument");
1928 if ($major < 4 && $^O eq 'openbsd') {
1930 # Need changes from commit a6e633defa583ad5.
1931 # Commits c07a80fdfe3926b5 and f82b3d4130164d5f changed the same part
1934 if (extract_from_file('perl.h',
1935 qr/^#ifdef HAS_GETPGRP2$/)) {
1939 #define TAINT_PROPER(s) if (tainting) taint_proper(no_security, s)
1940 #define TAINT_ENV() if (tainting) taint_env()
1942 ! #ifdef HAS_GETPGRP2
1943 ! # ifndef HAS_GETPGRP
1944 ! # define HAS_GETPGRP
1948 ! #ifdef HAS_SETPGRP2
1949 ! # ifndef HAS_SETPGRP
1950 ! # define HAS_SETPGRP
1955 } elsif (extract_from_file('perl.h',
1956 qr/Gack, you have one but not both of getpgrp2/)) {
1960 #define TAINT_PROPER(s) if (tainting) taint_proper(no_security, s)
1961 #define TAINT_ENV() if (tainting) taint_env()
1963 ! #if defined(HAS_GETPGRP2) && defined(HAS_SETPGRP2)
1964 ! # define getpgrp getpgrp2
1965 ! # define setpgrp setpgrp2
1966 ! # ifndef HAS_GETPGRP
1967 ! # define HAS_GETPGRP
1969 ! # ifndef HAS_SETPGRP
1970 ! # define HAS_SETPGRP
1972 ! # ifndef USE_BSDPGRP
1973 ! # define USE_BSDPGRP
1976 ! # if defined(HAS_GETPGRP2) || defined(HAS_SETPGRP2)
1977 ! #include "Gack, you have one but not both of getpgrp2() and setpgrp2()."
1982 } elsif (extract_from_file('perl.h',
1983 qr/^#ifdef USE_BSDPGRP$/)) {
1987 #define TAINT_PROPER(s) if (tainting) taint_proper(no_security, s)
1988 #define TAINT_ENV() if (tainting) taint_env()
1990 ! #ifdef USE_BSDPGRP
1991 ! # ifdef HAS_GETPGRP
1992 ! # define BSD_GETPGRP(pid) getpgrp((pid))
1994 ! # ifdef HAS_SETPGRP
1995 ! # define BSD_SETPGRP(pid, pgrp) setpgrp((pid), (pgrp))
1998 ! # ifdef HAS_GETPGRP2
1999 ! # define BSD_GETPGRP(pid) getpgrp2((pid))
2000 ! # ifndef HAS_GETPGRP
2001 ! # define HAS_GETPGRP
2004 ! # ifdef HAS_SETPGRP2
2005 ! # define BSD_SETPGRP(pid, pgrp) setpgrp2((pid), (pgrp))
2006 ! # ifndef HAS_SETPGRP
2007 ! # define HAS_SETPGRP
2012 #ifndef _TYPES_ /* If types.h defines this it's easy. */
2016 apply_patch(<<"EOPATCH");
2017 *** a/perl.h 2011-10-21 09:46:12.000000000 +0200
2018 --- b/perl.h 2011-10-21 09:46:12.000000000 +0200
2020 #define TAINT_PROPER(s) if (tainting) taint_proper(no_security, s)
2021 #define TAINT_ENV() if (tainting) taint_env()
2023 ! /* XXX All process group stuff is handled in pp_sys.c. Should these
2024 ! defines move there? If so, I could simplify this a lot. --AD 9/96.
2026 ! /* Process group stuff changed from traditional BSD to POSIX.
2027 ! perlfunc.pod documents the traditional BSD-style syntax, so we'll
2028 ! try to preserve that, if possible.
2030 ! #ifdef HAS_SETPGID
2031 ! # define BSD_SETPGRP(pid, pgrp) setpgid((pid), (pgrp))
2033 ! # if defined(HAS_SETPGRP) && defined(USE_BSD_SETPGRP)
2034 ! # define BSD_SETPGRP(pid, pgrp) setpgrp((pid), (pgrp))
2036 ! # ifdef HAS_SETPGRP2 /* DG/UX */
2037 ! # define BSD_SETPGRP(pid, pgrp) setpgrp2((pid), (pgrp))
2041 ! #if defined(BSD_SETPGRP) && !defined(HAS_SETPGRP)
2042 ! # define HAS_SETPGRP /* Well, effectively it does . . . */
2045 ! /* getpgid isn't POSIX, but at least Solaris and Linux have it, and it makes
2046 ! our life easier :-) so we'll try it.
2048 ! #ifdef HAS_GETPGID
2049 ! # define BSD_GETPGRP(pid) getpgid((pid))
2051 ! # if defined(HAS_GETPGRP) && defined(USE_BSD_GETPGRP)
2052 ! # define BSD_GETPGRP(pid) getpgrp((pid))
2054 ! # ifdef HAS_GETPGRP2 /* DG/UX */
2055 ! # define BSD_GETPGRP(pid) getpgrp2((pid))
2059 ! #if defined(BSD_GETPGRP) && !defined(HAS_GETPGRP)
2060 ! # define HAS_GETPGRP /* Well, effectively it does . . . */
2063 ! /* These are not exact synonyms, since setpgrp() and getpgrp() may
2064 ! have different behaviors, but perl.h used to define USE_BSDPGRP
2065 ! (prior to 5.003_05) so some extension might depend on it.
2067 ! #if defined(USE_BSD_SETPGRP) || defined(USE_BSD_GETPGRP)
2068 ! # ifndef USE_BSDPGRP
2069 ! # define USE_BSDPGRP
2073 #ifndef _TYPES_ /* If types.h defines this it's easy. */
2078 if ($major == 4 && extract_from_file('scope.c', qr/\(SV\*\)SSPOPINT/)) {
2079 # [PATCH] 5.004_04 +MAINT_TRIAL_1 broken when sizeof(int) != sizeof(void)
2080 # Fixes a bug introduced in 161b7d1635bc830b
2081 apply_commit('9002cb76ec83ef7f');
2084 if ($major == 4 && extract_from_file('av.c', qr/AvARRAY\(av\) = 0;/)) {
2085 # Fixes a bug introduced in 1393e20655efb4bc
2086 apply_commit('e1c148c28bf3335b', 'av.c');
2090 my $rest = extract_from_file('perl.c', qr/delimcpy(.*)/);
2091 if (defined $rest and $rest !~ /,$/) {
2092 # delimcpy added in fc36a67e8855d031, perl.c refactored to use it.
2093 # bug introduced in 2a92aaa05aa1acbf, fixed in 8490252049bf42d3
2094 # code then moved to util.c in commit 491527d0220de34e
2095 apply_patch(<<'EOPATCH');
2096 diff --git a/perl.c b/perl.c
2097 index 4eb69e3..54bbb00 100644
2100 @@ -1735,7 +1735,7 @@ SV *sv;
2101 if (len < sizeof tokenbuf)
2102 tokenbuf[len] = '\0';
2103 #else /* ! (atarist || DOSISH) */
2104 - s = delimcpy(tokenbuf, tokenbuf + sizeof tokenbuf, s, bufend
2105 + s = delimcpy(tokenbuf, tokenbuf + sizeof tokenbuf, s, bufend,
2108 #endif /* ! (atarist || DOSISH) */
2113 if ($major == 4 && $^O eq 'linux') {
2114 # Whilst this is fixed properly in f0784f6a4c3e45e1 which provides the
2115 # Configure probe, it's easier to back out the problematic changes made
2116 # in these previous commits:
2117 if (extract_from_file('doio.c',
2118 qr!^/\* XXX REALLY need metaconfig test \*/$!)) {
2119 revert_commit('4682965a1447ea44', 'doio.c');
2121 if (my $token = extract_from_file('doio.c',
2122 qr!^#if (defined\(__sun(?:__)?\)) && defined\(__svr4__\) /\* XXX Need metaconfig test \*/$!)) {
2123 my $patch = `git show -R 9b599b2a63d2324d doio.c`;
2124 $patch =~ s/defined\(__sun__\)/$token/g;
2125 apply_patch($patch);
2127 if (extract_from_file('doio.c',
2128 qr!^/\* linux \(and Solaris2\?\) uses :$!)) {
2129 revert_commit('8490252049bf42d3', 'doio.c');
2131 if (extract_from_file('doio.c',
2132 qr/^ unsemds.buf = &semds;$/)) {
2133 revert_commit('8e591e46b4c6543e');
2135 if (extract_from_file('doio.c',
2136 qr!^#ifdef __linux__ /\* XXX Need metaconfig test \*/$!)) {
2137 # Reverts part of commit 3e3baf6d63945cb6
2138 apply_patch(<<'EOPATCH');
2139 diff --git b/doio.c a/doio.c
2140 index 62b7de9..0d57425 100644
2143 @@ -1333,9 +1331,6 @@ SV **sp;
2145 I32 id, n, cmd, infosize, getinfo;
2147 -#ifdef __linux__ /* XXX Need metaconfig test */
2148 - union semun unsemds;
2151 id = SvIVx(*++mark);
2152 n = (optype == OP_SEMCTL) ? SvIVx(*++mark) : 0;
2153 @@ -1364,29 +1359,11 @@ SV **sp;
2154 infosize = sizeof(struct semid_ds);
2155 else if (cmd == GETALL || cmd == SETALL)
2157 -#ifdef __linux__ /* XXX Need metaconfig test */
2159 - int semctl (int semid, int semnun, int cmd, union semun arg)
2163 - struct semid_ds *buf;
2167 - union semun semds;
2168 - if (semctl(id, 0, IPC_STAT, semds) == -1)
2170 struct semid_ds semds;
2171 if (semctl(id, 0, IPC_STAT, &semds) == -1)
2174 getinfo = (cmd == GETALL);
2175 -#ifdef __linux__ /* XXX Need metaconfig test */
2176 - infosize = semds.buf->sem_nsems * sizeof(short);
2178 infosize = semds.sem_nsems * sizeof(short);
2180 /* "short" is technically wrong but much more portable
2181 than guessing about u_?short(_t)? */
2183 @@ -1429,12 +1406,7 @@ SV **sp;
2187 -#ifdef __linux__ /* XXX Need metaconfig test */
2188 - unsemds.buf = (struct semid_ds *)a;
2189 - ret = semctl(id, n, cmd, unsemds);
2191 ret = semctl(id, n, cmd, (struct semid_ds *)a);
2198 # Incorrect prototype added as part of 8ac853655d9b7447, fixed as part
2199 # of commit dc45a647708b6c54, with at least one intermediate
2200 # modification. Correct prototype for gethostbyaddr has socklen_t
2201 # second. Linux has uint32_t first for getnetbyaddr.
2202 # Easiest just to remove, instead of attempting more complex patching.
2203 # Something similar may be needed on other platforms.
2204 edit_file('pp_sys.c', sub {
2206 $code =~ s/^ struct hostent \*(?:PerlSock_)?gethostbyaddr\([^)]+\);$//m;
2207 $code =~ s/^ struct netent \*getnetbyaddr\([^)]+\);$//m;
2212 if ($major < 6 && $^O eq 'netbsd'
2213 && !extract_from_file('unixish.h',
2214 qr/defined\(NSIG\).*defined\(__NetBSD__\)/)) {
2215 apply_patch(<<'EOPATCH')
2216 diff --git a/unixish.h b/unixish.h
2217 index 2a6cbcd..eab2de1 100644
2222 /* #define ALTERNATE_SHEBANG "#!" / **/
2224 -#if !defined(NSIG) || defined(M_UNIX) || defined(M_XENIX)
2225 +#if !defined(NSIG) || defined(M_UNIX) || defined(M_XENIX) || defined(__NetBSD__)
2226 # include <signal.h>
2232 if (($major >= 7 || $major <= 9) && $^O eq 'openbsd'
2233 && `uname -m` eq "sparc64\n"
2234 # added in 2000 by commit cb434fcc98ac25f5:
2235 && extract_from_file('regexec.c',
2236 qr!/\* No need to save/restore up to this paren \*/!)
2237 # re-indented in 2006 by commit 95b2444054382532:
2238 && extract_from_file('regexec.c', qr/^\t\tCURCUR cc;$/)) {
2239 # Need to work around a bug in (at least) OpenBSD's 4.6's sparc64 #
2240 # compiler ["gcc (GCC) 3.3.5 (propolice)"]. Between commits
2241 # 3ec562b0bffb8b8b (2002) and 1a4fad37125bac3e^ (2005) the darling thing
2242 # fails to compile any code for the statement cc.oldcc = PL_regcc;
2244 # If you refactor the code to "fix" that, or force the issue using set
2245 # in the debugger, the stack smashing detection code fires on return
2246 # from S_regmatch(). Turns out that the compiler doesn't allocate any
2247 # (or at least enough) space for cc.
2249 # Restore the "uninitialised" value for cc before function exit, and the
2250 # stack smashing code is placated. "Fix" 3ec562b0bffb8b8b (which
2251 # changes the size of auto variables used elsewhere in S_regmatch), and
2252 # the crash is visible back to bc517b45fdfb539b (which also changes
2253 # buffer sizes). "Unfix" 1a4fad37125bac3e and the crash is visible until
2254 # 5b47454deb66294b. Problem goes away if you compile with -O, or hack
2255 # the code as below.
2257 # Hence this turns out to be a bug in (old) gcc. Not a security bug we
2258 # still need to fix.
2259 apply_patch(<<'EOPATCH');
2260 diff --git a/regexec.c b/regexec.c
2261 index 900b491..6251a0b 100644
2264 @@ -2958,7 +2958,11 @@ S_regmatch(pTHX_ regnode *prog)
2266 *******************************************************************/
2271 + char hack_buff[sizeof(CURCUR) + 1];
2273 +#define cc hack.hack_cc
2274 CHECKPOINT cp = PL_savestack_ix;
2275 /* No need to save/restore up to this paren */
2276 I32 parenfloor = scan->flags;
2277 @@ -2983,6 +2987,7 @@ S_regmatch(pTHX_ regnode *prog)
2278 n = regmatch(PREVOPER(next)); /* start on the WHILEM */
2280 PL_regcc = cc.oldcc;
2288 if ($major < 8 && $^O eq 'openbsd'
2289 && !extract_from_file('perl.h', qr/include <unistd\.h>/)) {
2290 # This is part of commit 3f270f98f9305540, applied at a slightly
2291 # different location in perl.h, where the context is stable back to
2293 apply_patch(<<'EOPATCH');
2294 diff --git a/perl.h b/perl.h
2295 index 9418b52..b8b1a7c 100644
2298 @@ -496,6 +496,10 @@ register struct op *Perl_op asm(stringify(OP_IN_REGISTER));
2299 # include <sys/param.h>
2302 +/* If this causes problems, set i_unistd=undef in the hint file. */
2304 +# include <unistd.h>
2307 /* Use all the "standard" definitions? */
2308 #if defined(STANDARD_C) && defined(I_STDLIB)
2314 if (-f 'ext/POSIX/Makefile.PL'
2315 && extract_from_file('ext/POSIX/Makefile.PL',
2316 qr/Explicitly avoid including/)) {
2317 # commit 6695a346c41138df, which effectively reverts 170888cff5e2ffb7
2319 # PERL5LIB is populated by make_ext.pl with paths to the modules we need
2320 # to run, don't override this with "../../lib" since that may not have
2321 # been populated yet in a parallel build.
2322 apply_commit('6695a346c41138df');
2325 if ($major < 8 && $^O eq 'darwin' && !-f 'ext/DynaLoader/dl_dyld.xs') {
2326 checkout_file('ext/DynaLoader/dl_dyld.xs', 'f556e5b971932902');
2327 apply_patch(<<'EOPATCH');
2328 diff -u a/ext/DynaLoader/dl_dyld.xs~ a/ext/DynaLoader/dl_dyld.xs
2329 --- a/ext/DynaLoader/dl_dyld.xs~ 2011-10-11 21:41:27.000000000 +0100
2330 +++ b/ext/DynaLoader/dl_dyld.xs 2011-10-11 21:42:20.000000000 +0100
2344 +# define dTHXa(a) extern int Perl___notused(void)
2345 +# define dTHX extern int Perl___notused(void)
2348 +#ifndef Perl_form_nocontext
2349 +# define Perl_form_nocontext form
2352 +#ifndef Perl_warn_nocontext
2353 +# define Perl_warn_nocontext warn
2357 +# define PTR2IV(p) (IV)(p)
2361 +# define get_av perl_get_av
2364 #define DL_LOADONCEONLY
2366 #include "dlutils.c" /* SaveError() etc */
2369 DLDEBUG(1,PerlIO_printf(Perl_debug_log, "dl_load_file(%s,%x):\n", filename,flags));
2371 - Perl_warn(aTHX_ "Can't make loaded symbols global on this platform while loading %s",filename);
2372 + Perl_warn_nocontext("Can't make loaded symbols global on this platform while loading %s",filename);
2373 RETVAL = dlopen(filename, mode) ;
2374 DLDEBUG(2,PerlIO_printf(Perl_debug_log, " libref=%x\n", RETVAL));
2375 ST(0) = sv_newmortal() ;
2377 if ($major < 4 && !extract_from_file('util.c', qr/^form/m)) {
2378 apply_patch(<<'EOPATCH');
2379 diff -u a/ext/DynaLoader/dl_dyld.xs~ a/ext/DynaLoader/dl_dyld.xs
2380 --- a/ext/DynaLoader/dl_dyld.xs~ 2011-10-11 21:56:25.000000000 +0100
2381 +++ b/ext/DynaLoader/dl_dyld.xs 2011-10-11 22:00:00.000000000 +0100
2383 # define get_av perl_get_av
2387 +form(char *pat, ...)
2391 + va_start(args, pat);
2392 + vasprintf(&retval, pat, &args);
2394 + SAVEFREEPV(retval);
2398 #define DL_LOADONCEONLY
2400 #include "dlutils.c" /* SaveError() etc */
2406 if (!extract_from_file('ext/DB_File/DB_File.xs',
2407 qr!^#else /\* Berkeley DB Version > 2 \*/$!)) {
2408 # This DB_File.xs is really too old to patch up.
2409 # Skip DB_File, unless we're invoked with an explicit -Unoextensions
2410 if (!exists $defines{noextensions}) {
2411 $defines{noextensions} = 'DB_File';
2412 } elsif (defined $defines{noextensions}) {
2413 $defines{noextensions} .= ' DB_File';
2415 } elsif (!extract_from_file('ext/DB_File/DB_File.xs',
2416 qr/^#ifdef AT_LEAST_DB_4_1$/)) {
2417 # This line is changed by commit 3245f0580c13b3ab
2418 my $line = extract_from_file('ext/DB_File/DB_File.xs',
2419 qr/^( status = \(?RETVAL->dbp->open\)?\(RETVAL->dbp, name, NULL, RETVAL->type, $)/);
2420 apply_patch(<<"EOPATCH");
2421 diff --git a/ext/DB_File/DB_File.xs b/ext/DB_File/DB_File.xs
2422 index 489ba96..fba8ded 100644
2423 --- a/ext/DB_File/DB_File.xs
2424 +++ b/ext/DB_File/DB_File.xs
2425 \@\@ -183,4 +187,8 \@\@
2428 +#if DB_VERSION_MAJOR > 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 1)
2429 +# define AT_LEAST_DB_4_1
2432 /* map version 2 features & constants onto their version 1 equivalent */
2434 \@\@ -1334,7 +1419,12 \@\@ SV * sv ;
2437 +#ifdef AT_LEAST_DB_4_1
2438 + status = (RETVAL->dbp->open)(RETVAL->dbp, NULL, name, NULL, RETVAL->type,
2444 /* printf("open returned %d %s\\n", status, db_strerror(status)) ; */
2450 if ($major < 10 and -f 'ext/IPC/SysV/SysV.xs') {
2451 edit_file('ext/IPC/SysV/SysV.xs', sub {
2453 my $fixed = <<'EOFIX';
2455 #include <sys/types.h>
2456 #if defined(HAS_MSG) || defined(HAS_SEM) || defined(HAS_SHM)
2458 # include <sys/ipc.h>
2461 # include <sys/msg.h>
2464 # if defined(PERL_SCO) || defined(PERL_ISC)
2465 # include <sys/sysmacros.h> /* SHMLBA */
2467 # include <sys/shm.h>
2468 # ifndef HAS_SHMAT_PROTOTYPE
2469 extern Shmat_t shmat (int, char *, int);
2471 # if defined(HAS_SYSCONF) && defined(_SC_PAGESIZE)
2472 # undef SHMLBA /* not static: determined at boot time */
2473 # define SHMLBA sysconf(_SC_PAGESIZE)
2474 # elif defined(HAS_GETPAGESIZE)
2475 # undef SHMLBA /* not static: determined at boot time */
2476 # define SHMLBA getpagesize()
2482 #include <sys/types\.h>
2484 (#ifdef newCONSTSUB|/\* Required)!$fixed$1!ms;
2491 # cperl-indent-level: 4
2492 # indent-tabs-mode: nil
2495 # ex: set ts=8 sts=4 sw=4 et: