-
Notifications
You must be signed in to change notification settings - Fork 4.8k
/
crossgen-corelib.proj
157 lines (125 loc) · 7.88 KB
/
crossgen-corelib.proj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<Project Sdk="Microsoft.Build.NoTargets">
<ItemGroup>
<ProjectReference Include="$(CoreClrProjectRoot)/tools/aot/crossgen2/crossgen2_inbuild.csproj" OutputItemType="Crossgen2" />
<ProjectReference Include="$(CoreClrProjectRoot)/tools/dotnet-pgo/dotnet-pgo.csproj" OutputItemType="DotNetPgo" Condition="'$(DotNetBuildSourceOnly)' != 'true'" />
<ProjectReference Include="$([MSBuild]::NormalizePath('$(CoreClrProjectRoot)', 'System.Private.CoreLib', 'System.Private.CoreLib.csproj'))" OutputItemType="CoreLib" />
</ItemGroup>
<PropertyGroup>
<OSPlatformConfig>$(TargetOS).$(TargetArchitecture).$(Configuration)</OSPlatformConfig>
<RootBinDir>$([MSBuild]::NormalizeDirectory('$(RepoRoot)', 'artifacts'))</RootBinDir>
<LogsDir>$([MSBuild]::NormalizeDirectory('$(RootBinDir)', 'log'))</LogsDir>
<BinDir>$([MSBuild]::NormalizeDirectory('$(RootBinDir)', 'bin', 'coreclr', $(OSPlatformConfig)))</BinDir>
<IntermediatesDir>$([MSBuild]::NormalizeDirectory('$(RootBinDir)', 'obj', 'coreclr', $(OSPlatformConfig)))</IntermediatesDir>
<DotNetCli>$([MSBuild]::NormalizePath('$(RepoRoot)', 'dotnet.sh'))</DotNetCli>
<DotNetCli Condition="'$(OS)' == 'Windows_NT'">$([MSBuild]::NormalizePath('$(RepoRoot)', 'dotnet.cmd'))</DotNetCli>
</PropertyGroup>
<PropertyGroup>
<BuildDll>true</BuildDll>
<BuildDll Condition="'$(TargetOS)' == 'netbsd' or '$(TargetOS)' == 'illumos' or '$(TargetOS)' == 'solaris' or '$(TargetOS)' == 'haiku'">false</BuildDll>
<BuildPdb>false</BuildPdb>
<BuildPdb Condition="$(BuildDll) and '$(OS)' == 'Windows_NT' and '$(TargetOS)' == 'windows'">true</BuildPdb>
<BuildPerfMap>false</BuildPerfMap>
<BuildPerfMap Condition="$(BuildDll) and '$(TargetOS)' == 'linux'">true</BuildPerfMap>
<_MergeMibcFilesCacheFile>$(MibcOptimizationDataDir)/$(TargetOS)/$(TargetArchitecture)/merge_mibc_files.cache</_MergeMibcFilesCacheFile>
</PropertyGroup>
<ItemGroup>
<OptimizationMibcFiles Include="$(MibcOptimizationDataDir)/$(TargetOS)/$(TargetArchitecture)/**/*.mibc" />
</ItemGroup>
<PropertyGroup>
<CoreLibAssemblyName>System.Private.CoreLib</CoreLibAssemblyName>
<CoreLibOutputPath>$([MSBuild]::NormalizePath('$(BinDir)', '$(CoreLibAssemblyName).dll'))</CoreLibOutputPath>
<CoreLibNiPdbPath></CoreLibNiPdbPath>
<CoreLibPerfMapPath></CoreLibPerfMapPath>
<CoreLibNiPdbPath Condition="$(BuildPdb)">$([MSBuild]::NormalizePath('$(BinDir)', 'PDB', '$(CoreLibAssemblyName).ni.pdb'))</CoreLibNiPdbPath>
<CoreLibPerfMapPath Condition="$(BuildPerfMap)">$([MSBuild]::NormalizePath('$(BinDir)', '$(CoreLibAssemblyName).ni.r2rmap'))</CoreLibPerfMapPath>
<MergedMibcPath>$([MSBuild]::NormalizePath('$(BinDir)', 'StandardOptimizationData.mibc'))</MergedMibcPath>
</PropertyGroup>
<!-- Creates a hash file that changes whenever the input mibc file modification times change.
This will trigger a re-merge when updating to a new version of the optimization data,
even if the new timestamps are still days in the past. -->
<Target Name="GenerateMergeMibcFilesInputCache">
<ItemGroup>
<_MergeMibcFilesInputCache Include="@(OptimizationMibcFiles)" />
<_MergeMibcFilesInputCache Include="@(DotNetPgo)" />
<_MergeMibcFilesInputCache Include="@(OptimizationMibcFiles->'%(ModifiedTime)')" />
</ItemGroup>
<Hash ItemsToHash="@(_MergeMibcFilesInputCache)">
<Output TaskParameter="HashResult" PropertyName="_MergeMibcFilesInputCacheHash" />
</Hash>
<WriteLinesToFile
Lines="$(_MergeMibcFilesInputCacheHash)"
File="$(_MergeMibcFilesCacheFile)"
Overwrite="true"
WriteOnlyWhenDifferent="true" />
<ItemGroup>
<FileWrites Include="$(_MergeMibcFilesCacheFile)" />
</ItemGroup>
</Target>
<Target Name="MergeMibcFiles"
DependsOnTargets="GenerateMergeMibcFilesInputCache"
Inputs="$(_MergeMibcFilesCacheFile);@(OptimizationMibcFiles);@(DotNetPgo)"
Condition="'@(DotNetPgo)' != ''"
Outputs="$(MergedMibcPath)">
<PropertyGroup>
<DotNetPgoCmd>$(DotNetCli) @(DotNetPgo) merge</DotNetPgoCmd>
<DotNetPgoCmd>$(DotNetPgoCmd) -o:$(MergedMibcPath)</DotNetPgoCmd>
<DotNetPgoCmd>$(DotNetPgoCmd) @(OptimizationMibcFiles->'-i:%(Identity)', ' ')</DotNetPgoCmd>
<DotNetPgoCmd>$(DotNetPgoCmd) --compressed false</DotNetPgoCmd> <!-- Signing service doesn't handle compressed mibc signing correctly. -->
</PropertyGroup>
<Message Importance="High" Text="$(DotNetPgoCmd)"/>
<Exec Command="$(DotNetPgoCmd)" />
</Target>
<Target Name="CreateMergedMibcFile"
DependsOnTargets="ResolveProjectReferences;MergeMibcFiles" />
<Target Name="PrepareInvokeCrossgen" DependsOnTargets="ResolveProjectReferences;CreateMergedMibcFile">
<ItemGroup>
<Crossgen2Inputs Include="@(CoreLib)" />
<Crossgen2Inputs Include="$(MergedMibcPath)" />
</ItemGroup>
<PropertyGroup>
<Crossgen2OutputPath>%(Crossgen2.RootDir)/%(Crossgen2.Directory)</Crossgen2OutputPath>
</PropertyGroup>
<ItemGroup>
<Crossgen2Files Include="$(Crossgen2OutputPath)/*.dll" />
<Crossgen2Files Include="$(Crossgen2OutputPath)/*.so" />
<Crossgen2Files Include="$(Crossgen2OutputPath)/*.dylib" />
</ItemGroup>
</Target>
<Target Name="InvokeCrossgen"
DependsOnTargets="PrepareInvokeCrossgen;CreateMergedMibcFile"
Inputs="@(Crossgen2Inputs);@(Crossgen2Files)"
Outputs="$(CoreLibOutputPath);$(CoreLibNiPdbPath);$(CoreLibPerfMapPath)"
AfterTargets="Build">
<MakeDir
Directories="$(BinDir);$(IntermediatesDir);$(LogsDir)" />
<Message Importance="High"
Text="Generating native image of System.Private.CoreLib for $(OSPlatformConfig). Logging to $(CrossGenCoreLibLog)" />
<PropertyGroup>
<CrossGenDllCmd>$(DotNetCli) @(Crossgen2)</CrossGenDllCmd>
<CrossGenDllCmd>$(CrossGenDllCmd) -o:$(CoreLibOutputPath)</CrossGenDllCmd>
<CrossGenDllCmd>$(CrossGenDllCmd) -r:$([MSBuild]::NormalizePath('$(BinDir)', 'IL', '*.dll'))</CrossGenDllCmd>
<CrossGenDllCmd>$(CrossGenDllCmd) --targetarch:$(TargetArchitecture)</CrossGenDllCmd>
<CrossGenDllCmd>$(CrossGenDllCmd) --targetos:$(TargetOS)</CrossGenDllCmd>
<CrossGenDllCmd Condition="'$(UsingToolIbcOptimization)' != 'true' and '$(EnableNgenOptimization)' == 'true'">$(CrossGenDllCmd) -m:$(MergedMibcPath) --embed-pgo-data</CrossGenDllCmd>
<CrossGenDllCmd>$(CrossGenDllCmd) -O</CrossGenDllCmd>
<CrossGenDllCmd Condition="'$(Configuration)' == 'Debug' or '$(Configuration)' == 'Checked'">$(CrossGenDllCmd) --verify-type-and-field-layout</CrossGenDllCmd>
<CrossGenDllCmd>$(CrossGenDllCmd) @(CoreLib)</CrossGenDllCmd>
</PropertyGroup>
<PropertyGroup Condition="$(BuildPdb)">
<CrossGenDllCmd>$(CrossGenDllCmd) --pdb --pdb-path:$([MSBuild]::NormalizePath('$(BinDir)', 'PDB'))</CrossGenDllCmd>
</PropertyGroup>
<PropertyGroup Condition="$(BuildPerfMap)">
<CrossGenDllCmd>$(CrossGenDllCmd) --perfmap-format-version:1</CrossGenDllCmd>
<CrossGenDllCmd>$(CrossGenDllCmd) --perfmap --perfmap-path:$(BinDir)</CrossGenDllCmd>
</PropertyGroup>
<Message Condition="$(BuildDll)" Importance="High" Text="$(CrossGenDllCmd)" />
<Exec Condition="$(BuildDll)" Command="$(CrossGenDllCmd)" />
<Message Condition="$(BuildPdb)" Importance="High" Text="$(CrossGenPdbCmd)" />
<Exec Condition="$(BuildPdb) and '$(CrossGenPdbCmd)' != ''" Command="$(CrossGenPdbCmd)" />
<Message Condition="$(BuildPerfMap)" Importance="High" Text="$(CrossGenPerfMapCmd)" />
<Exec Condition="$(BuildPerfMap) and '$(CrossGenPerfMapCmd)' != ''" Command="$(CrossGenPerfMapCmd)" />
<Copy Condition="!$(BuildDll)" SourceFiles="@(CoreLib)" DestinationFiles="$(CoreLibOutputPath)" UseHardlinksIfPossible="true" />
<Message Importance="High" Text="Crossgenning of System.Private.CoreLib succeeded." />
<Message Importance="High" Text="Product binaries are available at $(BinDir)" />
</Target>
</Project>