Skip to content

Commit 7bc5ec4

Browse files
committed
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
1 parent e4980c2 commit 7bc5ec4

File tree

3 files changed

+348
-0
lines changed

3 files changed

+348
-0
lines changed
Lines changed: 231 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
1+
SPDX-FileCopyrightText: 2013 Dan Kogai <[email protected]>
2+
SPDX-FileCopyrightText: 2025 fosslinux <[email protected]>
3+
4+
SPDX-License-Identifier: Artistic-1.0
5+
6+
Apply this patch to Encode package to Perl 5.18's import of Encode.
7+
8+
Is necessary for reproducible Encode.a.
9+
10+
From e800b1d3cc678e29ae6e95c3f3916b65439fd99c Mon Sep 17 00:00:00 2001
11+
From: Dan Kogai <[email protected]>
12+
Date: Wed, 17 Jul 2013 03:11:42 +0900
13+
Subject: [PATCH] RT #86974: Patch to output #includes in deterministic order
14+
15+
---
16+
Byte/Makefile.PL | 4 ++--
17+
CN/Makefile.PL | 4 ++--
18+
Changes | 7 +++++++
19+
EBCDIC/Makefile.PL | 4 ++--
20+
Encode/Makefile_PL.e2x | 10 +++++-----
21+
JP/Makefile.PL | 4 ++--
22+
KR/Makefile.PL | 4 ++--
23+
Symbol/Makefile.PL | 4 ++--
24+
TW/Makefile.PL | 4 ++--
25+
9 files changed, 26 insertions(+), 19 deletions(-)
26+
27+
diff --git perl-5.18.4/cpan/Encode/Byte/Makefile.PL perl-5.18.4/cpan/Encode/Byte/Makefile.PL
28+
index 60caf38..e368ac8 100644
29+
--- perl-5.18.4/cpan/Encode/Byte/Makefile.PL
30+
+++ perl-5.18.4/cpan/Encode/Byte/Makefile.PL
31+
@@ -108,7 +108,7 @@ sub post_initialize
32+
#define U8 U8
33+
#include "encode.h"
34+
END
35+
- foreach my $table (keys %tables) {
36+
+ foreach my $table (sort keys %tables) {
37+
print XS qq[#include "${table}.h"\n];
38+
}
39+
print XS <<"END";
40+
@@ -137,7 +137,7 @@ PROTOTYPES: DISABLE
41+
BOOT:
42+
{
43+
END
44+
- foreach my $table (keys %tables) {
45+
+ foreach my $table (sort keys %tables) {
46+
print XS qq[#include "${table}.exh"\n];
47+
}
48+
print XS "}\n";
49+
diff --git perl-5.18.4/cpan/Encode/CN/Makefile.PL perl-5.18.4/cpan/Encode/CN/Makefile.PL
50+
index 6d54404..323b47e 100644
51+
--- perl-5.18.4/cpan/Encode/CN/Makefile.PL
52+
+++ perl-5.18.4/cpan/Encode/CN/Makefile.PL
53+
@@ -84,7 +84,7 @@ sub post_initialize
54+
#define U8 U8
55+
#include "encode.h"
56+
END
57+
- foreach my $table (keys %tables) {
58+
+ foreach my $table (sort keys %tables) {
59+
print XS qq[#include "${table}.h"\n];
60+
}
61+
print XS <<"END";
62+
@@ -113,7 +113,7 @@ PROTOTYPES: DISABLE
63+
BOOT:
64+
{
65+
END
66+
- foreach my $table (keys %tables) {
67+
+ foreach my $table (sort keys %tables) {
68+
print XS qq[#include "${table}.exh"\n];
69+
}
70+
print XS "}\n";
71+
diff --git perl-5.18.4/cpan/Encode/EBCDIC/Makefile.PL perl-5.18.4/cpan/Encode/EBCDIC/Makefile.PL
72+
index 0e2a13c..1c78c6a 100644
73+
--- perl-5.18.4/cpan/Encode/EBCDIC/Makefile.PL
74+
+++ perl-5.18.4/cpan/Encode/EBCDIC/Makefile.PL
75+
@@ -65,7 +65,7 @@ sub post_initialize
76+
#define U8 U8
77+
#include "encode.h"
78+
END
79+
- foreach my $table (keys %tables) {
80+
+ foreach my $table (sort keys %tables) {
81+
print XS qq[#include "${table}.h"\n];
82+
}
83+
print XS <<"END";
84+
@@ -94,7 +94,7 @@ PROTOTYPES: DISABLE
85+
BOOT:
86+
{
87+
END
88+
- foreach my $table (keys %tables) {
89+
+ foreach my $table (sort keys %tables) {
90+
print XS qq[#include "${table}.exh"\n];
91+
}
92+
print XS "}\n";
93+
diff --git perl-5.18.4/cpan/Encode/Encode/Makefile_PL.e2x perl-5.18.4/cpan/Encode/Encode/Makefile_PL.e2x
94+
index ece5883..9fe60ef 100644
95+
--- perl-5.18.4/cpan/Encode/Encode/Makefile_PL.e2x
96+
+++ perl-5.18.4/cpan/Encode/Encode/Makefile_PL.e2x
97+
@@ -83,7 +83,7 @@ sub post_initialize
98+
if $^O eq 'MacOS' && $self->{SOURCE} !~ /\b$name\.c\b/;
99+
# $self->{'H'} = [$self->catfile($self->updir,'encode.h')];
100+
my %xs;
101+
- foreach my $table (keys %tables) {
102+
+ foreach my $table (sort keys %tables) {
103+
push (@{$self->{'C'}},"$table.c");
104+
# Do NOT add $table.h etc. to H_FILES unless we own up as to how they
105+
# get built.
106+
@@ -101,7 +101,7 @@ sub post_initialize
107+
#define U8 U8
108+
#include "encode.h"
109+
END
110+
- foreach my $table (keys %tables) {
111+
+ foreach my $table (sort keys %tables) {
112+
print XS qq[#include "${table}.h"\n];
113+
}
114+
print XS <<"END";
115+
@@ -130,7 +130,7 @@ PROTOTYPES: DISABLE
116+
BOOT:
117+
{
118+
END
119+
- foreach my $table (keys %tables) {
120+
+ foreach my $table (sort keys %tables) {
121+
print XS qq[#include "${table}.exh"\n];
122+
}
123+
print XS "}\n";
124+
@@ -144,14 +144,14 @@ sub postamble
125+
my $dir = "."; # $self->catdir('Encode');
126+
my $str = "# $name\$(OBJ_EXT) depends on .h and .exh files not .c files - but all written by enc2xs\n";
127+
$str .= "$name.c : $name.xs ";
128+
- foreach my $table (keys %tables)
129+
+ foreach my $table (sort keys %tables)
130+
{
131+
$str .= " $table.c";
132+
}
133+
$str .= "\n\n";
134+
$str .= "$name\$(OBJ_EXT) : $name.c\n\n";
135+
136+
- foreach my $table (keys %tables)
137+
+ foreach my $table (sort keys %tables)
138+
{
139+
my $numlines = 1;
140+
my $lengthsofar = length($str);
141+
diff --git perl-5.18.4/cpan/Encode/JP/Makefile.PL perl-5.18.4/cpan/Encode/JP/Makefile.PL
142+
index a75685e..c6a725f 100644
143+
--- perl-5.18.4/cpan/Encode/JP/Makefile.PL
144+
+++ perl-5.18.4/cpan/Encode/JP/Makefile.PL
145+
@@ -84,7 +84,7 @@ sub post_initialize
146+
#define U8 U8
147+
#include "encode.h"
148+
END
149+
- foreach my $table (keys %tables) {
150+
+ foreach my $table (sort keys %tables) {
151+
print XS qq[#include "${table}.h"\n];
152+
}
153+
print XS <<"END";
154+
@@ -113,7 +113,7 @@ PROTOTYPES: DISABLE
155+
BOOT:
156+
{
157+
END
158+
- foreach my $table (keys %tables) {
159+
+ foreach my $table (sort keys %tables) {
160+
print XS qq[#include "${table}.exh"\n];
161+
}
162+
print XS "}\n";
163+
diff --git perl-5.18.4/cpan/Encode/KR/Makefile.PL perl-5.18.4/cpan/Encode/KR/Makefile.PL
164+
index e95d039..49c0319 100644
165+
--- perl-5.18.4/cpan/Encode/KR/Makefile.PL
166+
+++ perl-5.18.4/cpan/Encode/KR/Makefile.PL
167+
@@ -82,7 +82,7 @@ sub post_initialize
168+
#define U8 U8
169+
#include "encode.h"
170+
END
171+
- foreach my $table (keys %tables) {
172+
+ foreach my $table (sort keys %tables) {
173+
print XS qq[#include "${table}.h"\n];
174+
}
175+
print XS <<"END";
176+
@@ -111,7 +111,7 @@ PROTOTYPES: DISABLE
177+
BOOT:
178+
{
179+
END
180+
- foreach my $table (keys %tables) {
181+
+ foreach my $table (sort keys %tables) {
182+
print XS qq[#include "${table}.exh"\n];
183+
}
184+
print XS "}\n";
185+
diff --git perl-5.18.4/cpan/Encode/Symbol/Makefile.PL perl-5.18.4/cpan/Encode/Symbol/Makefile.PL
186+
index 23ca1f4..2c94aab 100644
187+
--- perl-5.18.4/cpan/Encode/Symbol/Makefile.PL
188+
+++ perl-5.18.4/cpan/Encode/Symbol/Makefile.PL
189+
@@ -70,7 +70,7 @@ sub post_initialize
190+
#define U8 U8
191+
#include "encode.h"
192+
END
193+
- foreach my $table (keys %tables) {
194+
+ foreach my $table (sort keys %tables) {
195+
print XS qq[#include "${table}.h"\n];
196+
}
197+
print XS <<"END";
198+
@@ -99,7 +99,7 @@ PROTOTYPES: DISABLE
199+
BOOT:
200+
{
201+
END
202+
- foreach my $table (keys %tables) {
203+
+ foreach my $table (sort keys %tables) {
204+
print XS qq[#include "${table}.exh"\n];
205+
}
206+
print XS "}\n";
207+
diff --git perl-5.18.4/cpan/Encode/TW/Makefile.PL perl-5.18.4/cpan/Encode/TW/Makefile.PL
208+
index 99c94bf..f90861f 100644
209+
--- perl-5.18.4/cpan/Encode/TW/Makefile.PL
210+
+++ perl-5.18.4/cpan/Encode/TW/Makefile.PL
211+
@@ -80,7 +80,7 @@ sub post_initialize
212+
#define U8 U8
213+
#include "encode.h"
214+
END
215+
- foreach my $table (keys %tables) {
216+
+ foreach my $table (sort keys %tables) {
217+
print XS qq[#include "${table}.h"\n];
218+
}
219+
print XS <<"END";
220+
@@ -109,7 +109,7 @@ PROTOTYPES: DISABLE
221+
BOOT:
222+
{
223+
END
224+
- foreach my $table (keys %tables) {
225+
+ foreach my $table (sort keys %tables) {
226+
print XS qq[#include "${table}.exh"\n];
227+
}
228+
print XS "}\n";
229+
--
230+
2.49.1
231+
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
SPDX-FileCopyrightText: 2013 Nicholas Clark <[email protected]>
2+
3+
SPDX-License-Identifier: Artistic-1.0
4+
5+
Direct application of this commit to ensure reproducibility of Errno.pm and
6+
Functions.pm.
7+
8+
From 826ca1caadb538106237a9a41004ce52e2c29c51 Mon Sep 17 00:00:00 2001
9+
From: Nicholas Clark <[email protected]>
10+
Date: Fri, 12 Jul 2013 16:50:13 +0200
11+
Subject: [PATCH] Generate Errno and Pod::Functions with deterministic order.
12+
13+
Previously the order of duplicate names in Errno was determined by hash
14+
iteration order, as was the order of the list of types for built-ins in
15+
Pod::Functions. With hash randomisation this meant that the generated file
16+
could differ between builds, which isn't ideal if the input is the same.
17+
18+
(Spotted as a side effect of running a diff on two installation trees.)
19+
---
20+
ext/Errno/Errno_pm.PL | 4 ++--
21+
ext/Pod-Functions/Functions_pm.PL | 4 ++--
22+
2 files changed, 4 insertions(+), 4 deletions(-)
23+
24+
diff --git perl-5.18.4/ext/Errno/Errno_pm.PL perl-5.18.4/ext/Errno/Errno_pm.PL
25+
index b7079112bf..b372875480 100644
26+
--- perl-5.18.4/ext/Errno/Errno_pm.PL
27+
+++ perl-5.18.4/ext/Errno/Errno_pm.PL
28+
@@ -2,7 +2,7 @@ use ExtUtils::MakeMaker;
29+
use Config;
30+
use strict;
31+
32+
-our $VERSION = "1.18";
33+
+our $VERSION = "1.19";
34+
35+
my %err = ();
36+
my %wsa = ();
37+
@@ -305,7 +305,7 @@ BEGIN {
38+
%err = (
39+
EDQ
40+
41+
- my @err = sort { $err{$a} <=> $err{$b} }
42+
+ my @err = sort { $err{$a} <=> $err{$b} || $a cmp $b }
43+
grep { $err{$_} =~ /-?\d+$/ } keys %err;
44+
45+
foreach $err (@err) {
46+
diff --git perl-5.18.4/ext/Pod-Functions/Functions_pm.PL perl-5.18.4/ext/Pod-Functions/Functions_pm.PL
47+
index 0d38aef003..7cf0b51e92 100644
48+
--- perl-5.18.4/ext/Pod-Functions/Functions_pm.PL
49+
+++ perl-5.18.4/ext/Pod-Functions/Functions_pm.PL
50+
@@ -198,7 +198,7 @@ L<perlfunc/"Perl Functions by Category"> section.
51+
52+
=cut
53+
54+
-our $VERSION = '1.06';
55+
+our $VERSION = '1.07';
56+
57+
require Exporter;
58+
59+
@@ -265,7 +265,7 @@ foreach my $func (sort_funcs(keys %Flavor)) {
60+
my $desc = $Flavor{$func};
61+
die "No types listed for $func" unless $Type{$func};
62+
next if $Omit{$func};
63+
- print $fh join("\t", $func, @{$Type{$func}}, $desc), "\n";
64+
+ print $fh join("\t", $func, (sort @{$Type{$func}}), $desc), "\n";
65+
}
66+
67+
close $fh or die "Can't close '$temp': $!";
68+
--
69+
2.49.1
70+
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
SPDX-FileCopyrightText: 2013 Karl Williamson <[email protected]>
2+
SPDX-FileCopyrightText: 2025 fosslinux <[email protected]>
3+
4+
SPDX-License-Identifier: Artistic-1.0
5+
6+
Backport of this commit to Perl 5.18 to ensure reproducibility of anything
7+
that uses ParseXS.
8+
9+
From 06535856556a6bc0b3b1e4fac8671acb2a9aa8fd Mon Sep 17 00:00:00 2001
10+
From: Karl Williamson <[email protected]>
11+
Date: Mon, 15 Jul 2013 09:55:40 -0600
12+
Subject: [PATCH] ParseXS: generate deterministically ordered output
13+
14+
The generated XS file output was varying between builds because of hash
15+
randomisation. This sorts the output to make it the same for the same
16+
inputs. This facilitates eyeballing diffs of two workspaces.
17+
---
18+
dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm | 6 ++++--
19+
1 file changed, 4 insertions(+), 2 deletions(-)
20+
21+
diff --git perl-5.18.4/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm perl-5.18.4/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm
22+
index d50b5010cd..8e691f4ab6 100644
23+
--- perl-5.18.4/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm
24+
+++ perl-5.18.4/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm
25+
@@ -845,7 +845,8 @@ EOF
26+
if (%{ $self->{XsubAliases} }) {
27+
$self->{XsubAliases}->{$pname} = 0
28+
unless defined $self->{XsubAliases}->{$pname};
29+
- while ( my ($xname, $value) = each %{ $self->{XsubAliases} }) {
30+
+ foreach my $xname (sort keys %{ $self->{XsubAliases} }) {
31+
+ my $value = $self->{XsubAliases}->{$xname};
32+
push(@{ $self->{InitFileCode} }, Q(<<"EOF"));
33+
# cv = $self->{newXS}(\"$xname\", XS_$Full_func_name, file$self->{proto});
34+
# XSANY.any_i32 = $value;
35+
@@ -859,7 +860,8 @@ EOF
36+
EOF
37+
}
38+
elsif ($self->{interface}) {
39+
- while ( my ($yname, $value) = each %{ $self->{Interfaces} }) {
40+
+ foreach my $yname (sort keys %{ $self->{Interfaces} }) {
41+
+ my $value = $self->{Interfaces}->{$yname};
42+
$yname = "$Package\::$yname" unless $yname =~ /::/;
43+
push(@{ $self->{InitFileCode} }, Q(<<"EOF"));
44+
# cv = $self->{newXS}(\"$yname\", XS_$Full_func_name, file$self->{proto});
45+
--
46+
2.49.1
47+

0 commit comments

Comments
 (0)