Build native apps for
bflat is a native compiler for C# that comes with everything you need to build C# apps for any of the supported platforms. No additional SDKs or NDKs needed.
Battle-tested fundamentals
Based on parts of the .NET 8 SDK that is trusted by developers all around the world, but reimagined as native-first and stripped to the bare minimum needed to build native apps with C#. Based on CoreCLR's code generator and GC.
Choose your standard library
Comes with two standard libraries: one (DotNet) that is compatible with .NET and supports everything from console to JSON, and another (Zero) that is stripped to bare minimum and doesn't even have a GC.
Build native apps or shared libraries
Produce native apps and native libraries. Consume C# libraries built with bflat from other languages using their respective FFI interface.
Bring your own build system
Invoke bflat directly from terminal, integrate with a shell script, Makefile, or even MSBuild. The choice is yours.
Standard libraries supported by bflat at a glance
DotNet | Zero | |
Primitive types | ✓ | ✓ |
Rich standard library | ✓ | ✗ |
Marshalling-less p/invoke | ✓ | ✓ |
Full p/invoke | ✓ | ✗ |
Garbage collector | ✓ | ✗ |
Exception handling | ✓ | ✗ |
Building apps and libraries | ✓ | ✓ |
Target Linux, Windows, Android | ✓ | ✓ |
Target UEFI | ✗ | ✓ |
Starting app size | 600 kB | 4 kB |
Run C# with no operating system, on bare metal
Build native code or .NET bytecode
$ bflat build --help Description: Compiles the specified C# source files into native code Usage: bflat build [<>...] [options] Arguments: <file list> Options: -d, --define <define> Define conditional compilation symbol(s) -r, --reference <file list> Additional .NET assemblies to include --target <Exe|Shared|WinExe> Build target -o, --out <file> Output file path -c Produce object file, but don't run linker --ldflags <ldflags> Arguments to pass to the linker -x Print the commands --arch <x86|x64|arm64> Target architecture --os <linux|windows|uefi> Target operating system -m <{isa1}[,{isaN}]|native> Target instruction set extensions --libc <libc> Target libc (Windows: shcrt|none, Linux: glibc|bionic) -Os, --optimize-space Favor code space when optimizing -Ot, --optimize-time Favor code speed when optimizing -O0, --no-optimization Disable optimizations --no-reflection Disable support for reflection --no-stacktrace-data Disable support for textual stack traces --no-globalization Disable support for globalization (use invariant mode) --no-exception-messages Disable exception messages --no-pie Do not generate position independent executable --separate-symbols Separate debugging symbols (Linux) --no-debug-info Disable generation of debug information --map <file> Generate an object map file --mstat Produce MSTAT and DGML files for size analysis -i <library|library!function> Bind to entrypoint statically --feature <Feature=[true|false]> Set feature switch value -res, --resource <<file>[,<name>[,public|private]]> Managed resource to include --stdlib <DotNet|None|Zero> C# standard library to use --deterministic Produce deterministic outputs including timestamps --verbose Enable verbose logging --langversion <langversion> C# language version ('latest', 'default', 'latestmajor', 'preview', or version like '6' or '7.1' -?, -h, --help Show help and usage information