1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
|
Author: Danny Milosavljevic <dannym@friendly-machines.com>
Date: 10 Jun 2025
Subject: Fix sources of non-reproducibility.
diff -ru orig/mono-1.9.1-checkout/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs mono-1.9.1-checkout/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs
--- orig/mono-1.9.1-checkout/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs 2025-06-09 11:58:58.679365113 +0200
+++ mono-1.9.1-checkout/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs 2025-06-09 19:10:46.839764717 +0200
@@ -80,7 +80,7 @@
this.assembly = this.assemblyb = assb;
this.transient = transient;
// to keep mcs fast we do not want CryptoConfig wo be involved to create the RNG
- guid = Guid.FastNewGuidArray ();
+ guid = new byte[16]; // = Guid.Empty.ToByteArray();
// guid = Guid.NewGuid().ToByteArray ();
table_idx = get_next_table_index (this, 0x00, true);
name_cache = new Hashtable ();
diff -ru orig/mono-1.9.1-checkout/mcs/class/Mono.Cecil/Mono.Cecil.Binary/ImageInitializer.cs mono-1.9.1-checkout/mcs/class/Mono.Cecil/Mono.Cecil.Binary/ImageInitializer.cs
--- orig/mono-1.9.1-checkout/mcs/class/Mono.Cecil/Mono.Cecil.Binary/ImageInitializer.cs 2025-06-09 11:58:58.233978153 +0200
+++ mono-1.9.1-checkout/mcs/class/Mono.Cecil/Mono.Cecil.Binary/ImageInitializer.cs 2025-06-09 16:46:46.086454131 +0200
@@ -132,6 +132,15 @@
public static uint TimeDateStampFromEpoch ()
{
+ string sourceDateEpoch = Environment.GetEnvironmentVariable("SOURCE_DATE_EPOCH");
+ if (sourceDateEpoch != null && sourceDateEpoch != "") {
+ try {
+ return uint.Parse(sourceDateEpoch);
+ } catch {
+ // fallthrough
+ }
+ }
+
return (uint) DateTime.UtcNow.Subtract (
new DateTime (1970, 1, 1)).TotalSeconds;
}
diff -ru orig/mono-1.9.1-checkout/mcs/mcs/anonymous.cs mono-1.9.1-checkout/mcs/mcs/anonymous.cs
--- orig/mono-1.9.1-checkout/mcs/mcs/anonymous.cs 2025-06-09 11:58:58.814338639 +0200
+++ mono-1.9.1-checkout/mcs/mcs/anonymous.cs 2025-06-09 22:27:26.049258977 +0200
@@ -21,6 +21,7 @@
namespace Mono.CSharp {
+
public abstract class CompilerGeneratedClass : Class
{
GenericMethod generic_method;
@@ -174,6 +175,61 @@
throw new InternalErrorException ("Helper class already defined!");
}
+//
+// A comparer for all types that inherit from the abstract class 'Variable'.
+// Uses only C# 2.0 compatible syntax.
+//
+//
+public class VariableComparer : System.Collections.IComparer
+{
+ // Helper method to safely get a comparable name from any Variable type.
+ private string GetVariableName(object obj)
+ {
+ // Case 1: The object is a 'CapturedVariable' or any of its children.
+ if (obj is ScopeInfo.CapturedVariable)
+ {
+
+ ScopeInfo.CapturedVariable cv = (ScopeInfo.CapturedVariable)obj;
+ return cv.Name;
+ }
+
+ // Case 2: The object is a 'LocalVariable'
+ if (obj is LocalInfo.LocalVariable)
+ {
+ // Explicit cast required for C# 2.0
+ LocalInfo.LocalVariable lv = (LocalInfo.LocalVariable)obj;
+ return lv.LocalInfo.Name;
+ }
+
+ //
+ // Fallback for any other unknown 'Variable' subtype.
+ //
+ return obj.GetType().FullName;
+ }
+
+ // The single method required by the IComparer interface.
+ public int Compare(object x, object y)
+ {
+ // Handle nulls gracefully.
+ if (x == null && y == null) return 0;
+ if (x == null) return -1;
+ if (y == null) return 1;
+
+ string name_x = GetVariableName(x);
+ string name_y = GetVariableName(y);
+
+ // Primary Sort Key: The extracted variable name.
+ int name_compare = string.CompareOrdinal(name_x, name_y);
+ if (name_compare != 0)
+ {
+ return name_compare;
+ }
+
+ // Secondary Sort Key (Tie-breaker): The full type name.
+ return string.CompareOrdinal(x.GetType().FullName, y.GetType().FullName);
+ }
+}
+
protected class CapturedVariableField : Field
{
public CapturedVariableField (CompilerGeneratedClass helper, string name,
@@ -264,9 +320,11 @@
protected CapturedScope[] CapturedScopes {
get {
- CapturedScope[] list = new CapturedScope [captured_scopes.Count];
- captured_scopes.Values.CopyTo (list, 0);
- return list;
+ ArrayList list = new ArrayList(captured_scopes.Values);
+ list.Sort(new VariableComparer());
+ CapturedScope[] result = new CapturedScope[list.Count];
+ list.CopyTo(result, 0);
+ return result;
}
}
@@ -420,7 +478,7 @@
return new ScopeInitializer (this);
}
- protected abstract class CapturedVariable : Variable
+ public abstract class CapturedVariable : Variable
{
public readonly ScopeInfo Scope;
public readonly string Name;
@@ -493,7 +551,7 @@
}
}
- protected class CapturedParameter : CapturedVariable {
+ public class CapturedParameter : CapturedVariable {
public readonly Parameter Parameter;
public readonly int Idx;
@@ -511,7 +569,7 @@
}
}
- protected class CapturedLocal : CapturedVariable {
+ public class CapturedLocal : CapturedVariable {
public readonly LocalInfo Local;
public CapturedLocal (ScopeInfo scope, LocalInfo local)
@@ -527,7 +585,7 @@
}
}
- protected class CapturedThis : CapturedVariable {
+ public class CapturedThis : CapturedVariable {
public CapturedThis (RootScopeInfo host)
: base (host, "<>THIS", host.ParentType)
{ }
@@ -646,7 +704,9 @@
} else
scope_instance = ec.ig.DeclareLocal (type);
- foreach (CapturedLocal local in Scope.locals.Values) {
+ ArrayList sorted_locals = new ArrayList(Scope.locals.Values);
+ sorted_locals.Sort(new VariableComparer());
+ foreach (CapturedLocal local in sorted_locals) {
FieldExpr fe = (FieldExpr) Expression.MemberLookup (
ec.ContainerType, type, local.Field.Name, loc);
Report.Debug (64, "RESOLVE SCOPE INITIALIZER #2", this, Scope,
@@ -660,7 +720,9 @@
}
if (Scope.HostsParameters) {
- foreach (CapturedParameter cp in Scope.captured_params.Values) {
+ ArrayList sorted_params = new ArrayList(Scope.captured_params.Values);
+ sorted_params.Sort(new VariableComparer());
+ foreach (CapturedParameter cp in sorted_params) {
FieldExpr fe = (FieldExpr) Expression.MemberLookup (
ec.ContainerType, type, cp.Field.Name, loc);
if (fe == null)
@@ -775,7 +837,9 @@
captured_scope.EmitAssign (ec);
if (Scope.HostsParameters) {
- foreach (CapturedParameter cp in Scope.captured_params.Values) {
+ ArrayList sorted_params = new ArrayList(Scope.captured_params.Values);
+ sorted_params.Sort(new VariableComparer());
+ foreach (CapturedParameter cp in sorted_params) {
Report.Debug (128, "EMIT SCOPE INIT #6", this,
ec, ec.IsStatic, Scope, cp, cp.Field.Name);
DoEmitInstance (ec);
diff -ru orig/mono-1.9.1-checkout/mcs/mcs/statement.cs mono-1.9.1-checkout/mcs/mcs/statement.cs
--- orig/mono-1.9.1-checkout/mcs/mcs/statement.cs 2025-06-09 11:58:58.816851529 +0200
+++ mono-1.9.1-checkout/mcs/mcs/statement.cs 2025-06-09 22:07:10.441563853 +0200
@@ -1392,7 +1392,7 @@
get { return Location; }
}
- protected class LocalVariable : Variable
+ public class LocalVariable : Variable
{
public readonly LocalInfo LocalInfo;
LocalBuilder builder;
diff -ru orig/mono-1.9.1-checkout/mono/metadata/reflection.c mono-1.9.1-checkout/mono/metadata/reflection.c
--- orig/mono-1.9.1-checkout/mono/metadata/reflection.c 2025-06-09 11:58:58.903462701 +0200
+++ mono-1.9.1-checkout/mono/metadata/reflection.c 2025-06-09 18:44:58.063693593 +0200
@@ -4851,7 +4851,7 @@
header->coff.coff_machine = GUINT16_FROM_LE (assemblyb->machine);
header->coff.coff_sections = GUINT16_FROM_LE (nsections);
- header->coff.coff_time = GUINT32_FROM_LE (time (NULL));
+ header->coff.coff_time = GUINT32_FROM_LE (getenv("SOURCE_DATE_EPOCH") ? atoi(getenv("SOURCE_DATE_EPOCH")) : time (NULL));
header->coff.coff_opt_header_size = GUINT16_FROM_LE (sizeof (MonoDotNetHeader) - sizeof (MonoCOFFHeader) - 4);
if (assemblyb->pekind == 1) {
/* it's a dll */
--- orig/mono-1.9.1-checkout/mono/metadata/reflection.c 2025-07-06 21:51:39.127926599 +0200
+++ mono-1.9.1-checkout/mono/metadata/reflection.c 2025-07-06 21:54:27.468828555 +0200
@@ -4485,12 +4485,24 @@
int nsections = 0;
/* alignment constraints */
- assembly->code.index += 3;
- assembly->code.index &= ~3;
+ guint32 old_code_index = assembly->code.index;
+ guint32 new_code_index = (old_code_index + 3) & ~3;
+ if (new_code_index > old_code_index) {
+ guint32 padding_needed = new_code_index - old_code_index;
+ make_room_in_stream (&assembly->code, new_code_index);
+ memset (assembly->code.data + old_code_index, 0, padding_needed);
+ assembly->code.index = new_code_index;
+ }
assembly->meta_size += 3;
assembly->meta_size &= ~3;
- assembly->resources.index += 3;
- assembly->resources.index &= ~3;
+ guint32 old_res_index = assembly->resources.index;
+ guint32 new_res_index = (old_res_index + 3) & ~3;
+ if (new_res_index > old_res_index) {
+ guint32 padding_needed = new_res_index - old_res_index;
+ make_room_in_stream (&assembly->resources, new_res_index);
+ memset (assembly->resources.data + old_res_index, 0, padding_needed);
+ assembly->resources.index = new_res_index;
+ }
assembly->sections [MONO_SECTION_TEXT].size = assembly->meta_size + assembly->code.index + assembly->resources.index + assembly->strong_name_size;
assembly->sections [MONO_SECTION_TEXT].attrs = SECT_FLAGS_HAS_CODE | SECT_FLAGS_MEM_EXECUTE | SECT_FLAGS_MEM_READ;
|