Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
[WIP] Enable binding to CoreLib as NI image (#11040)
Browse files Browse the repository at this point in the history
Enable binding to CoreLib as NI image
  • Loading branch information
gkhanna79 committed Apr 27, 2017
1 parent 368ee30 commit c983bb8
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 47 deletions.
6 changes: 3 additions & 3 deletions build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -379,15 +379,15 @@ 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
fi

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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
<NativeBinary Include="$(BinDir)libsosplugin.so" />
<NativeBinary Include="$(BinDir)System.Globalization.Native.so" />
<NativeBinary Include="$(BinDir)sosdocsunix.txt" />
<NativeBinary Condition="'$(_PlatformDoesNotSupportNiFiles)' != 'true'" Include="$(BinDir)System.Private.CoreLib.ni.dll" />
<ArchitectureSpecificLibFile Include="$(BinDir)System.Private.CoreLib.dll" />
<ArchitectureSpecificLibFile Include="$(BinDir)SOS.NETCore.dll" />
<ArchitectureSpecificToolFile Include="$(BinDir)crossgen" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<NativeBinary Include="$(BinDir)libsos.dylib" />
<NativeBinary Include="$(BinDir)System.Globalization.Native.dylib" />
<NativeBinary Include="$(BinDir)sosdocsunix.txt" />
<NativeBinary Include="$(BinDir)System.Private.CoreLib.ni.dll" />
<ArchitectureSpecificLibFile Include="$(BinDir)System.Private.CoreLib.dll" />
<ArchitectureSpecificLibFile Include="$(BinDir)SOS.NETCore.dll" />
<ArchitectureSpecificToolFile Include="$(BinDir)crossgen" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
<NativeBinary Include="$(BinDir)mscorrc.debug.dll" />
<NativeBinary Include="$(BinDir)mscorrc.dll" />
<NativeBinary Include="$(BinDir)sos.dll" />
<NativeBinary Include="$(BinDir)System.Private.CoreLib.ni.dll" />
<NativeBinary Include="$(UniversalCRTSDKDir)Redist\ucrt\DLLs\$(BuildArch)\*.dll" Condition="'$(BuildType)'=='Release' AND '$(BuildArch)' != 'arm64'" />
<ArchitectureSpecificLibFile Include="$(BinDir)System.Private.CoreLib.dll" />
<ArchitectureSpecificLibFile Include="$(BinDir)SOS.NETCore.dll" />
Expand Down
27 changes: 11 additions & 16 deletions src/binder/assemblybinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 8 additions & 0 deletions src/build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,21 @@
</Target>

<ItemGroup>
<ILToCopy Include="$(BinDir)System.Private.CoreLib.dll"/>
<PDBSToMove Include="$(BinDir)System.Private.CoreLib.pdb"/>
</ItemGroup>

<PropertyGroup>
<CoreLibPath>$(BinDir)System.Private.CoreLib.dll</CoreLibPath>
<CoreLibPDBPath>$(BinDir)System.Private.CoreLib.pdb</CoreLibPDBPath>
</PropertyGroup>

<Target Name="CopyCoreLib" AfterTargets="Build">
<Copy Condition="Exists($(CoreLibPath))"
SourceFiles="@(ILToCopy)"
DestinationFolder="$(BinDir)IL" />
</Target>

<Target Name="MovePDB" AfterTargets="Build">
<Move Condition="Exists($(CoreLibPDBPath))"
SourceFiles="@(PDBSToMove)"
Expand Down
27 changes: 4 additions & 23 deletions src/tools/crossgen/crossgen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,35 +311,16 @@ void PopulateTPAList(SString path, LPCWSTR pwszMask, SString &refTPAList, bool f
bool fAddDelimiter = (refTPAList.GetCount() > 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)
{
Expand Down

0 comments on commit c983bb8

Please sign in to comment.