summaryrefslogtreecommitdiff
path: root/Porting
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2022-08-01 10:02:39 +0200
committerYves Orton <demerphq@gmail.com>2023-02-11 07:17:42 +0100
commitbb9871770c3dec3ad101dfff5f9a0920045221a2 (patch)
treed67c92cea696ec541a5d71872e0b4edf70a2fd76 /Porting
parent2f61c58f0a6e755f230edfd4e9a705fddd582419 (diff)
downloadperl-bb9871770c3dec3ad101dfff5f9a0920045221a2.tar.gz
bisect-runner.pl needs to use the current approach for symbol probing
The older version assumed an explicit prototype for printf(), which doesn't fly on arm64 macOS. It might not be robust on some other platforms too, whereas the "current" (ie 2003 onward) approach still works everywhere. Change edit_file() to only localise $/ to undef during the read, so that it's restored to its default ("\n") when the callback is invoked. Without this, `chomp` "doesn't work" (as expected) in the callback.
Diffstat (limited to 'Porting')
-rwxr-xr-xPorting/bisect-runner.pl42
1 files changed, 37 insertions, 5 deletions
diff --git a/Porting/bisect-runner.pl b/Porting/bisect-runner.pl
index 6062c254a0..e957976347 100755
--- a/Porting/bisect-runner.pl
+++ b/Porting/bisect-runner.pl
@@ -1333,9 +1333,11 @@ sub extract_from_file {
sub edit_file {
my ($file, $munger) = @_;
- local $/;
my $fh = open_or_die($file);
- my $orig = <$fh>;
+ my $orig = do {
+ local $/;
+ <$fh>;
+ };
die_255("Can't read $file: $!") unless defined $orig && close $fh;
my $new = $munger->($orig);
return if $new eq $orig;
@@ -2547,18 +2549,48 @@ EOPATCH
});
}
- if ($major == 8 || $major == 9) {
+ if ($major < 10) {
# Fix symbol detection to that of commit 373dfab3839ca168 if it's any
# intermediate version 5129fff43c4fe08c or later, as the intermediate
# versions don't work correctly on (at least) Sparc Linux.
# 5129fff43c4fe08c adds the first mention of mistrustnm.
# 373dfab3839ca168 removes the last mention of lc=""
+ #
+ # Fix symbol detection prior to 5129fff43c4fe08c to use the same
+ # approach, where we don't call printf without a prototype
+ # We can't include <stdio.h> to get its prototype, as the way this works
+ # is to create a (wrong) prototype for the probed functions, and those
+ # conflict if the function in question is in stdio.h.
edit_file('Configure', sub {
my $code = shift;
return $code
if $code !~ /\btc="";/; # 373dfab3839ca168 or later
- return $code
- if $code !~ /\bmistrustnm\b/; # before 5129fff43c4fe08c
+ if ($code !~ /\bmistrustnm\b/) {
+ # doing this as a '' heredoc seems to be the easiest
+ # way to avoid confusing levels of backslashes:
+ my $now = <<'EOT';
+void *(*(p()))$tdc { extern void *$1$tdc; return &$1; } int main() { if(p()) return(0); else return(1); }
+EOT
+ chomp $now;
+
+ # before 5129fff43c4fe08c
+ # befure 16d20bd98cd29be7
+ my @old = (<<'EOT', <<'EOT');
+main() { extern short $1$tdc; printf(\"%hd\", $1$tc); }
+EOT
+main() { extern int $1$tdc; printf(\"%d\", $1$tc); }
+EOT
+ for my $was (@old) {
+ chomp $was;
+ $was = quotemeta $was;
+
+ # Prior to commit d674cd6de52ff38b there was no
+ # 'int ' for 'int main'
+ $code =~ s/(?:int )?$was/$now/;
+ }
+ return $code;
+ }
+
my $fixed = <<'EOC';
: is a C symbol defined?