summaryrefslogtreecommitdiff
path: root/gnu/packages/dotnet.scm
diff options
context:
space:
mode:
authorDanny Milosavljevic <dannym@friendly-machines.com>2026-04-08 17:06:24 +0200
committerDanny Milosavljevic <dannym@friendly-machines.com>2026-07-17 01:41:57 +0200
commitd71affea0c59266b8fc75377c3e6d32878a29b56 (patch)
tree6ae944e7d71a8b7e6b938ec4ed7fd7658e01a9d8 /gnu/packages/dotnet.scm
parentce5aae4199f0cbd08b6460f568fcbcdef58d9160 (diff)
gnu: Add roslyn@3.0.0.
* gnu/packages/patches/roslyn-3.0.0-bootstrap-with-csc-2.8.patch: New file. * gnu/local.mk (dist_patch_DATA): Add reference to it. * gnu/packages/dotnet.scm (roslyn-3.0): New variable. Change-Id: I385b29abff8c0b4672125786b948aafdd69cb014
Diffstat (limited to 'gnu/packages/dotnet.scm')
-rw-r--r--gnu/packages/dotnet.scm174
1 files changed, 174 insertions, 0 deletions
diff --git a/gnu/packages/dotnet.scm b/gnu/packages/dotnet.scm
index 2564dc2f33f..b914d29fe60 100644
--- a/gnu/packages/dotnet.scm
+++ b/gnu/packages/dotnet.scm
@@ -2783,6 +2783,180 @@ namespace Microsoft.DiaSymReader
2783 "This package provides the Roslyn C# compiler (@command{csc}), built 2783 "This package provides the Roslyn C# compiler (@command{csc}), built
2784from source using @code{roslyn-2.3} as the bootstrap compiler. It produces 2784from source using @code{roslyn-2.3} as the bootstrap compiler. It produces
2785a C# 7.2 compiler."))) 2785a C# 7.2 compiler.")))
2786
2787;;;
2788;;; roslyn-3.0: inherits roslyn-2.8, built with csc 2.8
2789;;;
2790
2791(define-public roslyn-3.0
2792 (package
2793 (inherit roslyn-2.8)
2794 (version "3.0.0")
2795 (source
2796 (origin
2797 (method git-fetch)
2798 (uri (git-reference
2799 (url "https://github.com/dotnet/roslyn")
2800 (commit (string-append "version-" version))))
2801 (file-name (git-file-name "roslyn" version))
2802 (sha256
2803 (base32
2804 "17x9bapqaaapa7jsb2sz9pm20swgj40naxlgci4nc9xh7brahcqw"))
2805 (patches
2806 (search-patches "roslyn-3.0.0-bootstrap-with-csc-2.8.patch"))))
2807 (native-inputs (list roslyn-2.8))
2808 (arguments
2809 (substitute-keyword-arguments (package-arguments roslyn-2.8)
2810 ((#:phases phases '())
2811 #~(modify-phases #$phases
2812 ;; No compiler-compat or mono-compat fixes needed for 3.0;
2813 ;; the patch handles ReadOnlySpan and other changes.
2814 ;; KeyValuePair helper was removed in 3.0.
2815 (replace 'fix-compiler-compat
2816 (lambda _ #t))
2817 (replace 'fix-mono-compat
2818 (lambda _
2819 ;; Only CodePagesEncodingProvider remains.
2820 (substitute* "src/Compilers/Core/Portable/EncodedStringText.cs"
2821 (("if \\(CodePagesEncodingProvider\\.Instance != null\\)")
2822 "if (false)")
2823 (("Encoding\\.RegisterProvider\\(CodePagesEncodingProvider\\.Instance\\);")
2824 "// not available in Mono"))))
2825
2826 ;; 3.0 has more files with PathUtilities ambiguity.
2827 (add-after 'fix-srm-inline 'fix-srm-inline-3.0
2828 (lambda _
2829 (substitute* (list
2830 "src/Compilers/Core/Portable/StrongName/DesktopStrongNameProvider.cs"
2831 "src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerFileReference.cs")
2832 (("\\bPathUtilities\\.")
2833 "Roslyn.Utilities.PathUtilities."))))
2834
2835 ;; 3.0 has no stale files from 2.x. Only DiaSymReader COM
2836 ;; files need stubbing (inherited from create-diasymreader-stubs).
2837 ;; Rename file with trailing space in its name.
2838 (replace 'remove-stale-files
2839 (lambda _
2840 (rename-file
2841 "src/Compilers/Core/Portable/Operations/IConstructorBodyOperation .cs"
2842 "src/Compilers/Core/Portable/Operations/IConstructorBodyOperation.cs")
2843 (for-each
2844 (lambda (f) (when (file-exists? f) (delete-file f)))
2845 '("src/Compilers/Core/Portable/DiaSymReader/Utilities/IUnsafeComStream.cs"
2846 "src/Compilers/Core/Portable/DiaSymReader/Utilities/ComMemoryStream.cs"))))
2847
2848 ;; csc.rsp: C# 7.3 langversion, NET472 define (was NET46 in 2.8).
2849 (replace 'create-csc-rsp
2850 (lambda _
2851 (call-with-output-file "csc.rsp"
2852 (lambda (port)
2853 (display "-langversion:7.3\n-d:NET472\n" port)))))
2854
2855 ;; Point at roslyn-2.8's csc.
2856 (replace 'create-csc-wrapper
2857 (lambda* (#:key inputs #:allow-other-keys)
2858 (mkdir-p "bootstrap-bin")
2859 (call-with-output-file "bootstrap-bin/csc"
2860 (lambda (port)
2861 (format port "#!~a~%exec mono ~a \"$@\"~%"
2862 (which "bash")
2863 (string-append (assoc-ref inputs "roslyn") "/lib/roslyn/csc.exe"))))
2864 (chmod "bootstrap-bin/csc" #o755)
2865 (setenv "PATH"
2866 (string-append (getcwd) "/bootstrap-bin:"
2867 (getenv "PATH")))))
2868
2869 ;; 3.0 csc.exe needs additional shared files.
2870 (replace 'compile
2871 (lambda* (#:key inputs #:allow-other-keys)
2872 (let* ((sci-dll
2873 (search-input-file
2874 inputs "/lib/mono/4.5/System.Collections.Immutable.dll"))
2875 (srm-dir
2876 (if (file-exists? "srm-src-patched")
2877 "srm-src-patched"
2878 #$%srm-source-dir))
2879 (srm-source-files
2880 (filter
2881 (lambda (f)
2882 (not (or (string-contains f "netstandard")
2883 (string-contains f "netcoreapp")
2884 (string-contains f "AssemblyInfo")
2885 (string-suffix? "/SR.cs" f))))
2886 (find-files srm-dir "\\.cs$")))
2887 (deps-dir
2888 (if (file-exists? "src/Dependencies/CodeAnalysis.Metadata")
2889 "src/Dependencies/CodeAnalysis.Metadata"
2890 "src/Dependencies/CodeAnalysis.Debugging")))
2891
2892 ;; 1. Microsoft.CodeAnalysis.dll
2893 (apply invoke "csc" "@csc.rsp" "-target:library" "-unsafe"
2894 "-out:Microsoft.CodeAnalysis.dll"
2895 (string-append
2896 "-resource:Microsoft.CodeAnalysis.CodeAnalysisResources.resources"
2897 ",Microsoft.CodeAnalysis.CodeAnalysisResources.resources")
2898 "-r:System.dll" "-r:System.Core.dll"
2899 "-r:System.Xml.dll" "-r:System.Xml.Linq.dll"
2900 "-r:System.Numerics.dll" "-r:System.IO.Compression.dll"
2901 "-r:System.Security.dll"
2902 "-r:System.Runtime.Serialization.dll"
2903 (string-append "-r:" sci-dll)
2904 "-d:COMPILERCORE" "-d:SRM"
2905 "bootstrap-sr.cs" "bootstrap-ivt.cs"
2906 "src/Compilers/Shared/CoreClrShim.cs"
2907 "src/Compilers/Shared/DesktopShim.cs"
2908 (append
2909 (find-files "src/Compilers/Core/Portable" "\\.cs$")
2910 (find-files "src/Compilers/Core/AnalyzerDriver" "\\.cs$")
2911 (find-files deps-dir "\\.cs$")
2912 (find-files "src/Dependencies/PooledObjects" "\\.cs$")
2913 srm-source-files))
2914
2915 ;; 2. Microsoft.CodeAnalysis.CSharp.dll
2916 (apply invoke "csc" "@csc.rsp" "-target:library" "-unsafe"
2917 "-out:Microsoft.CodeAnalysis.CSharp.dll"
2918 (string-append
2919 "-resource:Microsoft.CodeAnalysis.CSharp.CSharpResources.resources"
2920 ",Microsoft.CodeAnalysis.CSharp.CSharpResources.resources")
2921 "-r:System.dll" "-r:System.Core.dll"
2922 "-r:System.Xml.dll" "-r:System.Xml.Linq.dll"
2923 "-r:System.Numerics.dll" "-r:System.IO.Compression.dll"
2924 (string-append "-r:" sci-dll)
2925 "-r:Microsoft.CodeAnalysis.dll"
2926 "bootstrap-csharp-ivt.cs"
2927 "src/Compilers/CSharp/CSharpAnalyzerDriver/CSharpDeclarationComputer.cs"
2928 (append
2929 (find-files "src/Compilers/CSharp/Portable" "\\.cs$")
2930 (if (file-exists? "generated")
2931 (find-files "generated" "\\.cs$")
2932 '())))
2933
2934 ;; 3. csc.exe - 3.0 added RuntimeHostInfo and NamedPipeUtil.
2935 (invoke "csc" "@csc.rsp" "-out:csc.exe"
2936 "-r:System.dll" "-r:System.Core.dll"
2937 (string-append "-r:" sci-dll)
2938 "-r:Microsoft.CodeAnalysis.dll"
2939 "-r:Microsoft.CodeAnalysis.CSharp.dll"
2940 "src/Compilers/CSharp/csc/Program.cs"
2941 "src/Compilers/Shared/Csc.cs"
2942 "src/Compilers/Shared/BuildClient.cs"
2943 "src/Compilers/Shared/BuildServerConnection.cs"
2944 "src/Compilers/Shared/DesktopBuildClient.cs"
2945 "src/Compilers/Shared/DesktopAnalyzerAssemblyLoader.cs"
2946 "src/Compilers/Shared/ExitingTraceListener.cs"
2947 "src/Compilers/Shared/CoreClrShim.cs"
2948 "src/Compilers/Shared/DesktopShim.cs"
2949 "src/Compilers/Shared/RuntimeHostInfo.cs"
2950 "src/Compilers/Shared/NamedPipeUtil.cs"
2951 "src/Compilers/Core/CommandLine/BuildProtocol.cs"
2952 "src/Compilers/Core/CommandLine/NativeMethods.cs"
2953 "src/Compilers/Core/CommandLine/ConsoleUtil.cs"
2954 "src/Compilers/Core/CommandLine/CompilerServerLogger.cs"))))))))
2955 (synopsis "C# 8.0 compiler bootstrapped from source")
2956 (description
2957 "This package provides the Roslyn C# compiler (@command{csc}), built
2958from source using @code{roslyn-2.8} as the bootstrap compiler. It produces
2959a C# 8.0 compiler.")))
2786;; too new version: 15.9.21.664 2960;; too new version: 15.9.21.664
2787;; too old (no support for mono) version: 14.0 2961;; too old (no support for mono) version: 14.0
2788(define-public msbuild 2962(define-public msbuild