Did microsoft rewrote CLR for each individual platform OS, or are they just same code?
Did microsoft rewrote CLR for each individual platform OS, or are they just same code?
A very broad question and simple answer is Yes, but only a part of CLR would be targeting the specific OS. This is how generally such system level software, which interact directly with OS and use its APIs work.
As part of architecture, there are two broad components:
a.) OS dependent (general terminology is SOSD (System OS dependant)
b.) OS independent
Now the OS independent part forms the APIs exposed to the outside, to the application programmers, which are thus standardized in terms of usage and functionality, but under the hood, these APIs for variety of system functions like memory management, thread / process management, Network, parallel processing have to consume the OS APIs, which in case of windows is generally accessing the Win32 using PInvoke and similar technology for other OS.
It is the OS dependent part which is rewritten to suit the OS, in fact even its flavor, like different distributions on Linux Unbuntu, Debian, even different version of windows and Mac to make it efficient internally, still standard in its working. The compilers and other tools on each platform are designed to then suit the requirements, so that the IL thus emitted can be efficiently target by relevant CLR to JIT compile to the native code, which can thus be executed to provide maximum efficiency. This is how various multi OS systems like Java, Oracle are designed.
.Net core which targets multiple OS (windows, linux, Mac) inherently supports .net Standard, which is also same for .Net framework for windows. When we target a code for .Net standard, which is generally subset of full fledged framework in terms of API, we are guaranteed that it will work across the OS and flavors supported by .Net like Xamarin, .Net core though the optimizations can be more specific and can be more performance oriented when we target the Windows only version of .Net framework (full fledged), thus there's a trade off