CSharpLLVM
An LLVM-based compiler for IL/C# for kernels that compiles to native code
Install / Use
/learn @SharpNative/CSharpLLVMREADME
CSharpLLVM
CSharpLLVM is an LLVM-based compiler for CIL (Common Intermediate Language). The main goal for this compiler is to use it in low-level system development (e.g. kernels) in the C# language, where the .NET-framework is unavailable. Note that the project is still work-in-progress and does not support all features of the C# language.
Important note
Because this compiler will be mainly used for C# kernels, this means we will not support the following most notable features:
- Garbage collection: implementing this would make the kernel slower, and it is more difficult to implement because certain objects may be coming from userspace
- No .NET-framework
An important difference to the .NET framework is that we treat "System.Char" as 8-bit instead of 16-bit. This decision was influenced by the fact that this compiler's main goal is to work together with kernels.
Some important features
A list of important features we support (this list does not contain all features):
- Classes, (including virtual calls and inheritance), interfaces
- Structs (with fixed buffer support)
- Most opcodes for CIL
- The basic types
Some notable features we currently don't support:
- Boxing & unboxing (need some sort of garbage collector, or we could work around this, need to investigate)
- Generic types
- Linq (depends on classes in the .NET framework)
Future
Short term planning:
- Add support for delegates
- Add support for "Plug", this means that you will be able to provide your own implementation of certain .NET classes and/or methods.
- ...
This list can change alot. It mostly depends on what is needed, which we will find out while building the kernel.
Runtime information
The compiler generates code that should be linked against some runtime methods that you'll need to implement. There is a standard implementation available for these methods in runtime.c, but you can write custom implementations if you wish. More information about this (and a default implementation) can be found in the runtime folder.
Dependencies
We are using a NuGET package called Swigged.LLVM, the package is a wrapper for LLVM so we can use LLVM in C#. (https://www.nuget.org/packages/swigged.llvm/) For command line parsing we are also using a NuGET package called CommandLineParser. (https://www.nuget.org/packages/CommandLineParser/)
Related Skills
node-connect
351.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
110.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
351.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
351.2kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
