Use netcoreapp3.0 for building crossgen2 (dotnet/coreclr#26792)
authorDavid Wrighton <davidwr@microsoft.com>
Tue, 24 Sep 2019 20:35:58 +0000 (13:35 -0700)
committerGitHub <noreply@github.com>
Tue, 24 Sep 2019 20:35:58 +0000 (13:35 -0700)
* Use netcoreapp3.0 for building crossgen2
- Enables better debugging support
- Enables use of netcoreapp3.0 surface area in crossgen2
- Should improve performance
- Initialize the PAL in the jit on Unix builds
- Enable crossgen2smoke on alpine

Commit migrated from https://github.com/dotnet/coreclr/commit/41471dc78816edffa072582f2f826210829bf0d1

src/coreclr/src/tools/crossgen2/Common/JitInterface/CorInfoImpl.cs
src/coreclr/src/tools/crossgen2/ILCompiler.DependencyAnalysisFramework/ILCompiler.DependencyAnalysisFramework.csproj
src/coreclr/src/tools/crossgen2/ILCompiler.ReadyToRun/ILCompiler.ReadyToRun.csproj
src/coreclr/src/tools/crossgen2/ILCompiler.TypeSystem.ReadyToRun/ILCompiler.TypeSystem.ReadyToRun.csproj
src/coreclr/src/tools/crossgen2/crossgen2/crossgen2.csproj
src/coreclr/tests/src/readytorun/crossgen2/crossgen2smoke.csproj

index a64cf95..6b2d62d 100644 (file)
@@ -55,6 +55,11 @@ namespace Internal.JitInterface
 
         private ExceptionDispatchInfo _lastException;
 
+        private static bool s_jitRegistered = RegisterJITModule();
+
+        [DllImport("clrjitilc")]
+        private extern static IntPtr PAL_RegisterModule([MarshalAs(UnmanagedType.LPUTF8Str)] string moduleName);
+
         [DllImport("clrjitilc", CallingConvention=CallingConvention.StdCall)] // stdcall in CoreCLR!
         private extern static IntPtr jitStartup(IntPtr host);
 
@@ -109,12 +114,26 @@ namespace Internal.JitInterface
 
         private readonly UnboxingMethodDescFactory _unboxingThunkFactory;
 
+        private static bool RegisterJITModule()
+        {
+            if ((Environment.OSVersion.Platform == PlatformID.Unix) || (Environment.OSVersion.Platform == PlatformID.MacOSX))
+            {
+                return PAL_RegisterModule("libclrjitilc.so") != (IntPtr)1;
+            }
+            else
+            {
+                return true;
+            }
+        }
+
         public CorInfoImpl(JitConfigProvider jitConfig)
         {
             //
             // Global initialization
             //
             _jitConfig = jitConfig;
+            if (!s_jitRegistered)
+                throw new IOException("Failed to register JIT");
 
             jitStartup(GetJitHost(_jitConfig.UnmanagedInstance));
 
index 3a0dc1e..3ac648b 100644 (file)
@@ -7,7 +7,7 @@
     <TargetFramework>netstandard1.3</TargetFramework>
     <EnableDefaultCompileItems>false</EnableDefaultCompileItems>
     <Platforms>x64;x86</Platforms>
-    <OutputPath>$(BinDir)\crossgen2</OutputPath>
+    <OutputPath>$(BinDir)/crossgen2/libs</OutputPath>
     <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
   </PropertyGroup>
   <ItemGroup>
index 28f4459..87bfdf3 100644 (file)
@@ -4,12 +4,12 @@
   <PropertyGroup>
     <OutputType>Library</OutputType>
     <AssemblyName>ILCompiler.ReadyToRun</AssemblyName>
-    <TargetFramework>netstandard1.3</TargetFramework>
+    <TargetFramework>netcoreapp3.0</TargetFramework>
     <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
     <DefineConstants>READYTORUN;$(DefineConstants)</DefineConstants>
     <EnableDefaultCompileItems>false</EnableDefaultCompileItems>
     <Platforms>x64;x86</Platforms>
-    <OutputPath>$(BinDir)\crossgen2</OutputPath>
+    <OutputPath>$(BinDir)/crossgen2/libs</OutputPath>
     <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
   </PropertyGroup>
   
index d130008..0598bb9 100644 (file)
@@ -9,7 +9,7 @@
     <TargetFramework>netstandard1.3</TargetFramework>
     <EnableDefaultCompileItems>false</EnableDefaultCompileItems>
     <Platforms>x64;x86</Platforms>
-    <OutputPath>$(BinDir)\crossgen2</OutputPath>
+    <OutputPath>$(BinDir)/crossgen2/libs</OutputPath>
     <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
   </PropertyGroup>
   <ItemGroup>
index 2a1fe01..e1d1e9c 100644 (file)
@@ -5,10 +5,10 @@
     <AssemblyName>crossgen2</AssemblyName>
     <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
     <OutputType>Exe</OutputType>
-    <TargetFramework>netcoreapp2.0</TargetFramework>
+    <TargetFramework>netcoreapp3.0</TargetFramework>
     <NoWarn>8002,NU1701</NoWarn>
     <Platforms>x64;x86</Platforms>
-    <OutputPath>$(BinDir)\crossgen2</OutputPath>
+    <OutputPath>$(BinDir)/crossgen2</OutputPath>
     <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
   </PropertyGroup>
 
index 674eba3..d521fc1 100644 (file)
@@ -27,14 +27,7 @@ $(CLRTestBatchPreCommands)
 ]]></CLRTestBatchPreCommands>
     <BashCLRTestPreCommands><![CDATA[
 $(BashCLRTestPreCommands)
-if [ -e "/etc/os-release" ]; then
-    source /etc/os-release
-fi
-if [ "${ID}" != "alpine" ]; then
-    $CORE_ROOT/crossgen2/crossgen2 -r:$CORE_ROOT/*.dll -o:crossgen2smoke.dll crossgen2smoke.ildll
-else
-    cp crossgen2smoke.ildll crossgen2smoke.dll
-fi
+$CORE_ROOT/crossgen2/crossgen2 -r:$CORE_ROOT/*.dll -o:crossgen2smoke.dll crossgen2smoke.ildll
 ]]></BashCLRTestPreCommands>
   </PropertyGroup>
 </Project>