summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanny Milosavljevic <dannym@friendly-machines.com>2026-04-10 18:00:21 +0200
committerDanny Milosavljevic <dannym@friendly-machines.com>2026-07-17 01:41:57 +0200
commit8bd02af8349e07a2b93db8451054bf4ab78f56d8 (patch)
tree51ada2fb68b3f8798df3dbbc05a1852ebbeb74a8
parent1e78c108e5e3bce2f53437baf1390545c11c184b (diff)
gnu: Add roslyn@3.9.0.
* gnu/packages/patches/roslyn-3.9.0-bootstrap-with-csc-3.8.patch: New file. * gnu/local.mk (dist_patch_DATA): Add reference to it. * gnu/packages/dotnet.scm (roslyn-3.9): New variable. (roslyn): Replace variable. Change-Id: I1910ce649e10122a7dea87866a4a33869f7d855c
-rw-r--r--gnu/local.mk1
-rw-r--r--gnu/packages/dotnet.scm93
-rw-r--r--gnu/packages/patches/roslyn-3.9.0-bootstrap-with-csc-3.8.patch84
3 files changed, 177 insertions, 1 deletions
diff --git a/gnu/local.mk b/gnu/local.mk
index 99140d48ce0..6bcf4b22e0b 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -2430,6 +2430,7 @@ dist_patch_DATA = \
2430 %D%/packages/patches/roslyn-3.0.0-bootstrap-with-csc-2.8.patch \ 2430 %D%/packages/patches/roslyn-3.0.0-bootstrap-with-csc-2.8.patch \
2431 %D%/packages/patches/roslyn-3.2.0-bootstrap-with-csc-3.0.patch \ 2431 %D%/packages/patches/roslyn-3.2.0-bootstrap-with-csc-3.0.patch \
2432 %D%/packages/patches/roslyn-3.8.0-bootstrap-with-csc-3.2.patch \ 2432 %D%/packages/patches/roslyn-3.8.0-bootstrap-with-csc-3.2.patch \
2433 %D%/packages/patches/roslyn-3.9.0-bootstrap-with-csc-3.8.patch \
2433 %D%/packages/patches/rottlog-direntry.patch \ 2434 %D%/packages/patches/rottlog-direntry.patch \
2434 %D%/packages/patches/ruby-actionpack-remove-browser-tests.patch \ 2435 %D%/packages/patches/ruby-actionpack-remove-browser-tests.patch \
2435 %D%/packages/patches/ruby-activesupport-fix-deprecation-warning.patch \ 2436 %D%/packages/patches/ruby-activesupport-fix-deprecation-warning.patch \
diff --git a/gnu/packages/dotnet.scm b/gnu/packages/dotnet.scm
index 350147536a4..ee2bbb9d033 100644
--- a/gnu/packages/dotnet.scm
+++ b/gnu/packages/dotnet.scm
@@ -3453,7 +3453,98 @@ using System.Reflection;
3453scripting libraries, built from source using @code{roslyn-3.2} as the 3453scripting libraries, built from source using @code{roslyn-3.2} as the
3454bootstrap compiler. It produces a C# 9.0 compiler matching Mono 6.12."))) 3454bootstrap compiler. It produces a C# 9.0 compiler matching Mono 6.12.")))
3455 3455
3456(define roslyn roslyn-3.8) 3456;; roslyn-3.9: inherits roslyn-3.8, built with csc 3.8.
3457;; Upstream mono 6.12.0.206 ships 3.9.0 (roslyn-binaries commit
3458;; 1c6482470c). Both 3.8 and 3.9 implement C# 9. The only
3459;; 3.9-specific change is project-wide nullable enable (was per-file
3460;; in 3.8), plus a few new Mono-compat fixes in the patch
3461;; (CodePagesEncodingProvider in BuildClient.cs, Unsafe.As in
3462;; ImmutableArrayExtensions.cs).
3463(define-public roslyn-3.9
3464 (package
3465 (inherit roslyn-3.8)
3466 (version "3.9.0")
3467 (source
3468 (origin
3469 (method git-fetch)
3470 (uri (git-reference
3471 (url "https://github.com/dotnet/roslyn")
3472 (commit (string-append "v" version))))
3473 (file-name (git-file-name "roslyn" version))
3474 (sha256
3475 (base32
3476 "1kgm9aq5kd3cb8hw7nrmdyxlxw0blxvhdayyc0f28dzns2ph6v58"))
3477 (patches
3478 (search-patches "roslyn-3.9.0-bootstrap-with-csc-3.8.patch"))))
3479 (native-inputs (list roslyn-3.8))
3480 (arguments
3481 (substitute-keyword-arguments (package-arguments roslyn-3.8)
3482 ((#:phases phases '())
3483 #~(modify-phases #$phases
3484 ;; Point at roslyn-3.8's csc.
3485 (replace 'create-csc-wrapper
3486 (lambda* (#:key inputs #:allow-other-keys)
3487 (mkdir-p "bootstrap-bin")
3488 (call-with-output-file "bootstrap-bin/csc"
3489 (lambda (port)
3490 (format port "#!~a~%exec mono ~a \"$@\"~%"
3491 (which "bash")
3492 (string-append (assoc-ref inputs "roslyn")
3493 "/lib/roslyn/csc.exe"))))
3494 (chmod "bootstrap-bin/csc" #o755)
3495 (setenv "PATH"
3496 (string-append (getcwd) "/bootstrap-bin:"
3497 (getenv "PATH")))))
3498
3499 ;; 3.9 uses project-wide nullable enable instead of
3500 ;; per-file #nullable enable directives.
3501 (replace 'create-csc-rsp
3502 (lambda _
3503 (call-with-output-file "csc.rsp"
3504 (lambda (port)
3505 (display
3506 "-langversion:preview\n-d:NET472\n-nullable:enable\n"
3507 port)))))
3508
3509 ;; Broad Mono workarounds that are impractical in a patch
3510 ;; (too many files). Targeted fixes are in the patch.
3511 (add-after 'unpack 'fix-mono-compat-3.9
3512 (lambda _
3513 ;; SignatureCallingConvention.Unmanaged (value 9) not
3514 ;; in Mono's SRM. The enum initializer in Members.cs
3515 ;; is handled by the patch; sweep remaining uses.
3516 (for-each
3517 (lambda (file)
3518 (substitute* file
3519 (("SignatureCallingConvention\\.Unmanaged")
3520 "(SignatureCallingConvention)9")))
3521 (append
3522 (find-files "src/Compilers/Core/Portable" "\\.cs$")
3523 (find-files "src/Compilers/CSharp/Portable" "\\.cs$")))
3524 ;; PathUtilities ambiguity with SRM (too many files
3525 ;; to patch individually).
3526 (for-each
3527 (lambda (file)
3528 (substitute* file
3529 (("\\bPathUtilities\\.")
3530 "Roslyn.Utilities.PathUtilities.")))
3531 (append
3532 (find-files "src/Compilers/Core/Portable" "\\.cs$")
3533 (find-files "src/Scripting" "\\.cs$")))
3534 ;; Index/Range polyfills are internal and shadow Mono's
3535 ;; public mscorlib types. Delete so csc finds the
3536 ;; mscorlib versions.
3537 (delete-file
3538 "src/Compilers/Core/Portable/InternalUtilities/Index.cs")
3539 (delete-file
3540 "src/Compilers/Core/Portable/InternalUtilities/Range.cs")))))))
3541 (synopsis "C# 9.0 compiler and scripting libraries, bootstrapped from source")
3542 (description
3543 "This package provides the Roslyn C# compiler (@command{csc}) and
3544scripting libraries, built from source using @code{roslyn-3.8} as the
3545bootstrap compiler. This is the version shipped by upstream Mono 6.12.")))
3546
3547(define roslyn roslyn-3.9)
3457 3548
3458;; too new version: 15.9.21.664 3549;; too new version: 15.9.21.664
3459;; too old (no support for mono) version: 14.0 3550;; too old (no support for mono) version: 14.0
diff --git a/gnu/packages/patches/roslyn-3.9.0-bootstrap-with-csc-3.8.patch b/gnu/packages/patches/roslyn-3.9.0-bootstrap-with-csc-3.8.patch
new file mode 100644
index 00000000000..2cb8bf84ccf
--- /dev/null
+++ b/gnu/packages/patches/roslyn-3.9.0-bootstrap-with-csc-3.8.patch
@@ -0,0 +1,84 @@
1--- a/src/Compilers/CSharp/Portable/Compilation/CSharpCompilation.cs
2+++ b/src/Compilers/CSharp/Portable/Compilation/CSharpCompilation.cs
3@@ -2214,7 +2214,7 @@
4
5 private BinderFactory GetBinderFactory(SyntaxTree syntaxTree, bool ignoreAccessibility, ref WeakReference<BinderFactory>[]? cachedBinderFactories)
6 {
7- Debug.Assert(System.Runtime.CompilerServices.Unsafe.AreSame(ref cachedBinderFactories, ref ignoreAccessibility ? ref _ignoreAccessibilityBinderFactories : ref _binderFactories));
8+ // Unsafe.AreSame not available on Mono
9
10 var treeNum = GetSyntaxTreeOrdinal(syntaxTree);
11 WeakReference<BinderFactory>[]? binderFactories = cachedBinderFactories;
12--- a/src/Compilers/Shared/BuildClient.cs
13+++ b/src/Compilers/Shared/BuildClient.cs
14@@ -84,7 +84,7 @@
15 {
16 // Register encodings for console
17 // https://github.com/dotnet/roslyn/issues/10785
18- System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
19+ // CodePagesEncodingProvider not available on Mono
20 }
21
22 var client = new BuildClient(language, compileFunc, logger);
23--- a/src/Compilers/Core/Portable/PEWriter/Members.cs
24+++ b/src/Compilers/Core/Portable/PEWriter/Members.cs
25@@ -58,7 +58,7 @@
26 /// Extensible calling convention protocol. This represents either the union of calling convention modopts after the paramcount specifier
27 /// in IL, or platform default if none are present
28 /// </summary>
29- Unmanaged = SignatureCallingConvention.Unmanaged,
30+ Unmanaged = 9,
31
32 /// <summary>
33 /// The convention for calling a generic method.
34--- a/src/Compilers/Core/Portable/PEWriter/PeWriter.cs
35+++ b/src/Compilers/Core/Portable/PEWriter/PeWriter.cs
36@@ -350,7 +350,7 @@
37 _resourceSection = resourceSection;
38 }
39
40- protected override void Serialize(BlobBuilder builder, SectionLocation location)
41+ protected internal override void Serialize(BlobBuilder builder, SectionLocation location)
42 {
43 NativeResourceWriter.SerializeWin32Resources(builder, _resourceSection, location.RelativeVirtualAddress);
44 }
45@@ -366,7 +366,7 @@
46 _resources = resources;
47 }
48
49- protected override void Serialize(BlobBuilder builder, SectionLocation location)
50+ protected internal override void Serialize(BlobBuilder builder, SectionLocation location)
51 {
52 NativeResourceWriter.SerializeWin32Resources(builder, _resources, location.RelativeVirtualAddress);
53 }
54--- a/src/Compilers/Core/Portable/Emit/EditAndContinue/DeltaMetadataWriter.cs
55+++ b/src/Compilers/Core/Portable/Emit/EditAndContinue/DeltaMetadataWriter.cs
56@@ -635,7 +635,7 @@
57
58 if (localVariables.Length > 0)
59 {
60- var writer = PooledBlobBuilder.GetInstance();
61+ var writer = Microsoft.Cci.PooledBlobBuilder.GetInstance();
62 var encoder = new BlobEncoder(writer).LocalVariableSignature(localVariables.Length);
63
64 foreach (ILocalDefinition local in localVariables)
65--- a/src/Compilers/Core/Portable/Collections/ImmutableArrayExtensions.cs
66+++ b/src/Compilers/Core/Portable/Collections/ImmutableArrayExtensions.cs
67@@ -669,7 +669,7 @@
68 // TODO(https://github.com/dotnet/corefx/issues/34126): Remove when System.Collections.Immutable
69 // provides a Span API
70 internal static T[] DangerousGetUnderlyingArray<T>(this ImmutableArray<T> array)
71- => Unsafe.As<ImmutableArray<T>, ImmutableArrayProxy<T>>(ref array).MutableArray;
72+ => System.Linq.Enumerable.ToArray(array);
73
74 internal static ReadOnlySpan<T> AsSpan<T>(this ImmutableArray<T> array)
75 => array.DangerousGetUnderlyingArray();
76@@ -678,7 +678,7 @@
77 {
78 var proxy = new ImmutableArrayProxy<T> { MutableArray = array };
79 array = null!;
80- return Unsafe.As<ImmutableArrayProxy<T>, ImmutableArray<T>>(ref proxy);
81+ return System.Collections.Immutable.ImmutableArray.Create(proxy.MutableArray);
82 }
83
84 internal static Dictionary<K, ImmutableArray<T>> ToDictionary<K, T>(this ImmutableArray<T> items, Func<T, K> keySelector, IEqualityComparer<K>? comparer = null)