From 56336271be0e9128f7ff87a935c3873cf4f20871 Mon Sep 17 00:00:00 2001 From: David Wrighton Date: Wed, 31 Mar 2021 18:24:57 -0700 Subject: [PATCH] Simplify mibc usage in the build - Produce a merged mibc with all scenarios squished together - Properly attach the mibc data to the incremental build for System.Private.CoreLib - This can't be done for the framework here. It will require mibc integration in the SDK - Enable pgo optimization in checked builds - Enable pgo optimization in framework compile for outerloop runs --- Build.proj | 2 +- Directory.Build.props | 2 +- src/coreclr/crossgen-corelib.proj | 31 ++++++++++++++----- src/coreclr/tools/r2rtest/BuildOptions.cs | 1 + .../tools/r2rtest/CommandLineOptions.cs | 9 ++++++ src/coreclr/tools/r2rtest/Crossgen2Runner.cs | 9 ++++++ .../Microsoft.NETCore.App/ReadyToRun.targets | 6 ++-- src/tests/build.cmd | 2 +- src/tests/build.sh | 2 +- 9 files changed, 49 insertions(+), 15 deletions(-) diff --git a/Build.proj b/Build.proj index 6dcc3b9542037b..44da6d66f9942c 100644 --- a/Build.proj +++ b/Build.proj @@ -18,7 +18,7 @@ - + diff --git a/Directory.Build.props b/Directory.Build.props index 4ee7e1db360f89..3917b5b3f7b51e 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -200,7 +200,7 @@ - true + true true diff --git a/src/coreclr/crossgen-corelib.proj b/src/coreclr/crossgen-corelib.proj index 2399255b78d0f2..53c4e57c72eb58 100644 --- a/src/coreclr/crossgen-corelib.proj +++ b/src/coreclr/crossgen-corelib.proj @@ -45,6 +45,10 @@ + + + + System.Private.CoreLib $([MSBuild]::NormalizePath('$(BinDir)', 'IL', '$(CoreLibAssemblyName).dll')) @@ -53,12 +57,28 @@ $([MSBuild]::NormalizePath('$(BinDir)', 'PDB', '$(CoreLibAssemblyName).ni.pdb')) $([MSBuild]::NormalizePath('$(BinDir)', '$(CoreLibAssemblyName).perf.map')) + $([MSBuild]::NormalizePath('$(BinDir)', 'StandardOptimizationData.mibc')) - + + + $(DotNetCli) $([MSBuild]::NormalizePath('$(BinDir)', 'dotnet-pgo', 'dotnet-pgo.dll')) merge + $(DotNetPgoCmd) -o:$(MergedMibcPath) + $(DotNetPgoCmd) @(OptimizationMibcFiles->'-i:%(Identity)', ' ') + + + + + + + @@ -75,17 +95,12 @@ - - - - $(DotNetCli) $([MSBuild]::NormalizePath('$(BinDir)', '$(CrossDir)', 'crossgen2', 'crossgen2.dll')) $(CrossGenDllCmd) -o:$(CoreLibOutputPath) $(CrossGenDllCmd) -r:$([MSBuild]::NormalizePath('$(BinDir)', 'IL', '*.dll')) $(CrossGenDllCmd) --targetarch:$(TargetArchitecture) - @(OptimizationMibcFiles->'-m:%(Identity)', ' ') - $(CrossGenDllCmd) $(MibcArgs) --embed-pgo-data + $(CrossGenDllCmd) -m:$(MergedMibcPath) --embed-pgo-data $(CrossGenDllCmd) -O $(CrossGenDllCmd) $(CoreLibInputPath) diff --git a/src/coreclr/tools/r2rtest/BuildOptions.cs b/src/coreclr/tools/r2rtest/BuildOptions.cs index 0a2a8fe0eb7f3d..3465aa18598d7b 100644 --- a/src/coreclr/tools/r2rtest/BuildOptions.cs +++ b/src/coreclr/tools/r2rtest/BuildOptions.cs @@ -49,6 +49,7 @@ public class BuildOptions public string InputFileSearchString { get; set; } public string ConfigurationSuffix => (Release ? "-ret.out" : "-chk.out"); public string GCStress { get; set; } + public FileInfo[] MibcPath { get; set; } public string DotNetCli { get diff --git a/src/coreclr/tools/r2rtest/CommandLineOptions.cs b/src/coreclr/tools/r2rtest/CommandLineOptions.cs index ebadfd8fcdb450..d99e5af1c0c0a9 100644 --- a/src/coreclr/tools/r2rtest/CommandLineOptions.cs +++ b/src/coreclr/tools/r2rtest/CommandLineOptions.cs @@ -70,6 +70,7 @@ Command CompileFolder() => R2RDumpPath(), MeasurePerf(), InputFileSearchString(), + MibcPath(), }, CompileDirectoryCommand.CompileDirectory); @@ -107,6 +108,7 @@ Command CompileSubtree() => ExecutionTimeoutMinutes(), R2RDumpPath(), GCStress(), + MibcPath(), }, CompileSubtreeCommand.CompileSubtree); @@ -137,6 +139,7 @@ Command CompileFramework() => MeasurePerf(), InputFileSearchString(), OutputDirectory(), + MibcPath(), }, CompileFrameworkCommand.CompileFramework); @@ -155,6 +158,7 @@ Command CompileNugetPackages() => DegreeOfParallelism(), CompilationTimeoutMinutes(), ExecutionTimeoutMinutes(), + MibcPath(), }, CompileNugetCommand.CompileNuget); @@ -170,6 +174,7 @@ Command CompileSerp() => Pdb(), CompilationTimeoutMinutes(), Crossgen2Path(), + MibcPath(), }, options => { @@ -195,6 +200,10 @@ Option ReferencePath() => new Option(new[] { "--reference-path", "-r" }, "Folder containing assemblies to reference during compilation") { Argument = new Argument() { Arity = ArgumentArity.ZeroOrMore }.ExistingOnly() }; + Option MibcPath() => + new Option(new[] { "--mibc-path", "-m" }, "Mibc files to use in compilation") + { Argument = new Argument() { Arity = ArgumentArity.ZeroOrMore }.ExistingOnly() }; + Option Crossgen() => new Option(new[] { "--crossgen" }, "Compile the apps using Crossgen in the CORE_ROOT folder"); diff --git a/src/coreclr/tools/r2rtest/Crossgen2Runner.cs b/src/coreclr/tools/r2rtest/Crossgen2Runner.cs index 19d13dc2fc6073..2aa1dee6b6f6d0 100644 --- a/src/coreclr/tools/r2rtest/Crossgen2Runner.cs +++ b/src/coreclr/tools/r2rtest/Crossgen2Runner.cs @@ -122,6 +122,15 @@ protected override IEnumerable BuildCommandLineArguments(IEnumerable 0) + { + yield return "--embed-pgo-data"; + foreach (FileInfo mibc in _options.MibcPath) + { + yield return $"-m:{mibc.FullName}"; + } + } + if (!string.IsNullOrEmpty(Crossgen2RunnerOptions.CompositeRoot)) { yield return $"--compositerootpath={Crossgen2RunnerOptions.CompositeRoot}"; diff --git a/src/installer/pkg/sfx/Microsoft.NETCore.App/ReadyToRun.targets b/src/installer/pkg/sfx/Microsoft.NETCore.App/ReadyToRun.targets index 5d3492a286ed67..5b5f23f28b7d08 100644 --- a/src/installer/pkg/sfx/Microsoft.NETCore.App/ReadyToRun.targets +++ b/src/installer/pkg/sfx/Microsoft.NETCore.App/ReadyToRun.targets @@ -1,15 +1,15 @@ - + - - + + diff --git a/src/tests/build.cmd b/src/tests/build.cmd index b4f9a7b0702a41..18a85d6ae62214 100644 --- a/src/tests/build.cmd +++ b/src/tests/build.cmd @@ -578,7 +578,7 @@ exit /b 1 set "__CrossgenOutputDir=%__TestIntermediatesDir%\crossgen.out" -set __CrossgenCmd="%__RepoRootDir%\dotnet.cmd" "%CORE_ROOT%\R2RTest\R2RTest.dll" compile-framework -cr "%CORE_ROOT%" --output-directory "%__CrossgenOutputDir%" --release --nocleanup --target-arch %__BuildArch% -dop %NUMBER_OF_PROCESSORS% +set __CrossgenCmd="%__RepoRootDir%\dotnet.cmd" "%CORE_ROOT%\R2RTest\R2RTest.dll" compile-framework -cr "%CORE_ROOT%" --output-directory "%__CrossgenOutputDir%" --release --nocleanup --target-arch %__BuildArch% -dop %NUMBER_OF_PROCESSORS% -m "%CORE_ROOT%\StandardOptimizationData.mibc" if defined __CreatePdb ( set __CrossgenCmd=!__CrossgenCmd! --pdb diff --git a/src/tests/build.sh b/src/tests/build.sh index 4531a07e3d77fc..0d15d53b53910e 100755 --- a/src/tests/build.sh +++ b/src/tests/build.sh @@ -158,7 +158,7 @@ precompile_coreroot_fx() fi local outputDir="$__TestIntermediatesDir/crossgen.out" - local crossgenCmd="\"$__DotNetCli\" \"$CORE_ROOT/R2RTest/R2RTest.dll\" compile-framework -cr \"$CORE_ROOT\" --output-directory \"$outputDir\" --release --nocleanup --target-arch $__BuildArch -dop $__NumProc" + local crossgenCmd="\"$__DotNetCli\" \"$CORE_ROOT/R2RTest/R2RTest.dll\" compile-framework -cr \"$CORE_ROOT\" --output-directory \"$outputDir\" --release --nocleanup --target-arch $__BuildArch -dop $__NumProc -m \"$CORE_ROOT/StandardOptimizationData.mibc\"" if [[ "$__CompositeBuildMode" != 0 ]]; then crossgenCmd="$crossgenCmd --composite"