Crossgen now requires a Jit package to be specified.

Port Crossgen fix from core-setup.

See a2857af7e3
This commit is contained in:
Eric Erhardt 2016-06-07 12:36:13 -05:00
parent 748516bb0d
commit 82ef0304bb
5 changed files with 66 additions and 36 deletions

View file

@ -56,7 +56,7 @@ namespace Microsoft.DotNet.Cli.Build
public const string SharedFrameworkName = "Microsoft.NETCore.App";
public static Crossgen CrossgenUtil = new Crossgen(DependencyVersions.CoreCLRVersion);
public static Crossgen CrossgenUtil = new Crossgen(DependencyVersions.CoreCLRVersion, DependencyVersions.JitVersion);
// Updates the stage 2 with recent changes.
[Target(nameof(PrepareTargets.Init), nameof(CompileStage2))]

View file

@ -8,5 +8,6 @@ namespace Microsoft.DotNet.Cli.Build
public class DependencyVersions
{
public static readonly string CoreCLRVersion = "1.0.2-rc3-24206-00";
public static readonly string JitVersion = "1.0.2-rc3-24206-00";
}
}

View file

@ -11,8 +11,9 @@ namespace Microsoft.DotNet.Cli.Build
public class Crossgen
{
private string _coreClrVersion;
private string _jitVersion;
private string _crossGenPath;
private static readonly string[] s_excludedLibraries =
private static readonly string[] s_excludedLibraries =
{
"mscorlib.dll",
"mscorlib.ni.dll",
@ -25,9 +26,10 @@ namespace Microsoft.DotNet.Cli.Build
// in CompileTargets and the one in the shared library project.json match and are updated in lock step, but long term
// we need to be able to look at the project.lock.json file and figure out what version of Microsoft.NETCore.Runtime.CoreCLR
// was used, and then select that version.
public Crossgen(string coreClrVersion)
public Crossgen(string coreClrVersion, string jitVersion)
{
_coreClrVersion = coreClrVersion;
_jitVersion = jitVersion;
_crossGenPath = GetCrossgenPathForVersion();
}
@ -48,21 +50,59 @@ namespace Microsoft.DotNet.Cli.Build
private string GetLibCLRJitPathForVersion()
{
var coreclrRid = GetCoreCLRRid();
var crossgenPackagePath = GetCrossGenPackagePathForVersion();
var jitRid = GetCoreCLRRid();
var jitPackagePath = GetJitPackagePathForVersion();
if (crossgenPackagePath == null)
if (jitPackagePath == null)
{
return null;
}
return Path.Combine(
crossgenPackagePath,
jitPackagePath,
"runtimes",
coreclrRid,
jitRid,
"native",
$"{Constants.DynamicLibPrefix}clrjit{Constants.DynamicLibSuffix}");
}
}
private string GetJitPackagePathForVersion()
{
string jitRid = GetCoreCLRRid();
if (jitRid == null)
{
return null;
}
string packageId = $"runtime.{jitRid}.Microsoft.NETCore.Jit";
return Path.Combine(
Dirs.NuGetPackages,
packageId,
_jitVersion);
}
private string GetCoreLibsDirForVersion()
{
string coreclrRid = GetCoreCLRRid();
if (coreclrRid == null)
{
return null;
}
string packageId = $"runtime.{coreclrRid}.Microsoft.NETCore.Runtime.CoreCLR";
return Path.Combine(
Dirs.NuGetPackages,
packageId,
_coreClrVersion,
"runtimes",
coreclrRid,
"lib",
"netstandard1.0");
}
private string GetCrossGenPackagePathForVersion()
{
@ -73,7 +113,7 @@ namespace Microsoft.DotNet.Cli.Build
return null;
}
string packageId = $"runtime.{coreclrRid}.Microsoft.NETCore.Runtime.CoreCLR";
string packageId = $"runtime.{coreclrRid}.Microsoft.NETCore.Runtime.CoreCLR";
return Path.Combine(
Dirs.NuGetPackages,
@ -89,34 +129,23 @@ namespace Microsoft.DotNet.Cli.Build
var arch = RuntimeEnvironment.RuntimeArchitecture;
rid = $"win7-{arch}";
}
else if (CurrentPlatform.IsUbuntu)
{
rid = $"ubuntu.{RuntimeEnvironment.OperatingSystemVersion}-x64";
}
else if (CurrentPlatform.IsCentOS || CurrentPlatform.IsRHEL)
{
// CentOS runtime is in the runtime.rhel.7-x64... package.
rid = "rhel.7-x64";
}
else if (CurrentPlatform.IsOSX)
{
rid = "osx.10.10-x64";
}
else if (CurrentPlatform.IsDebian)
else if (CurrentPlatform.IsCentOS || CurrentPlatform.IsRHEL)
{
rid = "debian.8-x64";
// CentOS runtime is in the runtime.rhel.7-x64... package as are all
// versions of RHEL
rid = "rhel.7-x64";
}
else if (CurrentPlatform.IsFedora)
else if (CurrentPlatform.IsLinux)
{
rid = $"fedora.{RuntimeEnvironment.OperatingSystemVersion}-x64";
}
else if (CurrentPlatform.IsOpenSuse)
{
rid = $"opensuse.{RuntimeEnvironment.OperatingSystemVersion}-x64";
rid = RuntimeEnvironment.GetRuntimeIdentifier();
}
return rid;
}
}
public void CrossgenDirectory(string sharedFxPath, string pathToAssemblies)
{
@ -137,10 +166,12 @@ namespace Microsoft.DotNet.Cli.Build
// The right fix -
// If the assembly has deps.json then parse the json file to get all the dependencies, pass these dependencies as input to crossgen.
// else pass the current directory of assembly as input to crossgen.
var coreLibsDir = GetCoreLibsDirForVersion();
var addtionalPaths = Directory.GetDirectories(pathToAssemblies, "*", SearchOption.AllDirectories).ToList();
var paths = new List<string>() { sharedFxPath, pathToAssemblies };
var paths = new List<string>() { coreLibsDir, sharedFxPath, pathToAssemblies };
paths.AddRange(addtionalPaths);
var platformAssembliesPaths = string.Join(Path.PathSeparator.ToString(), paths.Distinct());
var jitPath = GetLibCLRJitPathForVersion();
var env = new Dictionary<string, string>()
{
@ -152,7 +183,7 @@ namespace Microsoft.DotNet.Cli.Build
{
string fileName = Path.GetFileName(file);
if (s_excludedLibraries.Any(lib => String.Equals(lib, fileName, StringComparison.OrdinalIgnoreCase))
if (s_excludedLibraries.Any(lib => String.Equals(lib, fileName, StringComparison.OrdinalIgnoreCase))
|| !PEUtils.HasMetadata(file))
{
continue;
@ -165,11 +196,8 @@ namespace Microsoft.DotNet.Cli.Build
"-platform_assemblies_paths", platformAssembliesPaths
};
if (CurrentPlatform.IsUnix)
{
crossgenArgs.Add("-JITPath");
crossgenArgs.Add(GetLibCLRJitPathForVersion());
}
crossgenArgs.Add("-JITPath");
crossgenArgs.Add(jitPath);
ExecSilent(_crossGenPath, crossgenArgs, env);

View file

@ -25,7 +25,7 @@ namespace Microsoft.DotNet.Cli.Build
private string _corehostLockedDirectory;
private string _corehostLatestDirectory;
private Crossgen _crossgenUtil = new Crossgen(DependencyVersions.CoreCLRVersion);
private Crossgen _crossgenUtil = new Crossgen(DependencyVersions.CoreCLRVersion, DependencyVersions.JitVersion);
private string _corehostPackageSource;
public SharedFrameworkPublisher(

View file

@ -212,6 +212,7 @@ namespace Microsoft.DotNet.Scripts
ReplaceFileContents(@"build_projects\shared-build-targets-utils\DependencyVersions.cs", fileContents =>
{
fileContents = ReplaceDependencyVersion(c, fileContents, "CoreCLRVersion", "Microsoft.NETCore.Runtime.CoreCLR");
fileContents = ReplaceDependencyVersion(c, fileContents, "JitVersion", "Microsoft.NETCore.Jit");
return fileContents;
});