|
|
Project:
https://github.com/soywiz/ilcc
You can try the sample by yourself:
https://sites.google.com/site/cspspemu/downloads/comptoe_ilcc.7z?attredirects=0&d=1
Native executables are build using microsoft c/c++ compiler with "cl /Ox" (maximum optimizations).
---
comptoe_ilcc.exe -c3 file.7z file.7z.c3
Encoding[03] file.7z -> file.7z.c3...Success
Elapsed: 1225
---
comptoe_native_cl_x86.exe -c3 file.7z file.7z.c3
Encoding[03] file.7z -> file.7z.c3...Success
Elapsed: 810
---
comptoe_native_cl_x64.exe -c3 file.7z file.7z.c3
Encoding[03] file.7z -> file.7z.c3...Success
Elapsed: 804
---
Also there are more targets:
Available Targets:
yaml - Outputs YAML markup
pinvoke - Outputs .NET pinvoke source with function declarations and structures (not fully implemented yet)
cil - Outputs .NET IL code (not fully implemented yet)
xml - Outputs YAML XML
Besides to generate IL Code, you can generate pinvoke signatures and output the AST as XML or YAML. So it can be used to analyze C code in C# using the library or in other languages outputing to XML.
Executable sizes:
25.088 comptoe_ilcc.exe
16.896 ilcc.Runtime.dll
76.288 comptoe_native_cl_x64.exe
66.560 comptoe_native_cl_x86.exe
At this point runtime lacks lot of stuffs, so it will get larger. For larger projects the runtime will be smaller than the executable and .NET executables get a better compression, so the executables will be smaller than the native executables most of time (at least compressed).
.NET version is just about 50% slower. That's great! It is in the same order of magnitude and it is faster than I initially expected.
So you will be able to run C code on managed .NET (but with unsafe code at this point) platform without recompiling just with a 50% tradeoff (related to the best optimization level CL can get) and without having to port C code to C# by hand.