I have a MacBook Pro with M1 chip. I have installed Parallels Desktop 17 because I need to develop under Windows and .NET platform. I have virtualized Windows 11 on ARM and installed Visual Studio 2019 (and also 2022). When trying to install both Visual Studio, a warning message appears saying it is not supported on M1 chips and may be unstable and slow. Anyway I have installed them and I see performance is good (no slow) also it seems stable and I have been able to build .NET solutions without problems by selecting x86 architecture as target from the dropdown list. So I am wondering if the binaries generated are really x86. So are they generated as x86 or ARM? In case of they are generated as x86 how is that possible? Is there any x86 emulation layer to do so?
If you know how .NET compilation happens under the hood, then the answer is rather obvious.
First, your source files (C# or F# or any other language) are compiled to MSIL and stored in PE format,
https://en.wikipedia.org/wiki/Portable_Executable
Second, in most cases the MSIL code remains the same even if you change compilation option from Any CPU to x86/x64/ARM64, and the only visible change is the CORFLAGS,
https://learn.microsoft.com/en-us/dotnet/framework/tools/corflags-exe-corflags-conversion-tool
Note that you can use tools like
corflags.exe
to flip the flags easily post compilation.
So now back to your question. If you want to know if some assembly is targeting x86 or not, analyze its CORFLAGS. Generating x86 assemblies on an ARM64 machine does not require any magic.