Overview
Cosmos.ilc.Build integrates the native AOT ILCompiler into the MSBuild pipeline. It consumes patched assemblies emitted by Cosmos.Build.Patcher and transforms them into native object files later linked with platform libraries for CosmosOS.
Flow chart
flowchart TD
A[ResolveIlcPath] --> B[WriteIlcRsp]
B --> C[CompileWithIlc]
C --> D[Native binary]
Parameters
| Name | Description | Default |
|---|---|---|
IlcToolsPath |
Path to the ilc executable resolved from the Microsoft.DotNet.ILCompiler runtime pack. |
auto-resolved |
IlcIntermediateOutputPath |
Directory where .ilc.rsp and .o files are written. |
$(IntermediateOutputPath)/cosmos/native/ |
IlcSystemModule |
System module used as ILCompiler entry point. | System.Private.CoreLib |
UnmanagedEntryPointsAssembly |
Assemblies whose methods are exported via --generateunmanagedentrypoints. |
Cosmos.Kernel.Runtime |
Tasks
| Task | Description | Depends On |
|---|---|---|
ResolveIlcPath |
Downloads and locates ILCompiler, setting IlcToolsPath. |
Build |
WriteIlcRsp |
Produces the ILCompiler response file listing inputs, references, and options. | ResolveIlcPath |
CompileWithIlc |
Runs ilc using the response file to emit a native object file. |
WriteIlcRsp |
Detailed workflow
- ResolveIlcPath uses
GetPackageDirectoryto find theruntime.<RID>.Microsoft.DotNet.ILCompilerpackage and setsIlcToolsPath. - WriteIlcRsp creates
$(IlcIntermediateOutputPath)$(AssemblyName).ilc.rsp, gathering patched assemblies from$(IntermediateOutputPath)/cosmos, references fromcosmos/ref, and ILCompiler options such as--runtimeknoband--featureflags. - CompileWithIlc executes
ilcwith the generated response file, producing$(AssemblyName).oin$(IlcIntermediateOutputPath). - The native binary is ready for further packaging, such as bootloader integration.
Outputs
- Response file:
$(IntermediateOutputPath)/cosmos/native/$(AssemblyName).ilc.rsplisting inputs, references, and ILCompiler options. - Native object:
$(IntermediateOutputPath)/cosmos/native/$(AssemblyName).oproduced byCompileWithIlcfor linking.
Notes:
- Reference assemblies resolved by ILC are located under
$(IntermediateOutputPath)/cosmos/ref/and come from the Patcher step.