|
17 | 17 | </PropertyGroup> |
18 | 18 |
|
19 | 19 | <PropertyGroup> |
20 | | - <BuildDll>true</BuildDll> |
21 | | - <BuildDll Condition="'$(TargetOS)' == 'netbsd' or '$(TargetOS)' == 'illumos' or '$(TargetOS)' == 'solaris' or '$(TargetOS)' == 'haiku'">false</BuildDll> |
| 20 | + <CrossgenTargetName>InvokeCrossgen2</CrossgenTargetName> |
| 21 | + |
| 22 | + <PublishReadyToRun>true</PublishReadyToRun> |
| 23 | + <!-- Disable crossgen on NetBSD, illumos, Solaris and Haiku for now. This can be revisited when we have full support. --> |
| 24 | + <PublishReadyToRun Condition="'$(TargetOS)' == 'netbsd' or '$(TargetOS)' == 'illumos' or '$(TargetOS)' == 'solaris' or '$(TargetOS)' == 'haiku'">false</PublishReadyToRun> |
| 25 | + <!-- TODO-WASM: we will have WASM R2R after https://github.com/dotnet/runtime/issues/121257 --> |
| 26 | + <PublishReadyToRun Condition="'$(TargetOS)' == 'browser' or '$(TargetOS)' == 'wasi'">false</PublishReadyToRun> |
| 27 | + |
| 28 | + <CrossgenTargetName Condition="!$(PublishReadyToRun)">CopyILCoreLib</CrossgenTargetName> |
22 | 29 |
|
23 | 30 | <BuildPdb>false</BuildPdb> |
24 | | - <BuildPdb Condition="$(BuildDll) and '$(OS)' == 'Windows_NT' and '$(TargetOS)' == 'windows'">true</BuildPdb> |
| 31 | + <BuildPdb Condition="'$(OS)' == 'Windows_NT' and '$(TargetOS)' == 'windows'">true</BuildPdb> |
25 | 32 |
|
26 | 33 | <BuildPerfMap>false</BuildPerfMap> |
27 | | - <BuildPerfMap Condition="$(BuildDll) and '$(TargetOS)' == 'linux'">true</BuildPerfMap> |
| 34 | + <BuildPerfMap Condition="'$(TargetOS)' == 'linux'">true</BuildPerfMap> |
28 | 35 |
|
29 | 36 | <_MergeMibcFilesCacheFile>$(MibcOptimizationDataDir)/$(TargetOS)/$(TargetArchitecture)/merge_mibc_files.cache</_MergeMibcFilesCacheFile> |
30 | 37 | </PropertyGroup> |
31 | 38 |
|
| 39 | + <PropertyGroup Condition="'$(TargetsAppleMobile)' == 'true' and $(PublishReadyToRun)"> |
| 40 | + <PublishReadyToRunContainerFormat>macho</PublishReadyToRunContainerFormat> |
| 41 | + <UseComposite>true</UseComposite> |
| 42 | + <CrossgenTargetName>$(CrossgenTargetName);LinkCoreLibMachO</CrossgenTargetName> |
| 43 | + </PropertyGroup> |
| 44 | + |
| 45 | + <PropertyGroup Condition="'$(UseComposite)' == 'true'"> |
| 46 | + <CrossgenTargetName>$(CrossgenTargetName);CopyR2RComponentCoreLib</CrossgenTargetName> |
| 47 | + </PropertyGroup> |
| 48 | + |
32 | 49 | <ItemGroup> |
33 | 50 | <OptimizationMibcFiles Include="$(MibcOptimizationDataDir)/$(TargetOS)/$(TargetArchitecture)/**/*.mibc" /> |
34 | 51 | </ItemGroup> |
35 | 52 |
|
36 | 53 | <PropertyGroup> |
37 | 54 | <CoreLibAssemblyName>System.Private.CoreLib</CoreLibAssemblyName> |
38 | 55 | <CoreLibOutputPath>$([MSBuild]::NormalizePath('$(BinDir)', '$(CoreLibAssemblyName).dll'))</CoreLibOutputPath> |
| 56 | + <CrossgenCoreLibOutputPath>$(CoreLibOutputPath)</CrossgenCoreLibOutputPath> |
| 57 | + <CrossgenCoreLibComponentOutputPath></CrossgenCoreLibComponentOutputPath> |
39 | 58 | <CoreLibNiPdbPath></CoreLibNiPdbPath> |
40 | 59 | <CoreLibPerfMapPath></CoreLibPerfMapPath> |
41 | 60 | <CoreLibNiPdbPath Condition="$(BuildPdb)">$([MSBuild]::NormalizePath('$(BinDir)', 'PDB', '$(CoreLibAssemblyName).ni.pdb'))</CoreLibNiPdbPath> |
42 | 61 | <CoreLibPerfMapPath Condition="$(BuildPerfMap)">$([MSBuild]::NormalizePath('$(BinDir)', '$(CoreLibAssemblyName).ni.r2rmap'))</CoreLibPerfMapPath> |
43 | 62 | <MergedMibcPath>$([MSBuild]::NormalizePath('$(BinDir)', 'StandardOptimizationData.mibc'))</MergedMibcPath> |
44 | 63 | </PropertyGroup> |
45 | 64 |
|
| 65 | + <PropertyGroup Condition="'$(PublishReadyToRunContainerFormat)' == 'macho'"> |
| 66 | + <CoreLibObjOutputPath>$([MSBuild]::NormalizePath('$(IntermediateOutputPath)', '$(CoreLibAssemblyName).o'))</CoreLibObjOutputPath> |
| 67 | + <CrossgenCoreLibOutputPath>$(CoreLibObjOutputPath)</CrossgenCoreLibOutputPath> |
| 68 | + <CoreLibDylibOutputPath>$([MSBuild]::NormalizePath('$(BinDir)', '$(CoreLibAssemblyName).dylib'))</CoreLibDylibOutputPath> |
| 69 | + </PropertyGroup> |
| 70 | + |
| 71 | + <PropertyGroup Condition="'$(UseComposite)' == 'true'"> |
| 72 | + <CrossgenCoreLibComponentOutputPath>$([MSBuild]::NormalizePath('$(IntermediateOutputPath)', '$(CoreLibAssemblyName).dll'))</CrossgenCoreLibComponentOutputPath> |
| 73 | + </PropertyGroup> |
| 74 | + |
46 | 75 | <!-- Creates a hash file that changes whenever the input mibc file modification times change. |
47 | 76 | This will trigger a re-merge when updating to a new version of the optimization data, |
48 | 77 | even if the new timestamps are still days in the past. --> |
|
88 | 117 | <Target Name="CreateMergedMibcFile" |
89 | 118 | DependsOnTargets="ResolveProjectReferences;MergeMibcFiles" /> |
90 | 119 |
|
91 | | - <Target Name="PrepareInvokeCrossgen" DependsOnTargets="ResolveProjectReferences;CreateMergedMibcFile"> |
| 120 | + <Target Name="PrepareInvokeCrossgen2" DependsOnTargets="ResolveProjectReferences;CreateMergedMibcFile"> |
92 | 121 | <ItemGroup> |
93 | 122 | <Crossgen2Inputs Include="@(CoreLib)" /> |
94 | 123 | <Crossgen2Inputs Include="$(MergedMibcPath)" /> |
95 | 124 | <Crossgen2Inputs Include="@(Crossgen2Files->Metadata('OutputPath'))" /> |
96 | 125 | </ItemGroup> |
97 | 126 | </Target> |
98 | 127 |
|
99 | | - <Target Name="InvokeCrossgenBrowser" |
100 | | - DependsOnTargets="PrepareInvokeCrossgen" |
101 | | - Inputs="@(Crossgen2Inputs)" |
102 | | - Outputs="$(CoreLibOutputPath)" |
103 | | - Condition="'$(TargetOS)' == 'browser'" |
104 | | - AfterTargets="Build"> |
105 | | - <!-- TODO-WASM: we will have WASM R2R later, for now we just need to copy the file into expected location --> |
| 128 | + <Target Name="CopyILCoreLib" |
| 129 | + DependsOnTargets="ResolveProjectReferences" |
| 130 | + Inputs="@(CoreLib)" |
| 131 | + Outputs="$(CoreLibOutputPath)"> |
106 | 132 | <Copy SourceFiles="@(CoreLib)" DestinationFiles="$(CoreLibOutputPath)" UseHardlinksIfPossible="true" /> |
107 | 133 | </Target> |
108 | 134 |
|
109 | | - <Target Name="InvokeCrossgen" |
110 | | - DependsOnTargets="PrepareInvokeCrossgen;CreateMergedMibcFile" |
| 135 | + <Target Name="InvokeCrossgen2" |
| 136 | + DependsOnTargets="PrepareInvokeCrossgen2;CreateMergedMibcFile" |
111 | 137 | Inputs="@(Crossgen2Inputs)" |
112 | | - Outputs="$(CoreLibOutputPath);$(CoreLibNiPdbPath);$(CoreLibPerfMapPath)" |
113 | | - Condition="'$(TargetOS)' != 'browser'" |
114 | | - AfterTargets="Build"> |
| 138 | + Outputs="$(CoreLibOutputPath);$(CoreLibNiPdbPath);$(CoreLibPerfMapPath);$(CrossgenCoreLibOutputPath);$(CrossgenCoreLibComponentOutputPath)"> |
115 | 139 |
|
116 | 140 | <MakeDir |
117 | 141 | Directories="$(BinDir);$(IntermediatesDir);$(LogsDir)" /> |
|
121 | 145 |
|
122 | 146 | <PropertyGroup> |
123 | 147 | <CrossGenDllCmd>@(Crossgen2Files->Metadata('OutputPath')->WithMetadataValue('Filename','crossgen2')->WithMetadataValue('Extension','$(ExeSuffix)'))</CrossGenDllCmd> |
124 | | - <CrossGenDllCmd>$(CrossGenDllCmd) -o:$(CoreLibOutputPath)</CrossGenDllCmd> |
| 148 | + <CrossGenDllCmd>$(CrossGenDllCmd) -o:$(CrossgenCoreLibOutputPath)</CrossGenDllCmd> |
125 | 149 | <CrossGenDllCmd>$(CrossGenDllCmd) -r:$([MSBuild]::NormalizePath('$(BinDir)', 'IL', '*.dll'))</CrossGenDllCmd> |
126 | 150 | <CrossGenDllCmd>$(CrossGenDllCmd) --targetarch:$(TargetArchitecture)</CrossGenDllCmd> |
| 151 | + <CrossGenDllCmd Condition="'$(PublishReadyToRunContainerFormat)' != ''">$(CrossGenDllCmd) --obj-format:$(PublishReadyToRunContainerFormat)</CrossGenDllCmd> |
| 152 | + <CrossGenDllCmd Condition="'$(UseComposite)' == 'true'">$(CrossGenDllCmd) --composite</CrossGenDllCmd> |
127 | 153 | <CrossGenDllCmd Condition="'$(TargetsAndroid)' != 'true'">$(CrossGenDllCmd) --targetos:$(TargetOS)</CrossGenDllCmd> |
128 | 154 | <!-- Unless and until Android requires R2R specific customizations, we're just dealing with another linux --> |
129 | 155 | <CrossGenDllCmd Condition="'$(TargetsAndroid)' == 'true'">$(CrossGenDllCmd) --targetos:linux</CrossGenDllCmd> |
|
145 | 171 | <CrossGenDllCmd>$(CrossGenDllCmd) --perfmap --perfmap-path:$(BinDir)</CrossGenDllCmd> |
146 | 172 | </PropertyGroup> |
147 | 173 |
|
148 | | - <Message Condition="$(BuildDll)" Importance="High" Text="$(CrossGenDllCmd)" /> |
| 174 | + <Message Importance="High" Text="$(CrossGenDllCmd)" /> |
149 | 175 |
|
150 | | - <Exec Condition="$(BuildDll)" Command="$(CrossGenDllCmd)" /> |
| 176 | + <Exec Command="$(CrossGenDllCmd)" /> |
151 | 177 |
|
152 | | - <Message Condition="$(BuildPdb)" Importance="High" Text="$(CrossGenPdbCmd)" /> |
| 178 | + <Message Importance="High" Text="Crossgenning of System.Private.CoreLib succeeded." /> |
| 179 | + <Message Importance="High" Text="Product binaries are available at $(BinDir)" /> |
| 180 | + </Target> |
153 | 181 |
|
154 | | - <Exec Condition="$(BuildPdb) and '$(CrossGenPdbCmd)' != ''" Command="$(CrossGenPdbCmd)" /> |
| 182 | + <Target Name="CopyR2RComponentCoreLib" |
| 183 | + DependsOnTargets="InvokeCrossgen2" |
| 184 | + Inputs="$(CrossgenCoreLibComponentOutputPath)" |
| 185 | + Outputs="$(CoreLibOutputPath)"> |
| 186 | + <Copy SourceFiles="$(CrossgenCoreLibComponentOutputPath)" DestinationFiles="$(CoreLibOutputPath)" UseHardlinksIfPossible="true" /> |
| 187 | + </Target> |
155 | 188 |
|
156 | | - <Message Condition="$(BuildPerfMap)" Importance="High" Text="$(CrossGenPerfMapCmd)" /> |
| 189 | + <Target |
| 190 | + Name="LinkCoreLibMachO" |
| 191 | + Inputs="$(CoreLibObjOutputPath)" |
| 192 | + Outputs="$(CoreLibDylibOutputPath)"> |
| 193 | + <PropertyGroup> |
| 194 | + <_AppleTargetArchitecture Condition="'$(TargetArchitecture)' == 'x64'">x86_64</_AppleTargetArchitecture> |
| 195 | + <_AppleTargetArchitecture Condition="'$(TargetArchitecture)' == 'arm64'">arm64</_AppleTargetArchitecture> |
| 196 | + </PropertyGroup> |
157 | 197 |
|
158 | | - <Exec Condition="$(BuildPerfMap) and '$(CrossGenPerfMapCmd)' != ''" Command="$(CrossGenPerfMapCmd)" /> |
| 198 | + <PropertyGroup> |
| 199 | + <AppleMinOSVersion Condition="'$(AppleMinOSVersion)' == '' and '$(TargetOS)' == 'osx'">12.0</AppleMinOSVersion> |
| 200 | + <AppleMinOSVersion Condition="'$(AppleMinOSVersion)' == '' and '$(TargetOS)' == 'maccatalyst'">15.0</AppleMinOSVersion> |
| 201 | + <AppleMinOSVersion Condition="'$(AppleMinOSVersion)' == '' and ($(TargetOS.StartsWith('ios')) or $(TargetOS.StartsWith('tvos')))">12.2</AppleMinOSVersion> |
| 202 | + |
| 203 | + <_AppleSdkName Condition="'$(TargetOS)' == 'ios'">iphoneos</_AppleSdkName> |
| 204 | + <_AppleSdkName Condition="'$(TargetOS)' == 'iossimulator'">iphonesimulator</_AppleSdkName> |
| 205 | + <_AppleSdkName Condition="'$(TargetOS)' == 'tvos'">appletvos</_AppleSdkName> |
| 206 | + <_AppleSdkName Condition="'$(TargetOS)' == 'tvossimulator'">appletvsimulator</_AppleSdkName> |
| 207 | + <_AppleSdkName Condition="'$(TargetOS)' == 'maccatalyst' or '$(TargetOS)' == 'osx'">macosx</_AppleSdkName> |
| 208 | + |
| 209 | + <_AppleTripleOS Condition="'$(TargetOS)' == 'osx'">macos</_AppleTripleOS> |
| 210 | + <_AppleTripleOS Condition="'$(TargetOS)' == 'maccatalyst' or $(TargetOS.StartsWith('ios'))">ios</_AppleTripleOS> |
| 211 | + <_AppleTripleOS Condition="$(TargetOS.StartsWith('tvos'))">tvos</_AppleTripleOS> |
| 212 | + |
| 213 | + <_AppleTripleAbi Condition="'$(TargetOS)' == 'ios' or '$(TargetOS)' == 'tvos'">macho</_AppleTripleAbi> |
| 214 | + <_AppleTripleAbi Condition="'$(TargetOS)' == 'maccatalyst'">macabi</_AppleTripleAbi> |
| 215 | + <_AppleTripleAbi Condition="$(TargetOS.EndsWith('simulator'))">simulator</_AppleTripleAbi> |
| 216 | + |
| 217 | + <TargetTriple Condition="'$(_AppleTripleAbi)' == ''">$(_AppleTargetArchitecture)-apple-$(_AppleTripleOS)$(AppleMinOSVersion)</TargetTriple> |
| 218 | + <TargetTriple Condition="'$(_AppleTripleAbi)' != ''">$(_AppleTargetArchitecture)-apple-$(_AppleTripleOS)$(AppleMinOSVersion)-$(_AppleTripleAbi)</TargetTriple> |
| 219 | + </PropertyGroup> |
159 | 220 |
|
160 | | - <Copy Condition="!$(BuildDll)" SourceFiles="@(CoreLib)" DestinationFiles="$(CoreLibOutputPath)" UseHardlinksIfPossible="true" /> |
| 221 | + <PropertyGroup> |
| 222 | + <Xcrun Condition="'$(Xcrun)' == ''">xcrun</Xcrun> |
| 223 | + <_WhereXcrun>0</_WhereXcrun> |
| 224 | + </PropertyGroup> |
161 | 225 |
|
162 | | - <Message Importance="High" Text="Crossgenning of System.Private.CoreLib succeeded." /> |
163 | | - <Message Importance="High" Text="Product binaries are available at $(BinDir)" /> |
| 226 | + <Exec Command="command -v "$(Xcrun)"" IgnoreExitCode="true" StandardOutputImportance="Low"> |
| 227 | + <Output TaskParameter="ExitCode" PropertyName="_WhereXcrun" /> |
| 228 | + </Exec> |
| 229 | + <Error Condition="'$(_WhereXcrun)' != '0'" |
| 230 | + Text="'$(Xcrun)' not found in PATH. Make sure '$(Xcrun)' is available in PATH." /> |
| 231 | + |
| 232 | + <Exec Command=""$(Xcrun)" --sdk $(_AppleSdkName) --show-sdk-path" IgnoreExitCode="true" StandardOutputImportance="Low" ConsoleToMsBuild="true"> |
| 233 | + <Output TaskParameter="ConsoleOutput" PropertyName="SysRoot" /> |
| 234 | + </Exec> |
| 235 | + |
| 236 | + <Error Condition="!Exists('$(SysRoot)')" |
| 237 | + Text="Apple SDK was not found in: '$(SysRoot)'" /> |
| 238 | + |
| 239 | + <Exec Command=""$(Xcrun)" --sdk $(_AppleSdkName) --find clang" IgnoreExitCode="true" StandardOutputImportance="Low" ConsoleToMsBuild="true"> |
| 240 | + <Output TaskParameter="ConsoleOutput" PropertyName="_AppleClang" /> |
| 241 | + </Exec> |
| 242 | + |
| 243 | + <Error Condition="!Exists('$(_AppleClang)')" |
| 244 | + Text="Apple Clang was not found at: '$(_AppleClang)'" /> |
| 245 | + |
| 246 | + <ItemGroup> |
| 247 | + <_MachLinkerArg Include="-gz=zlib" /> |
| 248 | + <_MachLinkerArg Include="-isysroot "$(SysRoot)"" /> |
| 249 | + <_MachLinkerArg Include="--target=$(TargetTriple)" /> |
| 250 | + <_MachLinkerArg Include="-g" /> |
| 251 | + <_MachLinkerArg Include="-dynamiclib" /> |
| 252 | + <_MachLinkerArg Include="-Wl,-dead_strip" /> |
| 253 | + </ItemGroup> |
| 254 | + |
| 255 | + <Exec Command=""$(_AppleClang)" --version" IgnoreExitCode="true" StandardOutputImportance="Low" IgnoreStandardErrorWarningFormat="true" ConsoleToMSBuild="true"> |
| 256 | + <Output TaskParameter="ExitCode" PropertyName="_XcodeVersionStringExitCode" /> |
| 257 | + <Output TaskParameter="ConsoleOutput" PropertyName="_XcodeVersionString" /> |
| 258 | + </Exec> |
| 259 | + |
| 260 | + <PropertyGroup Condition="('$(_XcodeVersionStringExitCode)' == '0' or '$(_XcodeVersionStringExitCode)' == '1') and '$(_XcodeVersionString)' != ''"> |
| 261 | + <_XcodeVersion>$([System.Text.RegularExpressions.Regex]::Match($(_XcodeVersionString), '[1-9]\d*'))</_XcodeVersion> |
| 262 | + </PropertyGroup> |
| 263 | + |
| 264 | + <ItemGroup Condition="'$(UseLdClassicXCodeLinker)' != 'false'"> |
| 265 | + <_MachLinkerArg Condition="'$(UseLdClassicXCodeLinker)' == 'true' or '$(_XcodeVersion)' == '15' or '$(_XcodeVersion)' == '16'" Include="-ld_classic" /> |
| 266 | + </ItemGroup> |
| 267 | + |
| 268 | + <PropertyGroup Condition="'$(UseLdClassicXCodeLinker)' != 'false'"> |
| 269 | + <!-- Xcode 16 warns on -ld_classic --> |
| 270 | + <_IgnoreLinkerWarnings Condition="'$(_XcodeVersion)' == '16'">true</_IgnoreLinkerWarnings> |
| 271 | + </PropertyGroup> |
| 272 | + |
| 273 | + <ItemGroup> |
| 274 | + <_MachLinkerArg Include="-Wl,-install_name,"@rpath/$(CoreLibAssemblyName).dylib"" /> |
| 275 | + <_MachLinkerArg Include="$(CoreLibObjOutputPath)" /> |
| 276 | + <_MachLinkerArg Include="-o $(CoreLibDylibOutputPath)" /> |
| 277 | + </ItemGroup> |
| 278 | + |
| 279 | + <MakeDir Directories="$([System.IO.Path]::GetDirectoryName($(CoreLibDylibOutputPath)))" /> |
| 280 | + |
| 281 | + <Exec Command=""$(_AppleClang)" @(_MachLinkerArg, ' ')" |
| 282 | + IgnoreStandardErrorWarningFormat="$(_IgnoreLinkerWarnings)"/> |
| 283 | + |
| 284 | + <!-- remove executable flag --> |
| 285 | + <Exec Command="chmod 644 "$(CoreLibDylibOutputPath)"" /> |
164 | 286 | </Target> |
| 287 | + |
| 288 | + <Target Name="CrossgenCoreLib" DependsOnTargets="$(CrossgenTargetName)" AfterTargets="CoreBuild" /> |
165 | 289 | </Project> |
0 commit comments