From 07632ae1555bedb020f5cd94ddf9fc9580278bd6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tom=C3=A1=C5=A1=20Rylek?= Date: Sat, 22 Feb 2020 09:56:47 +0100 Subject: [PATCH] Additional SuperIlc fixes for running composite R2R images (#32665) As an expedite way to run "non-shared" composite R2R images (including the frameworK) I have added support to SuperIlc to copy corerun, coreclr, clrjit and mscorrc next to the compiled composite executable and supplying that as the CORE_ROOT folder; otherwise corerun in the normal Tests/Core_Root automatically grabs the framework next to it, not the composite rewritten versions. Thanks Tomas --- .../src/tools/ReadyToRun.SuperIlc/BuildFolder.cs | 30 ++++++++++++++++++++++ .../src/tools/ReadyToRun.SuperIlc/BuildOptions.cs | 2 +- .../tools/ReadyToRun.SuperIlc/CompilerRunner.cs | 13 +++++++++- .../src/tools/ReadyToRun.SuperIlc/CpaotRunner.cs | 2 +- .../tools/ReadyToRun.SuperIlc/CrossgenRunner.cs | 2 +- .../src/tools/ReadyToRun.SuperIlc/PathHelpers.cs | 5 +++- 6 files changed, 49 insertions(+), 5 deletions(-) diff --git a/src/coreclr/src/tools/ReadyToRun.SuperIlc/BuildFolder.cs b/src/coreclr/src/tools/ReadyToRun.SuperIlc/BuildFolder.cs index 567242b..c667d42 100644 --- a/src/coreclr/src/tools/ReadyToRun.SuperIlc/BuildFolder.cs +++ b/src/coreclr/src/tools/ReadyToRun.SuperIlc/BuildFolder.cs @@ -12,6 +12,21 @@ namespace ReadyToRun.SuperIlc { public class BuildFolder { + private static string[] s_runtimeExecutables = + { + "corerun" + }; + + private static string[] s_runtimeLibraries = + { + "coreclr", + "clrjit", + "mscorrc", + "mscorrc.debug", + "mscordaccore", + "mscordbi", + }; + private List _compilationInputFiles; private List _mainExecutables; @@ -134,6 +149,21 @@ namespace ReadyToRun.SuperIlc return null; } + if (options.Composite) + { + // In composite mode we copy the native runtime to the app folder and pretend that is CORE_ROOT, + // otherwise CoreRun picks up the original MSIL versions of framework assemblies from CORE_ROOT + // instead of the rewritten ones next to the app. + foreach (string exe in s_runtimeExecutables) + { + passThroughFiles.Add(Path.Combine(options.CoreRootDirectory.FullName, exe.AppendOSExeSuffix())); + } + foreach (string lib in s_runtimeLibraries) + { + passThroughFiles.Add(Path.Combine(options.CoreRootDirectory.FullName, lib.AppendOSDllSuffix())); + } + } + foreach (CompilerRunner runner in compilerRunners) { string runnerOutputPath = runner.GetOutputPath(outputRoot); diff --git a/src/coreclr/src/tools/ReadyToRun.SuperIlc/BuildOptions.cs b/src/coreclr/src/tools/ReadyToRun.SuperIlc/BuildOptions.cs index 08abd1d..70cb2ce 100644 --- a/src/coreclr/src/tools/ReadyToRun.SuperIlc/BuildOptions.cs +++ b/src/coreclr/src/tools/ReadyToRun.SuperIlc/BuildOptions.cs @@ -111,7 +111,7 @@ namespace ReadyToRun.SuperIlc public string CoreRunPath(CompilerIndex index, bool isFramework) { string coreRunDir = CoreRootOutputPath(index, isFramework); - string coreRunExe = "corerun".OSExeSuffix(); + string coreRunExe = "corerun".AppendOSExeSuffix(); string coreRunPath = Path.Combine(coreRunDir, coreRunExe); if (!File.Exists(coreRunPath)) { diff --git a/src/coreclr/src/tools/ReadyToRun.SuperIlc/CompilerRunner.cs b/src/coreclr/src/tools/ReadyToRun.SuperIlc/CompilerRunner.cs index 1ff43da..e37c783 100644 --- a/src/coreclr/src/tools/ReadyToRun.SuperIlc/CompilerRunner.cs +++ b/src/coreclr/src/tools/ReadyToRun.SuperIlc/CompilerRunner.cs @@ -187,10 +187,21 @@ namespace ReadyToRun.SuperIlc processParameters.Arguments = "-c " + scriptToRun; } + string coreRootDir; + if (_options.Composite) + { + coreRootDir = GetOutputPath(outputRoot); + } + else + { + coreRootDir = _options.CoreRootOutputPath(Index, isFramework: false); + } + processParameters.InputFileNames = new string[] { scriptToRun }; processParameters.OutputFileName = scriptToRun; processParameters.LogPath = scriptToRun + ".log"; - processParameters.EnvironmentOverrides["CORE_ROOT"] = _options.CoreRootOutputPath(Index, isFramework: false); + processParameters.EnvironmentOverrides["CORE_ROOT"] = coreRootDir; + return processParameters; } diff --git a/src/coreclr/src/tools/ReadyToRun.SuperIlc/CpaotRunner.cs b/src/coreclr/src/tools/ReadyToRun.SuperIlc/CpaotRunner.cs index f30e621..b2f22c5 100644 --- a/src/coreclr/src/tools/ReadyToRun.SuperIlc/CpaotRunner.cs +++ b/src/coreclr/src/tools/ReadyToRun.SuperIlc/CpaotRunner.cs @@ -19,7 +19,7 @@ namespace ReadyToRun.SuperIlc protected override string CompilerRelativePath => "crossgen2"; - protected override string CompilerFileName => "crossgen2".OSExeSuffix(); + protected override string CompilerFileName => "crossgen2".AppendOSExeSuffix(); private List _resolvedReferences; diff --git a/src/coreclr/src/tools/ReadyToRun.SuperIlc/CrossgenRunner.cs b/src/coreclr/src/tools/ReadyToRun.SuperIlc/CrossgenRunner.cs index c483c47..e2e9739 100644 --- a/src/coreclr/src/tools/ReadyToRun.SuperIlc/CrossgenRunner.cs +++ b/src/coreclr/src/tools/ReadyToRun.SuperIlc/CrossgenRunner.cs @@ -19,7 +19,7 @@ namespace ReadyToRun.SuperIlc protected override string CompilerRelativePath => "."; - protected override string CompilerFileName => "crossgen".OSExeSuffix(); + protected override string CompilerFileName => "crossgen".AppendOSExeSuffix(); protected override string CompilerPath { diff --git a/src/coreclr/src/tools/ReadyToRun.SuperIlc/PathHelpers.cs b/src/coreclr/src/tools/ReadyToRun.SuperIlc/PathHelpers.cs index dc50bbb..8361b34 100644 --- a/src/coreclr/src/tools/ReadyToRun.SuperIlc/PathHelpers.cs +++ b/src/coreclr/src/tools/ReadyToRun.SuperIlc/PathHelpers.cs @@ -30,7 +30,10 @@ static class PathExtensions /// const int DirectoryDeletionBackoffMilliseconds = 500; - internal static string OSExeSuffix(this string path) => (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? path + ".exe" : path); + internal static string AppendOSExeSuffix(this string path) => (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? path + ".exe" : path); + + internal static string AppendOSDllSuffix(this string path) => path + + (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ".dll" : RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? ".dylib" : ".so"); internal static string ToAbsolutePath(this string argValue) => Path.GetFullPath(argValue); -- 2.7.4