gnu: mono@2.4.2.3: Make it reproducible.

* gnu/packages/patches/mono-2.4.2.3-fix-parallel-builds.patch: New file.
* gnu/packages/patches/mono-2.4.2.3-reproducibility.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add references to those patches.
* gnu/packages/dotnet.scm (mono-2.4.2.3)[source]: Use those patches.
[arguments]<#:phases>[disable-mono-mini-timestamps]: New phase.

Change-Id: Ib0a57d2e93b8b72c10fa9854a77eadeee578266c
Reviewed-by: Ludovic Courtès <ludo@gnu.org>
Signed-off-by: Sharlatan Hellseher <sharlatanus@gmail.com>
This commit is contained in:
Danny Milosavljevic 2025-06-10 17:15:08 +02:00 committed by Sharlatan Hellseher
parent 4f10384b54
commit fd256bb786
No known key found for this signature in database
GPG key ID: 76D727BFF62CD2B5
5 changed files with 90 additions and 12 deletions

View file

@ -1892,6 +1892,8 @@ dist_patch_DATA = \
%D%/packages/patches/mono-1.9.1-fixes.patch \ %D%/packages/patches/mono-1.9.1-fixes.patch \
%D%/packages/patches/mono-1.9.1-reproducibility.patch \ %D%/packages/patches/mono-1.9.1-reproducibility.patch \
%D%/packages/patches/mono-2.4.2.3-fixes.patch \ %D%/packages/patches/mono-2.4.2.3-fixes.patch \
%D%/packages/patches/mono-2.4.2.3-fix-parallel-builds.patch \
%D%/packages/patches/mono-2.4.2.3-reproducibility.patch \
%D%/packages/patches/mono-2.6.4-fixes.patch \ %D%/packages/patches/mono-2.6.4-fixes.patch \
%D%/packages/patches/mono-2.11.4-fixes.patch \ %D%/packages/patches/mono-2.11.4-fixes.patch \
%D%/packages/patches/mono-4.9.0-fix-runtimemetadataversion.patch \ %D%/packages/patches/mono-4.9.0-fix-runtimemetadataversion.patch \

View file

@ -497,7 +497,9 @@ a C-style programming language from Microsoft that is very similar to Java.")
(modules '((guix build utils) (modules '((guix build utils)
(ice-9 string-fun))) (ice-9 string-fun)))
(snippet prepare-mono-source) (snippet prepare-mono-source)
(patches (search-patches "mono-2.4.2.3-fixes.patch")))) (patches (search-patches "mono-2.4.2.3-reproducibility.patch"
"mono-2.4.2.3-fixes.patch"
"mono-2.4.2.3-fix-parallel-builds.patch"))))
(native-inputs (modify-inputs (package-native-inputs mono-1.9.1) (native-inputs (modify-inputs (package-native-inputs mono-1.9.1)
(replace "mono" mono-1.9.1))) (replace "mono" mono-1.9.1)))
(inputs (modify-inputs (package-inputs mono-1.9.1) (inputs (modify-inputs (package-inputs mono-1.9.1)
@ -513,6 +515,13 @@ a C-style programming language from Microsoft that is very similar to Java.")
#f) #f)
((#:phases phases #~%standard-phases) ((#:phases phases #~%standard-phases)
#~(modify-phases #$phases #~(modify-phases #$phases
(add-after 'unpack 'disable-mono-mini-timestamps
(lambda _
;; Note: Newer monos have mono/mini/Makefile.am.in .
(substitute* '("mono/mini/Makefile.am")
(("`date`")
;; This timestamp is the same as SOURCE_DATE_EPOCH.
"Tue Jan 1 12:00:00 AM UTC 1980"))))
(add-before 'bootstrap 'patch-sub-autogen.sh-shebang (add-before 'bootstrap 'patch-sub-autogen.sh-shebang
(lambda _ (lambda _
(patch-shebang "eglib/autogen.sh"))))))) (patch-shebang "eglib/autogen.sh")))))))

View file

@ -29,7 +29,7 @@ diff -ru orig/mono-1.9.1-checkout/mcs/class/Mono.Cecil/Mono.Cecil.Binary/ImageIn
+ // fallthrough + // fallthrough
+ } + }
+ } + }
+ +
return (uint) DateTime.UtcNow.Subtract ( return (uint) DateTime.UtcNow.Subtract (
new DateTime (1970, 1, 1)).TotalSeconds; new DateTime (1970, 1, 1)).TotalSeconds;
} }
@ -49,9 +49,9 @@ diff -ru orig/mono-1.9.1-checkout/mcs/mcs/anonymous.cs mono-1.9.1-checkout/mcs/m
} }
+// +//
+// A robust, standalone, and deterministic comparer for all types that +// A comparer for all types that inherit from the abstract class 'Variable'.
+// inherit from the abstract class 'Variable'. This version uses only +// Uses only C# 2.0 compatible syntax.
+// C# 2.0 compatible syntax. +//
+// +//
+public class VariableComparer : System.Collections.IComparer +public class VariableComparer : System.Collections.IComparer
+{ +{
@ -61,25 +61,25 @@ diff -ru orig/mono-1.9.1-checkout/mcs/mcs/anonymous.cs mono-1.9.1-checkout/mcs/m
+ // Case 1: The object is a 'CapturedVariable' or any of its children. + // Case 1: The object is a 'CapturedVariable' or any of its children.
+ if (obj is ScopeInfo.CapturedVariable) + if (obj is ScopeInfo.CapturedVariable)
+ { + {
+ // Explicit cast required for C# 2.0 +
+ ScopeInfo.CapturedVariable cv = (ScopeInfo.CapturedVariable)obj; + ScopeInfo.CapturedVariable cv = (ScopeInfo.CapturedVariable)obj;
+ return cv.Name; + return cv.Name;
+ } + }
+ +
+ // Case 2: The object is a 'LocalVariable' from statement.cs. + // Case 2: The object is a 'LocalVariable'
+ if (obj is LocalInfo.LocalVariable) + if (obj is LocalInfo.LocalVariable)
+ { + {
+ // Explicit cast required for C# 2.0 + // Explicit cast required for C# 2.0
+ LocalInfo.LocalVariable lv = (LocalInfo.LocalVariable)obj; + LocalInfo.LocalVariable lv = (LocalInfo.LocalVariable)obj;
+ return lv.LocalInfo.Name; + return lv.LocalInfo.Name;
+ } + }
+ +
+ // + //
+ // Fallback for any other unknown 'Variable' subtype. + // Fallback for any other unknown 'Variable' subtype.
+ // + //
+ return obj.GetType().FullName; + return obj.GetType().FullName;
+ } + }
+ +
+ // The single method required by the IComparer interface. + // The single method required by the IComparer interface.
+ public int Compare(object x, object y) + public int Compare(object x, object y)
+ { + {
@ -90,15 +90,15 @@ diff -ru orig/mono-1.9.1-checkout/mcs/mcs/anonymous.cs mono-1.9.1-checkout/mcs/m
+ +
+ string name_x = GetVariableName(x); + string name_x = GetVariableName(x);
+ string name_y = GetVariableName(y); + string name_y = GetVariableName(y);
+ +
+ // 1. Primary Sort Key: The extracted variable name. + // Primary Sort Key: The extracted variable name.
+ int name_compare = string.CompareOrdinal(name_x, name_y); + int name_compare = string.CompareOrdinal(name_x, name_y);
+ if (name_compare != 0) + if (name_compare != 0)
+ { + {
+ return name_compare; + return name_compare;
+ } + }
+ +
+ // 2. Secondary Sort Key (Stable Tie-breaker): The full type name. + // Secondary Sort Key (Tie-breaker): The full type name.
+ return string.CompareOrdinal(x.GetType().FullName, y.GetType().FullName); + return string.CompareOrdinal(x.GetType().FullName, y.GetType().FullName);
+ } + }
+} +}

View file

@ -0,0 +1,20 @@
Author: Danny Milosavljevic <dannym@friendly-machines.com>
Date: Mon Jun 9 12:06:40 PM CEST 2025
Subject: Fix parallel builds
diff -ru orig/7pmpv2pzi9xirz7fc8pzjb9d1qnscvdh-mono-2.4.2.3-checkout/scripts/Makefile.am 7pmpv2pzi9xirz7fc8pzjb9d1qnscvdh-mono-2.4.2.3-checkout/scripts/Makefile.am
--- orig/7pmpv2pzi9xirz7fc8pzjb9d1qnscvdh-mono-2.4.2.3-checkout/scripts/Makefile.am 2025-06-09 12:02:29.749177390 +0200
+++ 7pmpv2pzi9xirz7fc8pzjb9d1qnscvdh-mono-2.4.2.3-checkout/scripts/Makefile.am 2025-06-09 12:05:00.125919505 +0200
@@ -236,9 +236,6 @@
mv $@.tmp $@
$(MDOC_SUBCOMMANDS): Makefile
- for script in $(MDOC_SUBCOMMANDS) ; do \
- cmd=`echo $$script | sed 's/mdoc-//'` ; \
- echo "#!/bin/sh" > $$script ; \
- echo "exec mdoc $$cmd \"\$$@\"" >> $$script; \
- done
-
+ cmd=`echo $@ | sed 's/mdoc-//'` ; \
+ echo "#!/bin/sh" > $@ ; \
+ echo "exec mdoc $$cmd \"\$$@\"" >> $@

View file

@ -0,0 +1,47 @@
Author: Danny Milosavljevic <dannym@friendly-machines.com>
Date: Mon Jun 9 01:19:28 PM CEST 2025
Subject: Make mono 2.4.2.3 reprodubile.
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/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 */