Merge pull request #7953 from nguerrera/crossgen-symbols

Generate symbols on crossgen for profiling
This commit is contained in:
Nick Guerrera 2017-11-06 12:15:33 -08:00 committed by GitHub
commit 5fbaee6344
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 72 additions and 28 deletions

View file

@ -21,14 +21,14 @@
<HostMonikerRid Condition=" '$(HostMonikerRid)' == '' ">$(HostOSName)-$(Architecture)</HostMonikerRid> <HostMonikerRid Condition=" '$(HostMonikerRid)' == '' ">$(HostOSName)-$(Architecture)</HostMonikerRid>
<ArtifactNameSdk>dotnet-sdk-internal</ArtifactNameSdk> <ArtifactNameSdk>dotnet-sdk-internal</ArtifactNameSdk>
<ArtifactNameSdkDebug>dotnet-sdk-debug</ArtifactNameSdkDebug> <ArtifactNameSdkSymbols>dotnet-sdk-symbols</ArtifactNameSdkSymbols>
<ArtifactNameCombinedHostHostFxrFrameworkSdk>dotnet-sdk</ArtifactNameCombinedHostHostFxrFrameworkSdk> <ArtifactNameCombinedHostHostFxrFrameworkSdk>dotnet-sdk</ArtifactNameCombinedHostHostFxrFrameworkSdk>
<ArtifactNameSdkLanguagePack>$(ArtifactNameCombinedHostHostFxrFrameworkSdk)-langpack</ArtifactNameSdkLanguagePack> <ArtifactNameSdkLanguagePack>$(ArtifactNameCombinedHostHostFxrFrameworkSdk)-langpack</ArtifactNameSdkLanguagePack>
<ArtifactNameWithVersionSdk>$(ArtifactNameSdk)-$(SdkVersion)-$(ProductMonikerRid)</ArtifactNameWithVersionSdk> <ArtifactNameWithVersionSdk>$(ArtifactNameSdk)-$(SdkVersion)-$(ProductMonikerRid)</ArtifactNameWithVersionSdk>
<ArtifactNameWithVersionMSBuildExtensions>dotnet-standard-support-vs2015-$(SdkVersion)-$(ProductMonikerRid)</ArtifactNameWithVersionMSBuildExtensions> <ArtifactNameWithVersionMSBuildExtensions>dotnet-standard-support-vs2015-$(SdkVersion)-$(ProductMonikerRid)</ArtifactNameWithVersionMSBuildExtensions>
<ArtifactNameWithVersionSdkDebug>$(ArtifactNameSdkDebug)-$(SdkVersion)-$(ProductMonikerRid)</ArtifactNameWithVersionSdkDebug> <ArtifactNameWithVersionSdkSymbols>$(ArtifactNameSdkSymbols)-$(SdkVersion)-$(ProductMonikerRid)</ArtifactNameWithVersionSdkSymbols>
<ArtifactNameWithVersionCombinedHostHostFxrFrameworkSdk>$(ArtifactNameCombinedHostHostFxrFrameworkSdk)-$(SdkVersion)-$(ProductMonikerRid)</ArtifactNameWithVersionCombinedHostHostFxrFrameworkSdk> <ArtifactNameWithVersionCombinedHostHostFxrFrameworkSdk>$(ArtifactNameCombinedHostHostFxrFrameworkSdk)-$(SdkVersion)-$(ProductMonikerRid)</ArtifactNameWithVersionCombinedHostHostFxrFrameworkSdk>
<ArtifactNameWithVersionSdkLanguagePack>$(ArtifactNameSdkLanguagePack)-$(SdkVersion)-$(ProductMonikerRid)</ArtifactNameWithVersionSdkLanguagePack> <ArtifactNameWithVersionSdkLanguagePack>$(ArtifactNameSdkLanguagePack)-$(SdkVersion)-$(ProductMonikerRid)</ArtifactNameWithVersionSdkLanguagePack>
<DistroSpecificArtifactNameWithVersionCombinedHostHostFxrFrameworkSdk>$(ArtifactNameCombinedHostHostFxrFrameworkSdk)-$(SdkVersion)-$(HostMonikerRid)</DistroSpecificArtifactNameWithVersionCombinedHostHostFxrFrameworkSdk> <DistroSpecificArtifactNameWithVersionCombinedHostHostFxrFrameworkSdk>$(ArtifactNameCombinedHostHostFxrFrameworkSdk)-$(SdkVersion)-$(HostMonikerRid)</DistroSpecificArtifactNameWithVersionCombinedHostHostFxrFrameworkSdk>

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup> <PropertyGroup>
<SdkDebugLayoutOutputDirectory>$(LayoutDirectory)/$(ArtifactNameSdkDebug)</SdkDebugLayoutOutputDirectory> <SdkSymbolsLayoutOutputDirectory>$(LayoutDirectory)/$(ArtifactNameSdkSymbols)</SdkSymbolsLayoutOutputDirectory>
<CombinedHostHostFxrFrameworkSdkOutputDirectory>$(LayoutDirectory)/$(ArtifactNameCombinedHostHostFxrFrameworkSdk)</CombinedHostHostFxrFrameworkSdkOutputDirectory> <CombinedHostHostFxrFrameworkSdkOutputDirectory>$(LayoutDirectory)/$(ArtifactNameCombinedHostHostFxrFrameworkSdk)</CombinedHostHostFxrFrameworkSdkOutputDirectory>
<SdkLanguagePackOutputDirectory>$(LayoutDirectory)/$(ArtifactNameSdkLanguagePack)</SdkLanguagePackOutputDirectory> <SdkLanguagePackOutputDirectory>$(LayoutDirectory)/$(ArtifactNameSdkLanguagePack)</SdkLanguagePackOutputDirectory>
<SatelliteAssemblies>*.resources.dll</SatelliteAssemblies> <SatelliteAssemblies>*.resources.dll</SatelliteAssemblies>
@ -12,7 +12,7 @@
<!-- Set up Items with Layout Input Files --> <!-- Set up Items with Layout Input Files -->
<ItemGroup> <ItemGroup>
<SdkLayoutInput Include="$(OutputDirectory)/sdk/**/*" /> <SdkLayoutInput Include="$(OutputDirectory)/sdk/**/*" />
<SdkDebugLayoutInput Include="$(SymbolsDirectory)/sdk/**/*" /> <SdkSymbolsLayoutInput Include="$(SymbolsDirectory)/sdk/**/*" />
<CombinedHostHostFxrFrameworkSdkInput Include="$(OutputDirectory)/**/*" /> <CombinedHostHostFxrFrameworkSdkInput Include="$(OutputDirectory)/**/*" />
<SdkLanguagePackInput Include="$(OutputDirectory)/sdk/**/$(SatelliteAssemblies)" /> <SdkLanguagePackInput Include="$(OutputDirectory)/sdk/**/$(SatelliteAssemblies)" />
@ -30,9 +30,10 @@
<Output TaskParameter="RelativePath" ItemName="SdkRelativeOutputFiles" /> <Output TaskParameter="RelativePath" ItemName="SdkRelativeOutputFiles" />
</MakeRelative> </MakeRelative>
<MakeRelative <MakeRelative
Path1="$(SymbolsDirectory)" Condition="'$(SeparateSymbolsArchive)' != 'false'"
Path2="%(SdkDebugLayoutInput.Identity)" > Path1="$(SymbolsDirectory)/"
<Output TaskParameter="RelativePath" ItemName="SdkDebugRelativeOutputFiles" /> Path2="%(SdkSymbolsLayoutInput.Identity)" >
<Output TaskParameter="RelativePath" ItemName="SdkSymbolsRelativeOutputFiles" />
</MakeRelative> </MakeRelative>
<MakeRelative <MakeRelative
Path1="$(OutputDirectory)/" Path1="$(OutputDirectory)/"
@ -70,11 +71,11 @@
<Name>$(ArtifactNameSdk)</Name> <Name>$(ArtifactNameSdk)</Name>
</LayoutDefinition> </LayoutDefinition>
<LayoutDefinition Include="Debug"> <LayoutDefinition Include="SdkSymbols" Condition="'$(SeparateSymbolsArchive)' != 'false'">
<InputFiles>@(SdkDebugLayoutInput)</InputFiles> <InputFiles>@(SdkSymbolsLayoutInput)</InputFiles>
<OutputFiles>@(SdkDebugRelativeOutputFiles -> '$(SdkDebugLayoutOutputDirectory)/%(Identity)')</OutputFiles> <OutputFiles>@(SdkSymbolsRelativeOutputFiles -> '$(SdkSymbolsLayoutOutputDirectory)/%(Identity)')</OutputFiles>
<NameWithVersion>$(ArtifactNameWithVersionSdkDebug)</NameWithVersion> <NameWithVersion>$(ArtifactNameWithVersionSdkSymbols)</NameWithVersion>
<Name>$(ArtifactNameSdkDebug)</Name> <Name>$(ArtifactNameSdkSymbols)</Name>
</LayoutDefinition> </LayoutDefinition>
<LayoutDefinition Include="CombinedHostHostFxrFrameworkSdk"> <LayoutDefinition Include="CombinedHostHostFxrFrameworkSdk">

View file

@ -3,7 +3,9 @@
// See the LICENSE file in the project root for more information. // See the LICENSE file in the project root for more information.
using System; using System;
using System.Diagnostics;
using System.IO; using System.IO;
using System.Runtime.InteropServices;
using Microsoft.Build.Framework; using Microsoft.Build.Framework;
using Microsoft.Build.Utilities; using Microsoft.Build.Utilities;
@ -22,12 +24,18 @@ namespace Microsoft.DotNet.Build.Tasks
public string CrossgenPath { get; set; } public string CrossgenPath { get; set; }
public bool CreateSymbols { get; set; }
public string DiasymReaderPath { get; set; }
public bool ReadyToRun { get; set; } public bool ReadyToRun { get; set; }
public ITaskItem[] PlatformAssemblyPaths { get; set; } public ITaskItem[] PlatformAssemblyPaths { get; set; }
private string TempOutputPath { get; set; } private string TempOutputPath { get; set; }
private bool _secondInvocationToCreateSymbols;
protected override bool ValidateParameters() protected override bool ValidateParameters()
{ {
base.ValidateParameters(); base.ValidateParameters();
@ -58,6 +66,12 @@ namespace Microsoft.DotNet.Build.Tasks
File.Delete(TempOutputPath); File.Delete(TempOutputPath);
} }
if (toolResult && CreateSymbols)
{
_secondInvocationToCreateSymbols = true;
toolResult = base.Execute();
}
return toolResult; return toolResult;
} }
@ -83,9 +97,30 @@ namespace Microsoft.DotNet.Build.Tasks
protected override string GenerateCommandLineCommands() protected override string GenerateCommandLineCommands()
{ {
if (_secondInvocationToCreateSymbols)
{
return $"{GetReadyToRun()} {GetPlatformAssemblyPaths()} {GetDiasymReaderPath()} {GetCreateSymbols()}";
}
return $"{GetReadyToRun()} {GetInPath()} {GetOutPath()} {GetPlatformAssemblyPaths()} {GetJitPath()}"; return $"{GetReadyToRun()} {GetInPath()} {GetOutPath()} {GetPlatformAssemblyPaths()} {GetJitPath()}";
} }
private string GetCreateSymbols()
{
var option = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "-createpdb" : "-createperfmap";
return $"{option} \"{Path.GetDirectoryName(DestinationPath)}\" \"{DestinationPath}\"";
}
private string GetDiasymReaderPath()
{
if (string.IsNullOrEmpty(DiasymReaderPath))
{
return null;
}
return $"-diasymreaderpath \"{DiasymReaderPath}\"";
}
private string GetReadyToRun() private string GetReadyToRun()
{ {
if (ReadyToRun) if (ReadyToRun)

View file

@ -101,7 +101,8 @@
<Delete Files="$(PublishDir)/$(TargetName).deps.json; <Delete Files="$(PublishDir)/$(TargetName).deps.json;
$(PublishDir)/$(TargetName).runtimeconfig.json; $(PublishDir)/$(TargetName).runtimeconfig.json;
$(PublishDir)/%(BundledToolProjects.Identity).dll" /> $(PublishDir)/%(BundledToolProjects.Identity).dll;
$(PublishDir)/%(BundledToolProjects.Identity).pdb" />
<ChangeEntryPointLibraryName <ChangeEntryPointLibraryName
DepsFile="$(PublishDir)/%(BundledTools.Identity).deps.json" DepsFile="$(PublishDir)/%(BundledTools.Identity).deps.json"
@ -198,7 +199,7 @@
<Target Name="CrossgenPublishDir" <Target Name="CrossgenPublishDir"
Condition=" '$(DISABLE_CROSSGEN)' == '' " Condition=" '$(DISABLE_CROSSGEN)' == '' "
AfterTargets="PublishMSBuildExtensions"> AfterTargets="GenerateCliRuntimeConfigurationFiles">
<ItemGroup> <ItemGroup>
<!-- Removing Full CLR built TestHost assemblies from getting Crossgen as it is throwing error --> <!-- Removing Full CLR built TestHost assemblies from getting Crossgen as it is throwing error -->
<SdkFiles Include="$(PublishDir)/**/*" Exclude="$(PublishDir)/TestHost*/**/*;$(PublishDir)/Sdks/**/*" /> <SdkFiles Include="$(PublishDir)/**/*" Exclude="$(PublishDir)/TestHost*/**/*;$(PublishDir)/Sdks/**/*" />
@ -208,6 +209,11 @@
<!-- Don't try to CrossGen tasks and supporting DLLs compiled for .NET Framework --> <!-- Don't try to CrossGen tasks and supporting DLLs compiled for .NET Framework -->
<SdkFiles Remove="$(PublishDir)/Microsoft\Microsoft.NET.Build.Extensions\tools\net*\**\*" /> <SdkFiles Remove="$(PublishDir)/Microsoft\Microsoft.NET.Build.Extensions\tools\net*\**\*" />
<!-- Don't crossgen satellite assemblies -->
<SdkFiles Remove="$(PublishDir)/**/*.resources.dll" />
<DiasymReaderPath Include="$(SharedFrameworkNameVersionPath)/Microsoft.DiaSymReader.Native.*.dll" />
</ItemGroup> </ItemGroup>
<AddMetadataIsPE Items="@(SdkFiles)"> <AddMetadataIsPE Items="@(SdkFiles)">
@ -227,11 +233,19 @@
Glob="$(CrossgenPath)" Glob="$(CrossgenPath)"
Mode="u+x" /> Mode="u+x" />
<!-- Crossgen does not support generating symbols on Mac -->
<PropertyGroup Condition="'$(CreateCrossgenSymbols)' == ''">
<CreateCrossgenSymbols>true</CreateCrossgenSymbols>
<CreateCrossgenSymbols Condition="'$(OSName)' == 'osx'">false</CreateCrossgenSymbols>
</PropertyGroup>
<Crossgen SourceAssembly="%(CrossgenTargets.FullPath)" <Crossgen SourceAssembly="%(CrossgenTargets.FullPath)"
DestinationPath="%(CrossgenTargets.FullPath)" DestinationPath="%(CrossgenTargets.FullPath)"
JITPath="$(LibCLRJitPath)" JITPath="$(LibCLRJitPath)"
CrossgenPath="$(CrossgenPath)" CrossgenPath="$(CrossgenPath)"
ReadyToRun="True" ReadyToRun="True"
CreateSymbols="$(CreateCrossgenSymbols)"
DiasymReaderPath="@(DiasymReaderPath)"
PlatformAssemblyPaths="@(PlatformAssemblies); PlatformAssemblyPaths="@(PlatformAssemblies);
@(PublishDirSubDirectories); @(PublishDirSubDirectories);
$(SharedFrameworkNameVersionPath)" /> $(SharedFrameworkNameVersionPath)" />
@ -248,23 +262,16 @@
<Chmod Mode="755" Glob="$(SdkOutputDirectory)/FSharp/RunFsc.sh" /> <Chmod Mode="755" Glob="$(SdkOutputDirectory)/FSharp/RunFsc.sh" />
</Target> </Target>
<Target Name="CreateSymbolsDirectory" <Target Name="SeparateSymbolsFromPublishDir"
AfterTargets="CrossgenPublishDir"> AfterTargets="CrossgenPublishDir"
Condition="'$(SeparateSymbolsArchive)' != 'false'">
<ItemGroup> <ItemGroup>
<_AllSdkFiles Include="$(PublishDir)/**/*" /> <PdbsToMove Include="$(PublishDir)/**/*.pdb" />
<PdbsToMove Include="$(PublishDir)/**/*.ni.*.map" />
</ItemGroup> </ItemGroup>
<Copy SourceFiles="@(_AllSdkFiles)" <Move SourceFiles="@(PdbsToMove)"
DestinationFiles="@(_AllSdkFiles->'$(SymbolsDirectory)/sdk/%(RecursiveDir)%(Filename)%(Extension)')" /> DestinationFiles="@(PdbsToMove->'$(SymbolsDirectory)/sdk/$(SdkVersion)/%(RecursiveDir)%(Filename)%(Extension)')" />
</Target>
<Target Name="RemovePdbsFromPublishDir"
AfterTargets="CreateSymbolsDirectory">
<ItemGroup>
<PdbsToClean Include="$(PublishDir)/**/*.pdb" />
</ItemGroup>
<Delete Files="@(PdbsToClean)" />
</Target> </Target>
<Target Name="PublishStage2WithBackwardsCompatibleRuntimes" <Target Name="PublishStage2WithBackwardsCompatibleRuntimes"
@ -285,6 +292,7 @@
</Target> </Target>
<Target Name="RetargetVSTestConsole" <Target Name="RetargetVSTestConsole"
BeforeTargets="PublishStage2WithBackwardsCompatibleRuntimes"
AfterTargets="Publish"> AfterTargets="Publish">
<PropertyGroup> <PropertyGroup>
<VSTestRuntimeConfigPath>$(PublishDir)/vstest.console.runtimeconfig.json</VSTestRuntimeConfigPath> <VSTestRuntimeConfigPath>$(PublishDir)/vstest.console.runtimeconfig.json</VSTestRuntimeConfigPath>