Search code examples
.netclrjitcil

Run CLR JIT's output on bare hardware without OS running


Is it possible to run the output of CLR's JIT or AOT (Ahead-Of-Time) compiler, (since it is called native code or native instruction set) on a bare hardware without OS? At what point .NET framework library code is linked?

What i mean by without OS is without the help of Win32 API calls.


Solution

  • If you remove Win32, then you need to replace the things that it does for the CLR (like memory allocation, console, file system and network access) with something else, or they won't work.

    Probably the only difference between .Net and C in this regard is that you can write a useful C program that doesn't need any of that. On the other hand, CLR simply assumes that functionality like memory allocation and file system access exists and even the simplest C# program uses them.

    So, no, I don't believe that you could run a normal CLR program without at least a rudimentary OS.

    On the other hand, if you're not tied to the normal CLR, then the support non-CLR code that's required to run IL using an AOT compiler is not much, as shown by Singularity.


    Regarding terminology, the term "native code" means that it's code that runs directly on the CPU, using the CPU instruction set. It doesn't mean that it's code that doesn't contain any OS calls.