Switch to selfhosted NativeAOT compiler (#81205)
authorMichal Strehovský <MichalStrehovsky@users.noreply.github.com>
Thu, 9 Mar 2023 23:30:30 +0000 (08:30 +0900)
committerGitHub <noreply@github.com>
Thu, 9 Mar 2023 23:30:30 +0000 (08:30 +0900)
This will compile the NativeAOT compiler with the LKG build of the NativeAOT compiler that the repo is building with.

At this point NativeAOT-compiled compiler is significantly better than the R2R+Trimmed+SingleFile-compiled combo we're shipping right now.

ilc.exe size before: 31 MB. ilc.exe size after: 14 MB.
Time to compile hello world before: 2.3 seconds. Time to compile hello world after: 1.3 seconds.

src/coreclr/tools/aot/ILCompiler/ILCompiler.csproj

index fb49fd1..db48433 100644 (file)
   <!-- BEGIN: Workaround for https://github.com/dotnet/runtime/issues/67742 -->
   <PropertyGroup Condition="'$(BuildingInsideVisualStudio)' != 'true'">
     <PublishDir>$(RuntimeBinDir)ilc-published/</PublishDir>
-    <PublishTrimmed>true</PublishTrimmed>
-    <!-- Don't R2R on ARM64 machines because ARM64 crossgen2 that comes with .NET SDK <= 7.0 Preview 7 crashes.-->
-    <PublishReadyToRun Condition="'$(BuildArchitecture)' != 'arm64'">true</PublishReadyToRun>
-    <PublishSingleFile>true</PublishSingleFile>
+    <NativeAotSupported Condition="'$(TargetOS)' != 'windows' and '$(TargetOS)' != 'linux' and '$(TargetOS)' != 'osx'">false</NativeAotSupported>
+    <NativeAotSupported Condition="'$(TargetArchitecture)' != 'x64'">false</NativeAotSupported>
+    <PublishAot Condition="'$(NativeAotSupported)' == 'true'">true</PublishAot>
+    <PublishReadyToRun Condition="'$(NativeAotSupported)' != 'true'">true</PublishReadyToRun>
+    <PublishSingleFile Condition="'$(NativeAotSupported)' != 'true'">true</PublishSingleFile>
+    <PublishTrimmed Condition="'$(NativeAotSupported)' != 'true'">true</PublishTrimmed>
   </PropertyGroup>
 
   <Target Name="PublishCompiler"