Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between .NET CoreCLR, CoreRT, Roslyn and LLILC

Recently I started reading about .NET reorganization details (mostly through .NET Core github pages). It seams that they created sibling projects to support more platforms. While reading I have the impression that CoreCLR and CoreRT is a new OpenSource version of propriety Roslyn compiler. CoreRT provides native (AOT) compilation. And LLILC is an alternative implementation directing LLVM framework.

Can anyone confirm and describe the differences and goals of this projects from the user perspective? Why someone would use Roslyn in the future instead of CoreCLR?

like image 762
Robert Zaremba Avatar asked Jan 07 '16 20:01

Robert Zaremba


People also ask

What's the difference between RyuJIT and Roslyn?

Roslyn is the compiler that compiles your code (C# or VB) to IL. RyuJIT is a Just In Time compiler that compiles your IL to native code. Both of them are now open source. Roslyn API is what you need if you want to play with syntax tree, compilation, and semantic model.

What is CoreRT?

CoreRT is a native toolchain that compiles CIL byte code to machine code (e.g. X64 instructions). By default, CoreRT uses RyuJIT as an ahead-of-time (AOT) compiler, the same one that CoreCLR uses as a just-in-time (JIT) compiler.

What is Roslyn in .NET Core?

Roslyn, the . NET Compiler Platform, empowers the C# compiler on . NET Core and allows developers to leverage the rich code analysis APIs to perform code generation, analysis and compilation.

Is. NET Core AOT?

It is currently not supported with ASP.NET Core, but only console apps. The native AOT deployment model uses an IL to native compiler. Native AOT apps don't use a Just-In-Time (JIT) compiler when the application runs. Native AOT apps can run in restricted environments where a JIT is not allowed.


1 Answers

Roslyn is a compiler platform that enables you to build static and dynamic analysis tools and custom language extensions and transformations for the C# and VB programming languages.It also enables you to embed these languages within other languages or applications. Roslyn includes the C# and VB compilers and other tools. These compilers emit Common Intermediate Language (CIL) code.

To run this code, CIL has to be compiled into binary code that the target computer architecture can execute. .NET currently provides three ways to do this:

  1. Compile the CIL code into binary code using a JIT compiler while the app is running. This model is implemented by CoreCLR. CoreCLR started as a copy of CLR. It has been modified to support different OSes. They're maintained separately and in parallel.
  2. Compile the CIL code into binary code and integrate any required .NET framework components to produce a single-file self-contained executable whose performance is closer to code written native languages. This technology is called .NET Native. CoreRT is an open-source implementation of this technology. The main difference between .NET Native and CoreRT is that the AOT compiler that the former uses is the UTC compiler (the MSVC compiler backend) while the latter currently uses RyuJIT. UTC is much more aggressive in optimizing the code than RyuJIT. Also in CoreRT, some components of the runtime have been cleanly reimplemented in C#. CoreCLR still uses the C++ implementation.
  3. NGEN which is similar to .NET Native except that the produced executables are not self-contained and requires an externally installed runtime.

LLILC is a CIL compiler based on the portable LLVM compiler framework. It can be used to build JIT (current) and AOT (future) compilers. The advantage of this compiler is that it leverages the Clang C++ compiler optimizations and brings the LLVM extensibility model (analysis and optimization passes) to .NET.

CoreRT and LLILC are new projects and still in early development stage and require a lot more work to support production applications. So if you are a user and not a contributor, CoreCLR and Roslyn are for you. Again, CoreCLR is the runtime while Roslyn is the C# and VB compilers.

like image 103
Hadi Brais Avatar answered Oct 15 '22 01:10

Hadi Brais