This project transpiles LLVM IR to .NET CIL. This enables robust, automated translation of C and C++ to low-level C#. Translated code is highly performant, AOT compatible, cross-platform, and semantically accurate.
While this project is intended to handle any LLVM IR, it works best when the input is generated on Windows with the following Clang command:
clang -g -fno-discard-value-names -fstandalone-debug -S -emit-llvm {inputFile} -o {outputFile}
This ensures that debug information is included and that parameter names are preserved, which helps with generating code that is more readable.
Install Ninja
Use ninja --version
to verify that it's been added to the PATH.
cmake -G "Ninja" \
-S ./path-to-directory-with-source-files/ \
-B ./path-to-build-output-directory/ \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_C_FLAGS="-DNOMINMAX" \
-DCMAKE_CXX_FLAGS="-DNOMINMAX" \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
This will generate a compile_commands.json
file in the build output directory, which is necessary for a future step.
-DNOMINMAX
ensures that themin
andmax
macros do no interfere with compilation.
cmake --build ./path-to-build-output-directory/ --config Debug
This ensures that any generated files get generated.
LargeProjectCompiler.exe ./path-to/compile_commands.json
Use --help
to see additional options.
There are plans to ship this as a NuGet tool for easy installation and usage.
The libLLVMSharp
dependency is not included in the repository. The source code for it can be found here.