csharpc

06 — Roadmap

Status legend: ✅ supported (differential-tested against .NET 11) · 🟡 partial · ⬜ planned · ❌ out of scope (same limits as NativeAOT)

The measuring stick is the conformance corpus (09-conformance.md): 100 % of its 195 feature programs, with zero wrong-output cases — every failure is a clean “not supported by csharpc yet” diagnostic. The differential suite (tests/samples, 663 programs recorded from real .NET) runs at -O0 and -O2 on five platforms in CI (05-testing.md).

Milestone status

The order is fixed by the owner: M2–M6 first, then M7, M8, M9. A milestone is done only when none of its bullets is open; M7 and later are not worked on until M2–M6 are done. Where a bullet has no issue of its own, the section of the milestone below says where it is tracked.

Milestone Status What is open
M0 Spike ✅ done
M1 Real programs ✅ done
M2 Library in C# 🟡 open BCL surface ranked by the NuGet survey (#146: #152 MathF PR #156, #157 PR #158, #159, #162); TLS and X.509 on macOS and Windows run over OpenSSL, the native routes are the spikes #143 and #144; the gap lists #89, #95–#104
M3 Platforms ✅ done per-platform limits are documented, see M3 below
M4 Real-world validation 🟡 open parity is 98.4 % (242 of 246) in the latest Compatibility run, down from 100 % (#163)
M5 Binary packages and the program as IL 🟡 open the BCL surface packages use (#146)
M6 Bootstrapping 🟡 open quadratic lowering on very large programs (#93)
M7 TechEmpower with the csharpc CLI ⏸ on hold (owner) started 2026-10-31 before M2–M6 were done, against the owner’s rule; on hold since 2026-11-05. Last good measurement 288 of 456 metrics ahead of NativeAOT; on main today csharpc does not build the entry (#164)
M8 The dotnet fork ⬜ not started
M9 TechEmpower through the fork ⬜ not started

Feature-support matrix

Program structure

Feature Status Notes
Top-level statements, Main (void/int, string[] args) ✅
async Task Main / async Task<int> Main ✅
Namespaces, nested types, partial classes/methods/properties ✅
Multi-file programs, .csproj input, ProjectReference ✅ whole-program, see 08-drop-in.md; each referenced project’s source generators run on that project’s own compilation, with its options and additional files
dotnet build -p:UseCsharpc=true, dotnet publish -p:PublishCsharpc=true ✅ Csharpc.Sdk package
File-based apps (#:property directives) ✅
Assemblies without sources: -r X.dll, <Reference>, NuGet PackageReference 🟡 IL front-end (M5): the IL side is complete except TypedReference, jmp and ckfinite (explicit diagnostics, no package needs them); RID-specific assemblies and native assets are selected for the target; packages can still hit BCL gaps (#146)
The program as IL: csharpc app.dll (csc’s output, the dotnet pipeline’s input) ✅ every sample passes through tests/run.sh --via-il (tests/il-main-known-failures.txt is empty); gaps between the two front-ends are bugs

Types

Feature Status Notes
Primitives, enums (incl. names in ToString) ✅
decimal, DateTime, TimeSpan, BigInteger, Half, Int128/UInt128 ✅ explicit NotSupportedException for Half.Parse of text within a double’s precision of a rounding midpoint, and for Int128/UInt128 format strings, culture-specific signs and parse styles beyond sign and white space
Strings, StringBuilder, string library, char ✅ culture-aware comparison and casing via ICU; StringBuilder is .NET’s chunked builder
Cultures (CultureInfo, RegionInfo, calendars), invariant mode ✅ .NET’s ICU implementation (19); no NLS on Windows
Arrays (1-D, jagged, multi-dimensional), Index/Range ✅
Classes, inheritance, virtual/abstract/sealed, base ✅
Primary constructors, required, init, field keyword ✅
Structs, readonly/ref struct, generic structs ✅
Nullable<T> incl. lifted operators and three-valued bool? ✅
Tuples, deconstruction (tuples and user Deconstruct) ✅ any number of elements: stored flat, the Rest nesting is only the CLR type name; Rest through IL’s ldflda only where the layouts agree (explicit diagnostic otherwise); sample 975
Records (class and struct), with ✅ synthesized members generated by csharpc
Anonymous types ✅
Interfaces, default methods, static abstract members ✅
Generics (types, methods, constraints, generic math, variance) ✅ monomorphized
Delegates, lambdas, closures, events (also in generic classes), multicast ✅
Pointers, fixed, stackalloc, function pointers, calli ✅ managed and unmanaged signatures, see M5
Span<T>, ReadOnlySpan<T>, Memory<T>, UTF-8 literals ✅
dynamic ✅ bound at compile time with Roslyn, per run-time type that can reach the operation, with the runtime binder’s rules and RuntimeBinderException messages; ExpandoObject and DynamicObject (ADR 0019); from IL too (csc’s call sites decoded into the same bindings)

Statements and expressions

Feature Status Notes
All loops, switch statements/expressions, goto ✅
Patterns: type, constant, relational, logical, property, positional, list, var ✅ list patterns with .. var rest slices on arrays, strings and spans (sample 133); a slice capture on any other type is an explicit diagnostic
try/catch/finally, filters, rethrow, custom exceptions ✅ Itanium EH
Exception.StackTrace, traces in ToString() 🟡 user and IL-compiled frames exact incl. lambdas, async, inlining, hidden frames, async markers (ADR 0012); frames inside the corelib’s BCL code only for common members (CSLLVM0006)
checked/unchecked ✅
using statements/declarations, lock ✅ real monitors
Iterators (yield), async/await, await foreach ✅ LLVM coroutines
Exceptions inside async methods, TaskCompletionSource, cancellation ✅
Object/collection initializers, collection expressions (incl. spreads) ✅
Interpolation with alignment/format, composite formatting ✅ current culture or provider; FormattableString
C# 14 extension members ✅
Query expressions / LINQ ✅ Roslyn’s query lowering over the framework’s System.Linq IL
Expression trees ✅ System.Linq.Expressions from IL, interpreted as under NativeAOT; lambdas lowered as Roslyn does (18)

Semantics and runtime

Feature Status Notes
Garbage collection ✅ conservative, non-moving mark-sweep; thread-safe (stop-the-world); opt-in nursery and concurrent marker (ADR 0004, ADR 0020)
Finalizers ✅ ~T() and IL Finalize overrides of the program’s classes, GC.SuppressFinalize/ReRegisterForFinalize/WaitForPendingFinalizers, resurrection, a finalizer thread (ADR 0021); the corelib’s own types declare none
Multithreading (Thread, Monitor, Interlocked, Parallel, thread pool, wait handles incl. Mutex and Semaphore) ✅ Task.Run and continuations run on the runtime’s thread pool; named mutexes in one process (14); shared between processes stays an explicit diagnostic (#174)
Unhandled exceptions (message + exit 134) ✅
Static initialization ✅ lazy per type with CoreCLR’s triggers, TypeInitializationException, separate statics per generic instantiation (sample 381)
Reflection 🟡 GetType(), typeof, names; System.Type predicates, generics, assignability and Type.Assembly over compile-time metadata (12-corelib.md); constructors, methods, properties, attributes (including the [Nullable]/[NullableContext] csc writes for #nullable enable source, ADR 0018), Invoke, CreateDelegate, closed-world MakeGenericType, fields (with GetValue/SetValue, including the compiler-generated backing field of field-like events, as Type.GetFields lists it), events and GetInterfaces, for the types [DynamicallyAccessedMembers] or a constant typeof(C).GetX(...) pattern reaches, also through a local assigned typeof(C). Explicit NotSupportedException where csharpc can’t answer as .NET does: a type no such flow reaches (also typeof(C) reached through a field, a parameter without the annotation or obj.GetType(), a lambda-captured local in IL), non-public fields of reference-assembly types, fixed buffers and ref fields, the [Nullable]/[NullableContext] attributes of the shapes csharpc doesn’t model (records, delegates, indexers, primary constructors, constrained type parameters, type aliases…: the untyped attribute queries throw), a struct’s event field, FieldInfo.FieldHandle, MakeByRefType, Reflection.Emit
Debug info (DWARF, gdb/lldb) ✅ -g; from IL, line tables and names come from the assembly’s portable PDB (13-debugging.md)

Library (BCL)

Area Status Notes
Console, Math, Environment, GC ✅ intrinsics + csrt
Reflection handles and member lookup (RuntimeTypeHandle, ParameterModifier, DefaultValueAttribute, Type.GetMember, TypeInfo.GetDeclaredProperty) 🟡 done except nested types (not in the reflection metadata) and a run-time-only handle for RunClassConstructor (12-corelib.md, samples 1232-1234)
System.MathF, float/double generic-math statics (Sin, Hypot, Lerp, SinPi, …) ✅ all public MathF members and IFloatingPointIeee754<T> for float/double, bit for bit against .NET on the same libm (12-corelib.md, samples 1226-1229; ReciprocalEstimate is the exact quotient)
Parsing/formatting numbers ✅ standard + custom format strings
System.Collections.Generic (List, Dictionary, HashSet, …), concurrent collections, BlockingCollection, Partitioner ✅ shadow corelib in C#
System.Linq ✅ the framework’s IL (ADR 0023)
System.Text.RegularExpressions ✅ the framework’s IL (all engines, [GeneratedRegex] by the SDK’s generator), 12-corelib.md
System.Text.Json ✅ writer, reader, DOM, nodes, JsonSchemaExporter; serializer over source-generated metadata, reflection-style calls included (12-corelib.md); gaps in #89, #100
Task, TaskFactory, EventSource/EventListener ✅ 10-async.md, 12-corelib.md
File I/O, sockets, HttpClient ✅ System.IO, sockets (TCP/UDP, TcpListener/TcpClient, Dns), HttpClient over HTTP/1.1 with system proxies and gzip/deflate/brotli (16-interop-io.md); gaps in #102
TLS: SslStream, X.509, https:// 🟡 Linux over OpenSSL 3 (ADR 0022); the same code on macOS and Windows as an interim (#143, #144); not on WebAssembly; gaps in #101

Standing goal: better than .NET in every area, always

Not a milestone that ends: every milestone is held to it, and a regression in any of these areas is a bug like a wrong output.

  • Drop-in, measured against NativeAOT: csharpc is an ahead-of-time compiler, so the support target is 100 % parity with what .NET NativeAOT supports: every program and library that works when published with PublishAot must work with csharpc, with the same behaviour (byte-identical output, exit codes, exception messages), the same inputs (.cs, .csproj, NuGet packages) and the same workflow (dotnet build/run/publish). What NativeAOT doesn’t support — measured by running it, e.g. Reflection.Emit, MakeGenericType over unseen instantiations, loading assemblies at run time — is out of scope (❌) and must stay an explicit diagnostic; what it does run (expression trees via its interpreter, dynamic) is in scope. The JIT is the behavioural oracle for the tests and a benchmark baseline, not a support target (ADR 0016). The finish line is M9: the dotnet fork with csharpc in NativeAOT’s place, beating NativeAOT on the TechEmpower benchmarks.
  • Safer (first priority): hardening on by default (17-security.md); code that moves from a shadow to upstream IL keeps every guard the shadow had. A security measure may cost speed and size (numbers in the commit). The checks .NET semantics require (bounds, casts, array covariance) are correctness, outside this order: they are never dropped, only made cheaper.
  • Faster (second priority): throughput ahead of NativeAOT and the JIT on every benchmark, on every platform; start-up and compile time measured too (compile time against dotnet publish -p:PublishAot=true). A speed regression is a bug unless a security measure requires it, with the numbers stated.
  • Smaller (third priority): executables a fraction of NativeAOT’s size, with nothing linked that the program doesn’t use (pay-for-play library code). Size still counts — budgets fail CI, and an unexplained size increase is a bug — but a security measure or a measured speed gain may cost size (stated with numbers in the commit, budget raised with that reason); size never buys weaker security or a speed loss.

Evidence comes from CI (benchmarks/RESULTS.md, the compatibility runs), not claims. Known gaps: NativeAOT is ahead on asyncfanout (x86-64 and arm64) and on fileio, quicksort, shapes and spectralnorm on arm64; macOS executables have a ~50 KiB floor (three 16 KiB-page segments: code, read-only-after-binding data, data); benchmarks run on Linux only so far; compile time: in the latest Compatibility run (2026-11-01) the median is 10.3 s against NativeAOT’s 8.6 s (csharpc faster in 53 of 242 programs; earlier runs measured it the other way, 5.7 s against 7.1 s, so part of the difference may be the runner), and async- and generic-heavy programs are the slowest to compile; culture-sensitive formatting (any number, even a negative int written with Console.WriteLine) links the culture model and the ICU shim (~85 KiB; formatting dates ~210 KiB, all calendars included) and adds 3–4 s of compile time (mostly Roslyn binding the corelib’s culture code), and loading ICU costs ~3.5–5 ms at first use, ~1.7 ms of it .NET’s search for the newest libicuuc.so.N (19-globalization.md).

Libraries now come from the framework’s IL (ADR 0023). Upstream IL assumes NativeAOT’s optimizer (shared generic code for reference types, whole-program devirtualization, inlining hints), which csharpc lacks, so flips have cost speed, size and compile time (List.Add +33 %, StringBuilder appends up to 2x, the JSON reflection serializer 18x). ADR 0025 therefore orders the work: finish the flips in flight, then a compiler milestone (shared generics, devirtualization, inlining, self-compile memory budget) measured against NativeAOT, then the remaining CoreLib flips (culture, numbers, DateTime, text).

Milestones

M0 — Spike

Status: ✅ done.

Roslyn front-end, CFG → LLVM lowering, csrt runtime, differential tests, docs.

M1 — “Real programs”

Status: ✅ done.

Structs, generics, interfaces, exceptions, closures, async/iterators, GC, records, spans, unsafe, drop-in MSBuild integration, conformance corpus, threads, debug info; benchmarks ahead of the .NET JIT on every program and of NativeAOT on nearly all (benchmarks/RESULTS.md).

M2 — Library in C#

Status: 🟡 open (bullets below).

The BCL surface written in C# and compiled by csharpc together with the program; library symbols that Roslyn binds against the real reference assemblies are redirected to it (12-corelib.md).

Implemented: collections (concurrent ones and BlockingCollection included), LINQ, tasks, TaskFactory continuations, System.Text.RegularExpressions, System.Text.Json (ported from dotnet/runtime; JsonSerializer runs on compile-time metadata from the JSON source generator, which csharpc also synthesizes for reflection-style calls; with ProjectReferences each project’s source generators run on that project’s own compilation, with its options and additional files, 16-interop-io.md); formatting, parsing, decimal, BigInteger and DateTime; P/Invoke and System.IO; sockets; HttpClient (HTTP/1.1, system proxies, decompression); TLS (ADR 0022); library value types (Guid, Vector2/Vector3/Vector4, ArraySegment<T>, DateTimeOffset, Half, Int128); Unsafe, MemoryMarshal, BinaryPrimitives; MemoryPool<T>, Convert; Uri; finalizers and ObjectiveCMarshal (ADR 0021); EventSource/EventListener; ResourceManager (GetObject, GetResourceSet, GetStream, TypeConverter resources; .resx EmbeddedResources in project mode); System.Type reflection (ADR 0018); globalization (cultures via ICU, as .NET: 19-globalization.md).

Windows catches up with the other platforms case by case: .NET’s zlib-ng and brotli shims link from the NativeAOT win-x64 pack (lld over the MSVC libraries plus src/runtime/windows-shims), so gzip/deflate/zlib/Brotli streams, HttpClient decompression and ZipArchive/ZipFile (Aes.Create() over CNG) work there (16-interop-io.md); Uri follows .NET’s Windows rules for rooted paths without a drive, while UNC and drive-less file: URIs stay explicit diagnostics (16-interop-io.md). On macOS and Windows HttpClient’s system-proxy code is .NET’s own, compiled from the shared framework’s IL.

Open:

  • The library surface the NuGet survey ranks (#146; its small members and the System.Numerics vector structs are done): MathF and the floating-point generic-math statics (#152, PR #156), the reflection lookups (#157, PR #158; #159) and a generic local-function codegen bug (#162). (The System.Xml.Linq members the survey listed were an artifact of its consumer: the framework’s own System.Xml.Linq is compiled from IL and behaves as .NET, sample 1235.)
  • TLS and X.509 on macOS and Windows run over OpenSSL (Homebrew’s openssl@3, the OpenSSL 3 DLLs). That is an interim state, decided by the owner on 2026-11-07, with the native routes as the end state (macOS: the runtime pack’s Apple crypto shim and .NET’s code from IL, #144; Windows: .NET’s SSPI/CNG code from IL, #143), both still spikes.
  • The gap lists from a large WinForms/macOS application: #89 (JSON numbers written with the current culture), #95 (Container/ComponentResourceManager), #96–#99 (tasks, threading primitives, TimeZoneInfo, interop), #100–#104 (JSON, cryptography/TLS, IO/process/networking, text, reflection/collections).
  • Platform limits that are explicit diagnostics: asynchronous socket operations are blocking calls on the thread pool on macOS and Windows (no kqueue/IOCP engine, so a pending one can’t be canceled); FileSystemWatcher only on Linux; PosixSignalRegistration on Windows; on WebAssembly no sockets, TLS, compression or OS ciphers.

M3 — Platforms and per-platform evidence

Status: ✅ done.

Each platform gets a CI job (GitHub Actions) running the full differential suite, conformance corpus and real-world programs against real .NET on that machine, plus the benchmark comparison:

platform runner work
Linux x86-64 ubuntu-24.04 ✅
Linux ARM64 ubuntu-24.04-arm ✅ AAPCS64 P/Invoke, statx, BTI/PAC hardening
macOS ARM64 macos-15 ✅ Mach-O via Apple’s ld, compact unwind + libunwind, per-OS corelib constants, Apple arm64 P/Invoke ABI, Mach-O GC roots/TLV, .dylib probing (no --static, no gdb debug-info suite)
Windows x64 windows-2025 ✅ PE/COFF via LLVM-MinGW (lld, libunwind, UCRT; x86_64-w64-windows-gnu), Itanium EH on SEH unwind tables, Microsoft x64 P/Invoke ABI, SuspendThread stop-the-world, kernel32-based System.IO, "\r\n" line ends, .NET’s Windows exit codes (no gdb debug-info suite; MSVC environment not supported)
wasm32 (WASI preview 1) ubuntu-24.04 + wasmtime 36 ✅ --target wasm32-wasip1 via the WASI SDK (wasm-ld, wasi-libc): exceptions as explicit propagation (no unwinder), GC roots spilled to linear-memory stack slots by the compiler, one thread (Thread.Start throws PlatformNotSupportedException; tasks and timers run while the main thread blocks), WASI System.IO; samples, both conformance corpora, real-world programs and a GC stress run under wasmtime (ADR 0011; no sockets, dynamic P/Invoke, time zones or exit codes above 125)

Per-platform gaps that remain are listed with their reason in tests/platform-skips.txt (known gap) and are the platform limits named under M2.

M4 — Real-world validation

Status: 🟡 open (#163).

Compile unmodified open-source C# console applications and tools, publish a compatibility report (what builds, what matches .NET, what is missing and why), and turn every gap into a regression test. The corpus is 320 programs from dotnet/samples and dotnet/docs; the harness is tools/compat/, run on CI by the Compatibility workflow, and the report is 18-compatibility.md. The headline metric is parity with NativeAOT (ADR 0016): the harness also publishes each program with PublishAot and runs it; programs NativeAOT can’t build or run identically are out of scope, and parity is the share of NativeAOT-working programs csharpc matches (target: 100 %).

State: 249 of 249 (100 %) on 2026-10-30, 242 of 246 (98.4 %) in the latest run (2026-11-01, scheduled), with no wrong output and no crash among the in-scope programs. The four in-scope programs that failed to compile had three causes, all fixed in #163 (the next Compatibility run confirms it): the built-in regex generator wrote #nullable into a file even for a program without [GeneratedRegex] members (an error under LangVersion 6/7.x: ref-readonly-struct, csharp6-*); the projects of a solution carried different /features (the root’s configuration-binding generator adds InterceptorsNamespaces), which Roslyn rejects as “Inconsistent syntax tree features” (ConsoleApp1); and the SDK’s older generators of a net8.0 project were bound to the newer Microsoft.Interop.SourceGeneration linked into csharpc. csharpc also passes 22 of the 29 programs NativeAOT can’t run. Against NativeAOT on the 242: executables a tenth of the size (143 KiB vs 1,338 KiB median); compile time is the open comparison (see the standing goal). M4 is done when a Compatibility run is at 100 % again.

M5 — Drop-in: binary packages and the program as IL

Status: 🟡 open (#146).

An IL front-end (IL → the same lowering) so NuGet packages that ship only assemblies can be linked into the closed-world program, and so the program itself can come as IL — the input csharpc gets inside the dotnet pipeline (ADR 0016). The source front-end stays for standalone use; every feature must work through both. With M2 and M4 this is what makes csharpc a drop-in replacement for existing projects.

Design: ADR 0010 — IL is a second method-body source for Roslyn’s metadata symbols, lowered through the same FunctionCodeGen (synthetic IOperations for library-facing instructions).

Implemented: -r, <Reference> and PackageReference input; all opcodes but jmp, TypedReference ones and ckfinite; generics, virtual/interface dispatch across the source/IL boundary, EH incl. filters, static constructors (beforefieldinit), RVA data, P/Invoke, events, compiled C# idioms (interpolation handlers, closures, iterators, records, generic math); unreachable failures compile to stubs (CSLLVM0007); compiled async (method builders, awaiters, async iterators, IValueTaskSource); embedded resource strings (ResourceManager, framework SR messages) and the objects of a preserialized .resx (GetObject of System.Drawing.Point/Size/Rectangle/Color, enums, dates, [TypeConverter] types: the converters are System.ComponentModel.TypeConverter’s own IL, created for the types the resources and typeof + GetConverter name); AppContext with runtimeconfig defaults; System.Collections.Immutable compiled from the shared framework’s IL. tests/il.sh checks library projects consumed as DLLs, a nuget.org package (Ardalis.GuardClauses) and a framework assembly against dotnet run; tools/il-survey ranks what the top pure-IL packages still need (18-compatibility.md).

The program as IL (what csc hands the fork, ADR 0016): csharpc app.dll compiles a program from its main assembly — entry point from the CLI header, identity, module initializers and runtimeconfig.json from the build (ADR 0010). tests/run.sh --via-il runs every sample through dotnet build → csharpc against the same recordings (CI: the informational il-main.yml) and all of them pass at -O0 and -O2: stack traces (names from the assembly, lines from its PDB), reflection-based JSON (private and protected nested types included: the binding compilation reads the program with those types marked internal), [GeneratedRegex] and dynamic (csc’s call sites decoded and bound like source sites, ADR 0019 “From IL”). Left as diagnostics from IL: JSON of anonymous, file-local and other compiler-generated types, as in source.

Debug info from IL: csharpc -g app.dll (or a library DLL it references) emits the DWARF line table, parameter and local names from the assembly’s portable PDB — beside the DLL or embedded — so gdb breaks on Counter.cs:10 of a library compiled from its IL, with inlined frames at -O2 (tests/debuginfo.sh, 13-debugging.md). An assembly without a PDB, the precompiled corelib and shared-framework assemblies get no debug info (Windows PDBs aren’t read).

Function pointers and calli: delegate*<...> calls and IL calli share one lowering (managed signatures: csharpc’s own convention, ref/out/in and ref returns, structs, generics). delegate* unmanaged calls and &[UnmanagedCallersOnly] entries follow the platform’s C ABI as a P/Invoke of the same function does: structs by value (System V eightbytes, byval/sret, AAPCS64, Win64), bool as a 4-byte BOOL, small integers extended by the caller (samples 1150-1152, checked against libc/libm and across both ends); &Math.Sqrt and other library static methods can be pointer targets (sample 1153). Diagnostics: calli with an instance signature or vararg, and char/string/array/delegate in an unmanaged function pointer’s signature (.NET marshals them).

RID-specific and native package assets: the packages’ runtimes/<rid>/lib assemblies and runtimes/<rid>/native libraries for the target’s runtime identifier, as the host and PublishAot select them. A project with packages is restored for the target’s RID (--target -> linux-x64, linux-arm64, osx-arm64, win-x64; the host’s by default; a RID the project or -p:RuntimeIdentifier sets wins), so NuGet’s own selection applies: the RID-specific assembly replaces the portable lib/ one. The program as IL reads deps.json’s runtimeTargets with the runtime graph’s fallbacks (linux-x64 -> linux -> unix-x64 -> unix -> any). The native libraries are copied next to the executable, where a P/Invoke probes first (tests/il.sh, RidApp, against a package built locally). Static archives follow NativeAOT’s items: DirectPInvoke / DirectPInvokeList make a library’s imports direct calls the linker resolves, NativeLibrary / NativeSystemLibrary / LinkerArg extend the link line (project items, or --directpinvoke, --directpinvokelist, --native-library, --native-system-library, --linker-arg), and a package’s runtimes/<rid>/native/lib<name>.a is linked when a DirectPInvoke names it (#175; tests/projects.sh, “DirectPInvoke”, Linux and macOS; docs/16-interop-io.md).

Decided (#168, 2026-11-07): the opcodes jmp, arglist, mkrefany/refanyval/refanytype (TypedReference) and ckfinite, and calli with an instance or vararg signature stay explicit diagnostics: none of the 52 packages of the sharded survey, Roslyn, csharpc.dll or the framework IL needs one (no item of the survey names them), so they are built when a package does. Satellite resource assemblies are not used, and that is NativeAOT’s behaviour too: a PublishAot app that copies fr/Lib.resources.dll next to itself still prints the neutral string for CultureInfo("fr") (run to check, dotnet run prints the French one); csharpc answers the neutral string. ref/ against lib/: PublishAot compiles the lib/ (runtime) assets, as csharpc does, so nothing is missing; a source compiled against a ref/ surface that lib/ lacks is csc’s concern. Reflection-based JSON of anonymous, file-local and other compiler-generated types stays a diagnostic: PublishAot disables reflection-based serialization by default (InvalidOperationException), and with it enabled serializes such types as {} (their members are trimmed), which csharpc refuses instead of printing. (ADR 0010, “Out of scope”.)

Open (#146): the BCL surface packages use — the sharded IL survey of all 52 packages (#146) ranked the small members and the System.Numerics vector structs (26 packages) first, both done; next are MathF and the reflection lookups (Type.GetMember, TypeInfo.GetDeclaredProperty).

M6 — Bootstrapping

Status: 🟡 open (#93).

csharpc compiles csharpc (and Roslyn) — the strongest possible proof of maturity.

How it works. Framework assemblies the program uses are compiled from the shared framework’s IL whenever csharpc implements none of their types (ADR 0013, --framework-il). System.Reflection.Metadata (with System.Collections.Immutable) reads PE headers, metadata tables, signatures, custom attributes and IL bodies, and the Microsoft.Extensions Primitives/Options/DependencyInjection/Logging abstractions work, all matching dotnet run (tests/il.sh). A program hosting Roslyn from its package — parse, rewrite, bind, diagnostics, deterministic in-memory emit read back with SRM — compiles and prints exactly what dotnet run prints (tests/projects/il/IlRoslynHostApp, run by the Bootstrap workflow). The corelib surface these programs need is implemented (Unsafe from IL, GC handles, ArrayPool, BinaryPrimitives, BitConverter, memory-mapped views, weak references and ConditionalWeakTable, CancellationTokenRegistration with .NET’s callback order, the concurrent collections, EventSource, custom TaskSchedulers, Partitioner and the Parallel loops, BlockingCollection, TaskFactory.ContinueWhenAll/ContinueWhenAny/FromAsync, EventSource.Write<T> payloads, struct layouts LLVM’s types can’t express, unions of primitives, fixed-size buffers, [InlineArray]), each checked against .NET one type at a time (samples 1020-1063, 1200-1211; 12-corelib.md, 10-async.md). The Roslyn-from-IL survey (18-compatibility.md) ranks what still fails to lower.

Self-compile. tools/bootstrap/selfhost.sh (the Bootstrap workflow) compiles csharpc with csharpc, at -O0 and -O2. On a CI runner it takes 192 s at -O0 and 610 s at -O2 with a peak of 8.7 GB; the native compilers are 124 MB (-O0) and 89 MB (-O2). The native compiler passes every sample of the differential suite at -O0 and -O2, built with the -O0 and the -O2 native compiler (CSHARPC_NATIVE in tests/run.sh, the native-suite jobs of the Bootstrap workflow; tools/bootstrap/native-known-failures.txt is empty). Getting there took: the SDK’s JSON and LibraryImport source generators linked into csharpc (a csharpc compiled by csharpc cannot load assemblies at run time, so loading one is the explicit diagnostic CSLLVM0001); the framework’s real assembly attributes for typeof(object).Assembly; delegates over a struct’s instance method (called with the struct, not the box); and open instance delegates (MethodInfo.CreateDelegate without a target).

Compile time (ADR 0014): csharpc and Roslyn are ReadyToRun-compiled in Release builds; a compilation uses several threads (-j, CSHARPC_THREADS) to parse, bind, build Roslyn’s CFGs ahead of lowering and generate machine code per module partition after whole-program optimization; the output is the same at every -j. The corelib is compiled to IL once (cached per corelib version and symbol set) and lowered through the IL front-end instead of being parsed and bound into every program (ADR 0015). Code-generation memory is bounded (ADR 0014, section 6): no local value names in the IR, the bitcode image kept in LLVM’s buffer and the partition workers limited by the memory available (the first one is free, each further one is estimated at ten times the image), so the self-compile peaks at 8.0 GB at -O0 and 7.6 GB at -O2 with two workers and 5.3 and 5.5 GB with one (slower backend), with byte-identical executables. What remains is the module itself, about 2.7 GB for 9 M instructions, and the managed heap at the end of lowering (3.7 GB). The module-level lowering steps are cheaper (generic interface dispatchers look only at the types that implement their interface, array interface maps compute their facts once per interface and element; tools/bootstrap/compare-compilers.sh checks byte-identical output). Lowering on several threads is deferred by the owner: the single-threaded lowering is 75 s of the 238 s -O0 self-compile and 69 s of 577 s at -O2, so two threads would save about 35 s (15 % / 6 %) for a second set of types, declarations and constants in memory.

Roslyn-from-IL survey, re-measured 2026-11-07 (#169): 32 methods of Roslyn, csharpc.dll and the framework IL failed to lower (the 38 of 2026-10-31 had shrunk with earlier work), 4 after the fixes of that issue, and every shard now compiles to the end (18-compatibility.md); the remaining ones were Mutex (#174, now implemented). Threaded lowering is a decision, not an open item (owner, 2026-11-06; ADR 0014, “Next hot spots”): deferred, the measured saving is about 35 s of a 238 s (-O0) and 577 s (-O2) self-compile.

Open (#93): lowering scales quadratically on a very large program (#93: a ~250-assembly application, the builtin interface tables are the largest step left).

Runtime tiers — C# for library code, C where it is the right tool

ADR 0017; a C-free runtime is not a goal (owner, 2026-10-30). Tier 1 (alongside M2/M4): move the C runtime’s ordinary code to the C# corelib — task scheduler, thread pool and timers, type/interface/delegate helpers and the remaining library helpers — with identical behaviour, sizes within budgets and benchmarks not slower. Tier 2 (optional, measured): the GC, exception dispatch and thread management stay in C; a restricted “systems C#” version checked by the compiler ([RuntimeCritical]: no allocation, no safepoint, no throw) may be tried behind a flag next to the C one, and becomes the default only if it is faster and as safe on the benchmarks, the GC stress run and dotnet’s own AOT tests. C# where possible, not as a rule: a C# port that is measurably slower or bigger is optimized first (the code and csharpc’s codegen), and C stays wherever it is better for performance or safety. Tier 3 (permanent): a few hundred lines of native glue (entry, signal/SEH stubs, unwinder ABI, register spilling), plus dotnet’s own C shims for the OS (System.Native, System.Globalization.Native), as NativeAOT does.

M7 — TechEmpower: the csharpc CLI beats NativeAOT

Status: ⏸ on hold (owner).

The ASP.NET Core entries of the TechEmpower Framework Benchmarks that .NET runs with NativeAOT, built by the standalone csharpc CLI from the same sources (the fork is M8, and M9 repeats this through it), run in TechEmpower’s benchmark environment and beat the NativeAOT-compiled entries. Same sources, same test types, same harness; only the AOT compiler differs.

The owner’s rule is that M7 starts once M2–M6 are done. The harness and the performance work below were started on 2026-10-31, before that; since 2026-11-05 no M7 work is done, and none starts without the owner’s go. What is on main stays and is measured by CI.

Done when the csharpc build beats the NativeAOT build on every metric measured, held over repeated CI runs; the set is open-ended, and anything TechEmpower’s toolset or the harness reports joins it. Planned: TechEmpower’s own results for every test type (plaintext, JSON, single query, multiple queries, fortunes, updates, cached queries) at every concurrency and query-count level they use (requests per second, the latency distribution, zero errors); resources under load (peak and steady RSS, CPU time per request, threads, GC pauses); and deployment (start-up to the first response, idle RSS, executable size, build time, container image size). A tie or a loss on any of them means M7 isn’t done.

The harness (benchmarks/techempower/harness.py, the TechEmpower workflow). The app is TechEmpower’s ASP.NET Core [Platform] entry itself, the one its aspnetcore-aot test publishes with NativeAOT (frameworks/CSharp/aspnetcore/src/Platform at 57d92fb, unchanged but for net11.0), on PostgreSQL in TechEmpower’s own database image. Builds: NativeAOT and the JIT as the entry’s dockerfiles build them (OptimizationPreference=Speed, GarbageCollectionAdaptationMode=0; the JIT with ReadyToRun and hill climbing off); csharpc from the same IL NativeAOT compiles (dotnet build with the AOT properties, then csharpc Platform.dll), with csharpc Platform.csproj checked alongside. Every build is verified with TechEmpower’s own verification code from the pinned checkout (real-run rules: exact query and row counts through pg_stat_statements), and csharpc’s normalized answers must equal NativeAOT’s and the JIT’s; a build that fails isn’t loaded and fails the run. Load: TechEmpower’s scripts (primer, warm-up at 512 connections, then each level for 15 s) at every level it uses: plaintext 256–16384 connections pipelined ×16, JSON, single query and fortunes 16–512 connections, multiple queries and updates 1–20 queries and cached queries 1–100 at 512 connections, 37 levels. Metrics per level: requests/s; latency average, stdev, max, p50, p75, p90, p99; socket errors and non-2xx answers; from /proc, the server’s peak and steady RSS, threads and CPU time per request. Per run: peak RSS and csharpc’s GC pause total (NativeAOT reports its pause time only in-process). Deployment: start-up to the first response (5 starts per round), idle RSS, executable size, build time and a minimal runtime image per build (chiseled runtime-deps for the native builds, chiseled aspnet for the JIT, smoke-tested). Each measure job runs one test type for all builds on one runner, 3 rounds for NativeAOT and csharpc in alternating order (the JIT once). The verdict per metric compares medians: better or worse only when the difference exceeds both builds’ run-to-run range (max − min; beyond 5 samples, as for the 15 start-ups, the 10th–90th percentile spread) and 1 % (exact metrics such as sizes: any difference; single samples such as the build time: 5 %); errors are a requirement (zero), not a comparison. results.json holds every sample; results.md opens with “M7 finish line: X of Y metrics beat NativeAOT”. There are 456 compared metrics; a full run takes about 50 minutes of wall time in 13 jobs. The plaintext/JSON app the harness measured first is kept as benchmarks/techempower/interim and measured outside the verdict.

State.

  • Last measurement of main that built the entry (scheduled run, 2026-11-02, csharpc 9812e64, AMD EPYC 7763, 4 vCPUs): 288 of 456 metrics beat NativeAOT (135 ties, 33 worse), csharpc error-free at all 37 load levels, all test types verified. Ahead: start-up to the first response (521 vs 611 ms), plaintext latency, JSON, multiple queries and fortunes. Worse: idle RSS (42.4 vs 37.6 MiB), executable size (18.3 vs 16.4 MiB), build time (134 vs 29 s), container image (34.6 vs 32.7 MiB), plaintext at 256 connections (0.93 of NativeAOT’s requests/s), 12 of 61 cached-query metrics.
  • Today csharpc does not build the entry on main (workflow run of 2026-11-07: 0 of 456, 456 without a csharpc result): four methods fail to compile, a regression since 2026-11-02 (#164).
  • Tried and kept off by default, because speed comes first and they cost speed elsewhere: the concurrent marker (--gc-concurrent, ADR 0020: pauses p50 0.4 ms instead of 13–23 ms, about 5 % of plaintext throughput and 13–23 % wall time on arm64’s allocation-heavy programs) and the generational nursery.
  • What it takes beyond M2–M6: ASP.NET Core and Kestrel compiled from IL (hosting, dependency injection, configuration, logging, System.IO.Pipelines, the HTTP/1.1 parser, System.Text.Json source generation), the entry’s libraries (Npgsql, RazorSlices, Microsoft.Extensions.Caching.Memory) and, for the project input, the source generators its build runs (Razor, RazorSlices), the thread pool, sockets and async I/O at production throughput on Linux (epoll), and allocation/GC behaviour under sustained load. All of it builds and answers like NativeAOT’s build when #164 is not in the way (18-compatibility.md).

History. 2026-10-24: csharpc builds the first TechEmpower app (plaintext and JSON on Kestrel) at half of NativeAOT’s throughput; profile-driven fixes (task completion wake-ups, Monitor/Lock entries, interface-call caches, thread-pool wake-ups, lock-free ConcurrentQueue, vectorized span searches, allocation per request) bring it to NativeAOT’s level by 2026-10-25. 2026-10-31: the harness switches to TechEmpower’s real Platform entry and the verdict per metric (0 of 456 while csharpc could not build it; 242 once it did; 308 on the concurrent-marking branch). 2026-11-01..02: ValueTask<T> as .NET’s struct, ArrayPool<T>.Shared pools, parallel per-partition optimization, idle trimming, start-up polling fixed (288 on main).

M8 — csharpc as dotnet’s AOT backend: the fork

Status: ⬜ not started.

A fork of dotnet in which dotnet publish -p:PublishAot=true runs csharpc where NativeAOT’s ILCompiler runs today: the same IL inputs from csc, the same MSBuild properties (OptimizationPreference, IlcInstructionSet, InvariantGlobalization, StackTraceSupport, StripSymbols, NativeLib, DirectPInvoke, trimming descriptors and feature switches, …) and the same outputs, so existing projects get csharpc by switching the AOT backend (ADR 0016). Prerequisites: M7 (and with it M2–M6: IL as the primary input path, csharpc compiling Roslyn and itself, NativeAOT parity on the compatibility corpus). Acceptance gate: dotnet’s own tests for the AOT path all pass with csharpc in NativeAOT’s place — dotnet/runtime’s NativeAOT runtime tests, the libraries’ tests in their NativeAOT configuration, and the SDK’s PublishAot tests (exclusions only for tests of ILCompiler internals, each listed). Tracked before the fork by building those suites with csharpc on CI and reporting the pass rate. Until then Csharpc.Sdk is the integration point and adopts NativeAOT’s property names as it honours them. How the fork is run: it is a fork of dotnet/dotnet (the virtual monolithic repository that builds the SDK, runtime and ASP.NET Core together), and it keeps only its main and the branches the work needs (upstream’s other branches are not carried). The csharpc integration lands through a pull request from our working branch into the fork’s own main; nothing is proposed upstream to dotnet at this stage. Done when NativeAOT’s code is removed from the fork, csharpc takes its place, the fork is built, and its acceptance gate passes.

M9 — The finish line: TechEmpower through the fork

Status: ⬜ not started.

The project’s definition of done: the dotnet fork of M8 — NativeAOT’s code removed, csharpc in its place behind PublishAot — builds the ASP.NET Core TechEmpower entries .NET runs with NativeAOT, through the ordinary dotnet publish -p:PublishAot=true, and they beat the NativeAOT-compiled entries in the TechEmpower environment. M7 proved csharpc itself; M9 proves it as a drop-in replacement, with the same project files and the same publish command.

Credibility deliverables (cross-cutting)

  • A technical report: what csharpc demonstrates (Roslyn’s CFG as a mid-level IR, a C# corelib with whole-program LLVM optimization, the size/start-up/throughput/security results) and where it falls short.
  • Benchmarks generated by CI in a pinned environment, apples-to-apples with NativeAOT and the JIT.
  • Scope fixed to .NET 11 (RC2 → GA) and C# 14: converge on completeness rather than track releases.
  • Distribution: After every green CI on main, .github/workflows/release.yml ships a rolling GitHub prerelease (latest-main) and RID-specific NativeAOT tool packages (0.1.0-alpha.<ci_run_number>) to GitHub Packages. Tags v* on a commit with green main CI publish a named release and that version, also to nuget.org (Trusted Publishing via NuGet/login in release.yml; repo variable NUGET_USER; no GitHub environment). Archives and dotnet tool install carry the same binaries (libLLVM bundled; clang/lld remain a host prerequisite). Container: ghcr.io/jonathanperis/csharpc. See the README Install section.

Follow-ups

The measured losses and open follow-ups of the original goal, moved here from the tracking issues #473–#477 (closed 2026-11-25) so that the issue list holds only bugs and decisions. Each item links the issue (closed) that keeps its numbers and analysis; re-measure before working on one (tools/il-first/measure-aot.sh), since earlier changes move them. A new loss or follow-up is added here.

Run time against NativeAOT (was #473)

  • Synchronization primitives 4.4x NativeAOT, sync_throughput (#428).
  • Ascii and Base64 from CoreLib IL 1.95x slower: the ISA paths are not taken (#434).
  • Tracing from IL: EventSource throughput 1.28x slower (#454).
  • BigInteger from IL 1.12x slower despite 26 % fewer instructions (#448).
  • Convert from CoreLib IL 1.10x slower despite fewer instructions (#435).
  • String helpers from CoreLib IL 0.90x–1.06x of NativeAOT despite 21 % fewer instructions (#446).
  • Crypto from IL on Linux: hashing throughput 1.05x, the per-call overhead of the OpenSSL contract (#452).
  • IL lowering: List.Add from the framework IL costs 33 % more instructions than the shadow (NoInlining AddWithResize blocks promotion of size/version) (#259).
  • ComponentModel (componentmodel_throughput) 1.14x after #465 with fewer instructions (1.02 G vs 1.05 G): kernel time from first-touch page faults (8 903 vs 2 601; sys 37 vs 16 ms) as the heap grows to the first collection at 32 MiB.

Size and compile cost (was #474)

  • Every program that prints a number carries CoreLib’s culture start-up (~80 KB) (#431).
  • Struct method tables lower ToString/Equals/GetHashCode and dispatched interface slots for typeof-only structs (#420).
  • Fold EventSource.IsEnabled() when the program can have no EventListener: Barrier pulls in 190 KB (#429).
  • TLS/X.509 from IL on Linux: executables 1.5x–3.3x the copies’ size, compile CPU 3.4x NativeAOT’s (#456).
  • File system from the framework’s IL: 1.31x slower (kernel time) and 2.67x larger than the deleted shadows; at parity with NativeAOT (#438).
  • Hashtable from the framework’s IL: SR.Format in Insert pulls in composite and number formatting (+30 % size, +3 % instructions) (#373).
  • Release bundle: ship only the framework assemblies the IL route can reach (the bundle grew from 59.9 to 92.7 MB) (#379).
  • Do not link the NonBacktracking regex engine when RegexOptions is a constant without NonBacktracking (#214).

Types still to serve from the framework’s IL (was #475; ADR 0023/0024)

  • Crypto from the framework’s IL on macOS, Windows and WASI; Linux is flipped (#449).
  • Windows: System.Net.Sockets from IL needs IOCP (ThreadPoolBoundHandle) in the runtime (#441).
  • System.Uri (System.Private.Uri behind System.Runtime) (#442).
  • TimeSpan formatting through CoreLib’s TimeSpanFormat instead of the corelib’s formatter (#447).
  • Vector2/3/4, Plane and Quaternion (#451); System.Half (#410); BFloat16 and Decimal32/64/128 (#405).
  • System.Diagnostics.Process (it would also give #102’s other-process lookups).
  • Done since the tracker opened: Guid (#416); ManualResetEventSlim and SpinWait from CoreLib, Barrier from System.Threading (#414); ArrayList and BitArray (#372).

Stack allocation (was #476; after #457, #461)

  • Small arrays that do not escape (#458).
  • Allocations inside try regions, as invokes (#459).
  • wasm32, and under --gc-nursery / --gc-concurrent (#460).

Shared generics (was #477; ADR 0026)

  • Step 4: a hidden instantiating argument for generic structs, static and generic methods (#369).
  • Default-on audit: run-time type checks and observable identity in shared code (#422).