From c983bb86ddf46916206efc7cd5bc942ec8b834cb Mon Sep 17 00:00:00 2001 From: Gaurav Khanna Date: Thu, 27 Apr 2017 10:46:47 -0700 Subject: [PATCH] [WIP] Enable binding to CoreLib as NI image (#11040) Enable binding to CoreLib as NI image --- build.cmd | 6 ++--- build.sh | 4 +-- ...ux.Microsoft.NETCore.Runtime.CoreCLR.props | 1 - ...SX.Microsoft.NETCore.Runtime.CoreCLR.props | 1 - ...NT.Microsoft.NETCore.Runtime.CoreCLR.props | 1 - src/binder/assemblybinder.cpp | 27 ++++++++----------- src/build.proj | 8 ++++++ src/tools/crossgen/crossgen.cpp | 27 +++---------------- 8 files changed, 28 insertions(+), 47 deletions(-) diff --git a/build.cmd b/build.cmd index 64945cc1591b..715c6c228ad8 100644 --- a/build.cmd +++ b/build.cmd @@ -454,15 +454,15 @@ if %__BuildNativeCoreLib% EQU 1 ( set COMPlus_UseWindowsX86CoreLegacyJit=1 ) - echo "%__CrossgenExe%" %__IbcTuning% /Platform_Assemblies_Paths "%__BinDir%" /out "%__BinDir%\System.Private.CoreLib.ni.dll" "%__BinDir%\System.Private.CoreLib.dll" - "%__CrossgenExe%" %__IbcTuning% /Platform_Assemblies_Paths "%__BinDir%" /out "%__BinDir%\System.Private.CoreLib.ni.dll" "%__BinDir%\System.Private.CoreLib.dll" > "%__CrossGenCoreLibLog%" 2>&1 + echo "%__CrossgenExe%" %__IbcTuning% /Platform_Assemblies_Paths "%__BinDir%"\IL /out "%__BinDir%\System.Private.CoreLib.dll" "%__BinDir%\IL\System.Private.CoreLib.dll" + "%__CrossgenExe%" %__IbcTuning% /Platform_Assemblies_Paths "%__BinDir%"\IL /out "%__BinDir%\System.Private.CoreLib.dll" "%__BinDir%\IL\System.Private.CoreLib.dll" > "%__CrossGenCoreLibLog%" 2>&1 if NOT !errorlevel! == 0 ( echo %__MsgPrefix%Error: CrossGen System.Private.CoreLib build failed. Refer to %__CrossGenCoreLibLog% :: Put it in the same log, helpful for Jenkins type %__CrossGenCoreLibLog% goto CrossgenFailure ) - "%__CrossgenExe%" /Platform_Assemblies_Paths "%__BinDir%" /CreatePdb "%__BinDir%\PDB" "%__BinDir%\System.Private.CoreLib.ni.dll" >> "%__CrossGenCoreLibLog%" 2>&1 + "%__CrossgenExe%" /Platform_Assemblies_Paths "%__BinDir%" /CreatePdb "%__BinDir%\PDB" "%__BinDir%\System.Private.CoreLib.dll" >> "%__CrossGenCoreLibLog%" 2>&1 if NOT !errorlevel! == 0 ( echo %__MsgPrefix%Error: CrossGen /CreatePdb System.Private.CoreLib build failed. Refer to %__CrossGenCoreLibLog% :: Put it in the same log, helpful for Jenkins diff --git a/build.sh b/build.sh index 018cdf0439bd..12b7b726c4c3 100755 --- a/build.sh +++ b/build.sh @@ -379,7 +379,7 @@ build_CoreLib_ni() { if [ $__SkipCoreCLR == 0 -a -e $__BinDir/crossgen ]; then echo "Generating native image for System.Private.CoreLib." - $__BinDir/crossgen $__IbcTuning $__BinDir/System.Private.CoreLib.dll + $__BinDir/crossgen /Platform_Assemblies_Paths $__BinDir/IL $__IbcTuning /out $__BinDir/System.Private.CoreLib.dll $__BinDir/IL/System.Private.CoreLib.dll if [ $? -ne 0 ]; then echo "Failed to generate native image for System.Private.CoreLib." exit 1 @@ -387,7 +387,7 @@ build_CoreLib_ni() if [ "$__BuildOS" == "Linux" ]; then echo "Generating symbol file for System.Private.CoreLib." - $__BinDir/crossgen /CreatePerfMap $__BinDir $__BinDir/System.Private.CoreLib.ni.dll + $__BinDir/crossgen /CreatePerfMap $__BinDir $__BinDir/System.Private.CoreLib.dll if [ $? -ne 0 ]; then echo "Failed to generate symbol file for System.Private.CoreLib." exit 1 diff --git a/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/runtime.Linux.Microsoft.NETCore.Runtime.CoreCLR.props b/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/runtime.Linux.Microsoft.NETCore.Runtime.CoreCLR.props index 4ad2538826db..5c55497af945 100644 --- a/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/runtime.Linux.Microsoft.NETCore.Runtime.CoreCLR.props +++ b/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/runtime.Linux.Microsoft.NETCore.Runtime.CoreCLR.props @@ -17,7 +17,6 @@ - diff --git a/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/runtime.OSX.Microsoft.NETCore.Runtime.CoreCLR.props b/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/runtime.OSX.Microsoft.NETCore.Runtime.CoreCLR.props index b988a407458d..1d16788c06c4 100644 --- a/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/runtime.OSX.Microsoft.NETCore.Runtime.CoreCLR.props +++ b/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/runtime.OSX.Microsoft.NETCore.Runtime.CoreCLR.props @@ -8,7 +8,6 @@ - diff --git a/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/runtime.Windows_NT.Microsoft.NETCore.Runtime.CoreCLR.props b/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/runtime.Windows_NT.Microsoft.NETCore.Runtime.CoreCLR.props index 436901ebd278..a7d855511f4d 100644 --- a/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/runtime.Windows_NT.Microsoft.NETCore.Runtime.CoreCLR.props +++ b/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/runtime.Windows_NT.Microsoft.NETCore.Runtime.CoreCLR.props @@ -19,7 +19,6 @@ - diff --git a/src/binder/assemblybinder.cpp b/src/binder/assemblybinder.cpp index a73f79fb65b0..bd5dd18cc9f0 100644 --- a/src/binder/assemblybinder.cpp +++ b/src/binder/assemblybinder.cpp @@ -685,26 +685,21 @@ namespace BINDER_SPACE StackSString sCoreLib; - // At run-time, System.Private.CoreLib.ni.dll is typically always available, and - // System.Private.CoreLib.dll is typically not. So check for the NI first. + // At run-time, System.Private.CoreLib.dll is expected to be the NI image. sCoreLib = sCoreLibDir; - sCoreLib.Append(CoreLibName_NI_W); - if (!fBindToNativeImage || FAILED(AssemblyBinder::GetAssembly(sCoreLib, - FALSE /* fInspectionOnly */, - TRUE /* fIsInGAC */, - TRUE /* fExplicitBindToNativeImage */, - &pSystemAssembly))) - { - // If System.Private.CoreLib.ni.dll is unavailable, look for System.Private.CoreLib.dll instead - sCoreLib = sCoreLibDir; - sCoreLib.Append(CoreLibName_IL_W); - IF_FAIL_GO(AssemblyBinder::GetAssembly(sCoreLib, + sCoreLib.Append(CoreLibName_IL_W); + BOOL fExplicitBindToNativeImage = (fBindToNativeImage == true)? TRUE:FALSE; +#if defined(FEATURE_PAL) && !defined(_TARGET_AMD64_) + // Non-Amd64 platforms on non-Windows do not support generating the NI image + // as CoreLib.dll. For those, we will bind as IL. + fExplicitBindToNativeImage = FALSE; +#endif // defined(FEATURE_PAL) && !defined(_TARGET_AMD64_) + IF_FAIL_GO(AssemblyBinder::GetAssembly(sCoreLib, FALSE /* fInspectionOnly */, TRUE /* fIsInGAC */, - FALSE /* fExplicitBindToNativeImage */, + fExplicitBindToNativeImage, &pSystemAssembly)); - } - + *ppSystemAssembly = pSystemAssembly.Extract(); Exit: diff --git a/src/build.proj b/src/build.proj index 5da94e44c1b4..7962d27e9990 100644 --- a/src/build.proj +++ b/src/build.proj @@ -17,13 +17,21 @@ + + $(BinDir)System.Private.CoreLib.dll $(BinDir)System.Private.CoreLib.pdb + + + + 0)?true:false; bool fAddFileToTPAList = true; LPCWSTR pwszFilename = folderEnumerator.GetFileName(); - if (fCompilingMscorlib) + + // No NIs are supported when creating NI images (other than NI of System.Private.CoreLib.dll). + if (!fCreatePDB) { - // When compiling CoreLib, no ".ni.dll" should be on the TPAList. + // Only CoreLib's ni.dll should be in the TPAList for the compilation of non-mscorlib assemblies. if (StringEndsWith((LPWSTR)pwszFilename, W(".ni.dll"))) { fAddFileToTPAList = false; } } - else - { - // When creating PDBs, we must ensure that .ni.dlls are in the TPAList - if (!fCreatePDB) - { - // Only CoreLib's ni.dll should be in the TPAList for the compilation of non-mscorlib assemblies. - if (StringEndsWith((LPWSTR)pwszFilename, W(".ni.dll"))) - { - if (!StringEndsWith((LPWSTR)pwszFilename, CoreLibName_NI_W)) - { - fAddFileToTPAList = false; - } - } - } - - // Ensure that CoreLib's IL version is also not on the TPAlist for this case. - if (StringEndsWith((LPWSTR)pwszFilename, CoreLibName_IL_W)) - { - fAddFileToTPAList = false; - } - } if (fAddFileToTPAList) {