summaryrefslogtreecommitdiff
path: root/gnu/packages/dotnet.scm
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 /gnu/packages/dotnet.scm
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
Diffstat (limited to 'gnu/packages/dotnet.scm')
-rw-r--r--gnu/packages/dotnet.scm93
1 files changed, 92 insertions, 1 deletions
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