Make Perl 5.18 reproducible

All of these only apply to Perl 5.18 and future perls are okay.
This commit backports
- a patch to make the include order of files in Encode package
  reproducible
- a patch to make Errno and Pod pm files reproducible
- a patch to make the ordering of .a files deterministic using ParseXS
This commit is contained in:
Samuel Tyler 2025-09-14 14:10:30 +10:00
parent e4980c20e8
commit 7bc5ec4555
3 changed files with 348 additions and 0 deletions

View file

@ -0,0 +1,231 @@
SPDX-FileCopyrightText: 2013 Dan Kogai <dankogai+github@gmail.com>
SPDX-FileCopyrightText: 2025 fosslinux <fosslinux@aussies.space>
SPDX-License-Identifier: Artistic-1.0
Apply this patch to Encode package to Perl 5.18's import of Encode.
Is necessary for reproducible Encode.a.
From e800b1d3cc678e29ae6e95c3f3916b65439fd99c Mon Sep 17 00:00:00 2001
From: Dan Kogai <dankogai+github@gmail.com>
Date: Wed, 17 Jul 2013 03:11:42 +0900
Subject: [PATCH] RT #86974: Patch to output #includes in deterministic order
---
Byte/Makefile.PL | 4 ++--
CN/Makefile.PL | 4 ++--
Changes | 7 +++++++
EBCDIC/Makefile.PL | 4 ++--
Encode/Makefile_PL.e2x | 10 +++++-----
JP/Makefile.PL | 4 ++--
KR/Makefile.PL | 4 ++--
Symbol/Makefile.PL | 4 ++--
TW/Makefile.PL | 4 ++--
9 files changed, 26 insertions(+), 19 deletions(-)
diff --git perl-5.18.4/cpan/Encode/Byte/Makefile.PL perl-5.18.4/cpan/Encode/Byte/Makefile.PL
index 60caf38..e368ac8 100644
--- perl-5.18.4/cpan/Encode/Byte/Makefile.PL
+++ perl-5.18.4/cpan/Encode/Byte/Makefile.PL
@@ -108,7 +108,7 @@ sub post_initialize
#define U8 U8
#include "encode.h"
END
- foreach my $table (keys %tables) {
+ foreach my $table (sort keys %tables) {
print XS qq[#include "${table}.h"\n];
}
print XS <<"END";
@@ -137,7 +137,7 @@ PROTOTYPES: DISABLE
BOOT:
{
END
- foreach my $table (keys %tables) {
+ foreach my $table (sort keys %tables) {
print XS qq[#include "${table}.exh"\n];
}
print XS "}\n";
diff --git perl-5.18.4/cpan/Encode/CN/Makefile.PL perl-5.18.4/cpan/Encode/CN/Makefile.PL
index 6d54404..323b47e 100644
--- perl-5.18.4/cpan/Encode/CN/Makefile.PL
+++ perl-5.18.4/cpan/Encode/CN/Makefile.PL
@@ -84,7 +84,7 @@ sub post_initialize
#define U8 U8
#include "encode.h"
END
- foreach my $table (keys %tables) {
+ foreach my $table (sort keys %tables) {
print XS qq[#include "${table}.h"\n];
}
print XS <<"END";
@@ -113,7 +113,7 @@ PROTOTYPES: DISABLE
BOOT:
{
END
- foreach my $table (keys %tables) {
+ foreach my $table (sort keys %tables) {
print XS qq[#include "${table}.exh"\n];
}
print XS "}\n";
diff --git perl-5.18.4/cpan/Encode/EBCDIC/Makefile.PL perl-5.18.4/cpan/Encode/EBCDIC/Makefile.PL
index 0e2a13c..1c78c6a 100644
--- perl-5.18.4/cpan/Encode/EBCDIC/Makefile.PL
+++ perl-5.18.4/cpan/Encode/EBCDIC/Makefile.PL
@@ -65,7 +65,7 @@ sub post_initialize
#define U8 U8
#include "encode.h"
END
- foreach my $table (keys %tables) {
+ foreach my $table (sort keys %tables) {
print XS qq[#include "${table}.h"\n];
}
print XS <<"END";
@@ -94,7 +94,7 @@ PROTOTYPES: DISABLE
BOOT:
{
END
- foreach my $table (keys %tables) {
+ foreach my $table (sort keys %tables) {
print XS qq[#include "${table}.exh"\n];
}
print XS "}\n";
diff --git perl-5.18.4/cpan/Encode/Encode/Makefile_PL.e2x perl-5.18.4/cpan/Encode/Encode/Makefile_PL.e2x
index ece5883..9fe60ef 100644
--- perl-5.18.4/cpan/Encode/Encode/Makefile_PL.e2x
+++ perl-5.18.4/cpan/Encode/Encode/Makefile_PL.e2x
@@ -83,7 +83,7 @@ sub post_initialize
if $^O eq 'MacOS' && $self->{SOURCE} !~ /\b$name\.c\b/;
# $self->{'H'} = [$self->catfile($self->updir,'encode.h')];
my %xs;
- foreach my $table (keys %tables) {
+ foreach my $table (sort keys %tables) {
push (@{$self->{'C'}},"$table.c");
# Do NOT add $table.h etc. to H_FILES unless we own up as to how they
# get built.
@@ -101,7 +101,7 @@ sub post_initialize
#define U8 U8
#include "encode.h"
END
- foreach my $table (keys %tables) {
+ foreach my $table (sort keys %tables) {
print XS qq[#include "${table}.h"\n];
}
print XS <<"END";
@@ -130,7 +130,7 @@ PROTOTYPES: DISABLE
BOOT:
{
END
- foreach my $table (keys %tables) {
+ foreach my $table (sort keys %tables) {
print XS qq[#include "${table}.exh"\n];
}
print XS "}\n";
@@ -144,14 +144,14 @@ sub postamble
my $dir = "."; # $self->catdir('Encode');
my $str = "# $name\$(OBJ_EXT) depends on .h and .exh files not .c files - but all written by enc2xs\n";
$str .= "$name.c : $name.xs ";
- foreach my $table (keys %tables)
+ foreach my $table (sort keys %tables)
{
$str .= " $table.c";
}
$str .= "\n\n";
$str .= "$name\$(OBJ_EXT) : $name.c\n\n";
- foreach my $table (keys %tables)
+ foreach my $table (sort keys %tables)
{
my $numlines = 1;
my $lengthsofar = length($str);
diff --git perl-5.18.4/cpan/Encode/JP/Makefile.PL perl-5.18.4/cpan/Encode/JP/Makefile.PL
index a75685e..c6a725f 100644
--- perl-5.18.4/cpan/Encode/JP/Makefile.PL
+++ perl-5.18.4/cpan/Encode/JP/Makefile.PL
@@ -84,7 +84,7 @@ sub post_initialize
#define U8 U8
#include "encode.h"
END
- foreach my $table (keys %tables) {
+ foreach my $table (sort keys %tables) {
print XS qq[#include "${table}.h"\n];
}
print XS <<"END";
@@ -113,7 +113,7 @@ PROTOTYPES: DISABLE
BOOT:
{
END
- foreach my $table (keys %tables) {
+ foreach my $table (sort keys %tables) {
print XS qq[#include "${table}.exh"\n];
}
print XS "}\n";
diff --git perl-5.18.4/cpan/Encode/KR/Makefile.PL perl-5.18.4/cpan/Encode/KR/Makefile.PL
index e95d039..49c0319 100644
--- perl-5.18.4/cpan/Encode/KR/Makefile.PL
+++ perl-5.18.4/cpan/Encode/KR/Makefile.PL
@@ -82,7 +82,7 @@ sub post_initialize
#define U8 U8
#include "encode.h"
END
- foreach my $table (keys %tables) {
+ foreach my $table (sort keys %tables) {
print XS qq[#include "${table}.h"\n];
}
print XS <<"END";
@@ -111,7 +111,7 @@ PROTOTYPES: DISABLE
BOOT:
{
END
- foreach my $table (keys %tables) {
+ foreach my $table (sort keys %tables) {
print XS qq[#include "${table}.exh"\n];
}
print XS "}\n";
diff --git perl-5.18.4/cpan/Encode/Symbol/Makefile.PL perl-5.18.4/cpan/Encode/Symbol/Makefile.PL
index 23ca1f4..2c94aab 100644
--- perl-5.18.4/cpan/Encode/Symbol/Makefile.PL
+++ perl-5.18.4/cpan/Encode/Symbol/Makefile.PL
@@ -70,7 +70,7 @@ sub post_initialize
#define U8 U8
#include "encode.h"
END
- foreach my $table (keys %tables) {
+ foreach my $table (sort keys %tables) {
print XS qq[#include "${table}.h"\n];
}
print XS <<"END";
@@ -99,7 +99,7 @@ PROTOTYPES: DISABLE
BOOT:
{
END
- foreach my $table (keys %tables) {
+ foreach my $table (sort keys %tables) {
print XS qq[#include "${table}.exh"\n];
}
print XS "}\n";
diff --git perl-5.18.4/cpan/Encode/TW/Makefile.PL perl-5.18.4/cpan/Encode/TW/Makefile.PL
index 99c94bf..f90861f 100644
--- perl-5.18.4/cpan/Encode/TW/Makefile.PL
+++ perl-5.18.4/cpan/Encode/TW/Makefile.PL
@@ -80,7 +80,7 @@ sub post_initialize
#define U8 U8
#include "encode.h"
END
- foreach my $table (keys %tables) {
+ foreach my $table (sort keys %tables) {
print XS qq[#include "${table}.h"\n];
}
print XS <<"END";
@@ -109,7 +109,7 @@ PROTOTYPES: DISABLE
BOOT:
{
END
- foreach my $table (keys %tables) {
+ foreach my $table (sort keys %tables) {
print XS qq[#include "${table}.exh"\n];
}
print XS "}\n";
--
2.49.1

View file

@ -0,0 +1,70 @@
SPDX-FileCopyrightText: 2013 Nicholas Clark <nick@ccl4.org>
SPDX-License-Identifier: Artistic-1.0
Direct application of this commit to ensure reproducibility of Errno.pm and
Functions.pm.
From 826ca1caadb538106237a9a41004ce52e2c29c51 Mon Sep 17 00:00:00 2001
From: Nicholas Clark <nick@ccl4.org>
Date: Fri, 12 Jul 2013 16:50:13 +0200
Subject: [PATCH] Generate Errno and Pod::Functions with deterministic order.
Previously the order of duplicate names in Errno was determined by hash
iteration order, as was the order of the list of types for built-ins in
Pod::Functions. With hash randomisation this meant that the generated file
could differ between builds, which isn't ideal if the input is the same.
(Spotted as a side effect of running a diff on two installation trees.)
---
ext/Errno/Errno_pm.PL | 4 ++--
ext/Pod-Functions/Functions_pm.PL | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git perl-5.18.4/ext/Errno/Errno_pm.PL perl-5.18.4/ext/Errno/Errno_pm.PL
index b7079112bf..b372875480 100644
--- perl-5.18.4/ext/Errno/Errno_pm.PL
+++ perl-5.18.4/ext/Errno/Errno_pm.PL
@@ -2,7 +2,7 @@ use ExtUtils::MakeMaker;
use Config;
use strict;
-our $VERSION = "1.18";
+our $VERSION = "1.19";
my %err = ();
my %wsa = ();
@@ -305,7 +305,7 @@ BEGIN {
%err = (
EDQ
- my @err = sort { $err{$a} <=> $err{$b} }
+ my @err = sort { $err{$a} <=> $err{$b} || $a cmp $b }
grep { $err{$_} =~ /-?\d+$/ } keys %err;
foreach $err (@err) {
diff --git perl-5.18.4/ext/Pod-Functions/Functions_pm.PL perl-5.18.4/ext/Pod-Functions/Functions_pm.PL
index 0d38aef003..7cf0b51e92 100644
--- perl-5.18.4/ext/Pod-Functions/Functions_pm.PL
+++ perl-5.18.4/ext/Pod-Functions/Functions_pm.PL
@@ -198,7 +198,7 @@ L<perlfunc/"Perl Functions by Category"> section.
=cut
-our $VERSION = '1.06';
+our $VERSION = '1.07';
require Exporter;
@@ -265,7 +265,7 @@ foreach my $func (sort_funcs(keys %Flavor)) {
my $desc = $Flavor{$func};
die "No types listed for $func" unless $Type{$func};
next if $Omit{$func};
- print $fh join("\t", $func, @{$Type{$func}}, $desc), "\n";
+ print $fh join("\t", $func, (sort @{$Type{$func}}), $desc), "\n";
}
close $fh or die "Can't close '$temp': $!";
--
2.49.1

View file

@ -0,0 +1,47 @@
SPDX-FileCopyrightText: 2013 Karl Williamson <public@khwilliamson.com>
SPDX-FileCopyrightText: 2025 fosslinux <fosslinux@aussies.space>
SPDX-License-Identifier: Artistic-1.0
Backport of this commit to Perl 5.18 to ensure reproducibility of anything
that uses ParseXS.
From 06535856556a6bc0b3b1e4fac8671acb2a9aa8fd Mon Sep 17 00:00:00 2001
From: Karl Williamson <public@khwilliamson.com>
Date: Mon, 15 Jul 2013 09:55:40 -0600
Subject: [PATCH] ParseXS: generate deterministically ordered output
The generated XS file output was varying between builds because of hash
randomisation. This sorts the output to make it the same for the same
inputs. This facilitates eyeballing diffs of two workspaces.
---
dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git perl-5.18.4/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm perl-5.18.4/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm
index d50b5010cd..8e691f4ab6 100644
--- perl-5.18.4/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm
+++ perl-5.18.4/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm
@@ -845,7 +845,8 @@ EOF
if (%{ $self->{XsubAliases} }) {
$self->{XsubAliases}->{$pname} = 0
unless defined $self->{XsubAliases}->{$pname};
- while ( my ($xname, $value) = each %{ $self->{XsubAliases} }) {
+ foreach my $xname (sort keys %{ $self->{XsubAliases} }) {
+ my $value = $self->{XsubAliases}->{$xname};
push(@{ $self->{InitFileCode} }, Q(<<"EOF"));
# cv = $self->{newXS}(\"$xname\", XS_$Full_func_name, file$self->{proto});
# XSANY.any_i32 = $value;
@@ -859,7 +860,8 @@ EOF
EOF
}
elsif ($self->{interface}) {
- while ( my ($yname, $value) = each %{ $self->{Interfaces} }) {
+ foreach my $yname (sort keys %{ $self->{Interfaces} }) {
+ my $value = $self->{Interfaces}->{$yname};
$yname = "$Package\::$yname" unless $yname =~ /::/;
push(@{ $self->{InitFileCode} }, Q(<<"EOF"));
# cv = $self->{newXS}(\"$yname\", XS_$Full_func_name, file$self->{proto});
--
2.49.1