-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Add support for emitting Mach-O R2R images #121186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
d42ffff
e986264
e43818f
573526b
0e87b5c
979fa8a
82c25a4
9db182f
9a08c72
3283658
c612d9b
a2d5718
986d789
9d04b33
107c2b4
5330a80
db6e7ee
ca02521
0ac0c61
114058d
6b7059b
25fdc84
304bb60
18f9803
1c73ef7
8a5c3cf
c7205a7
4c4d414
aa03236
908b86b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unrelated to this PR? |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -17,32 +17,61 @@ | |||||||||
| </PropertyGroup> | ||||||||||
|
|
||||||||||
| <PropertyGroup> | ||||||||||
| <BuildDll>true</BuildDll> | ||||||||||
| <BuildDll Condition="'$(TargetOS)' == 'netbsd' or '$(TargetOS)' == 'illumos' or '$(TargetOS)' == 'solaris' or '$(TargetOS)' == 'haiku'">false</BuildDll> | ||||||||||
| <CrossgenTargetName>InvokeCrossgen2</CrossgenTargetName> | ||||||||||
|
|
||||||||||
| <PublishReadyToRun>true</PublishReadyToRun> | ||||||||||
| <!-- Disable crossgen on NetBSD, illumos, Solaris and Haiku for now. This can be revisited when we have full support. --> | ||||||||||
| <PublishReadyToRun Condition="'$(TargetOS)' == 'netbsd' or '$(TargetOS)' == 'illumos' or '$(TargetOS)' == 'solaris' or '$(TargetOS)' == 'haiku'">false</PublishReadyToRun> | ||||||||||
| <!-- TODO-WASM: we will have WASM R2R after https://github.com/dotnet/runtime/issues/121257 --> | ||||||||||
| <PublishReadyToRun Condition="'$(TargetOS)' == 'browser' or '$(TargetOS)' == 'wasi'">false</PublishReadyToRun> | ||||||||||
|
|
||||||||||
| <CrossgenTargetName Condition="!$(PublishReadyToRun)">CopyILCoreLib</CrossgenTargetName> | ||||||||||
|
|
||||||||||
| <BuildPdb>false</BuildPdb> | ||||||||||
| <BuildPdb Condition="$(BuildDll) and '$(OS)' == 'Windows_NT' and '$(TargetOS)' == 'windows'">true</BuildPdb> | ||||||||||
| <BuildPdb Condition="'$(OS)' == 'Windows_NT' and '$(TargetOS)' == 'windows'">true</BuildPdb> | ||||||||||
|
|
||||||||||
| <BuildPerfMap>false</BuildPerfMap> | ||||||||||
| <BuildPerfMap Condition="$(BuildDll) and '$(TargetOS)' == 'linux'">true</BuildPerfMap> | ||||||||||
| <BuildPerfMap Condition="'$(TargetOS)' == 'linux'">true</BuildPerfMap> | ||||||||||
|
|
||||||||||
| <_MergeMibcFilesCacheFile>$(MibcOptimizationDataDir)/$(TargetOS)/$(TargetArchitecture)/merge_mibc_files.cache</_MergeMibcFilesCacheFile> | ||||||||||
| </PropertyGroup> | ||||||||||
|
|
||||||||||
| <PropertyGroup Condition="'$(TargetsAppleMobile)' == 'true' and $(PublishReadyToRun)"> | ||||||||||
| <PublishReadyToRunContainerFormat>macho</PublishReadyToRunContainerFormat> | ||||||||||
| <UseComposite>true</UseComposite> | ||||||||||
| <CrossgenTargetName>$(CrossgenTargetName);LinkCoreLibMachO</CrossgenTargetName> | ||||||||||
| </PropertyGroup> | ||||||||||
|
|
||||||||||
| <PropertyGroup Condition="'$(UseComposite)' == 'true'"> | ||||||||||
| <CrossgenTargetName>$(CrossgenTargetName);CopyR2RComponentCoreLib</CrossgenTargetName> | ||||||||||
| </PropertyGroup> | ||||||||||
|
|
||||||||||
| <ItemGroup> | ||||||||||
| <OptimizationMibcFiles Include="$(MibcOptimizationDataDir)/$(TargetOS)/$(TargetArchitecture)/**/*.mibc" /> | ||||||||||
| </ItemGroup> | ||||||||||
|
|
||||||||||
| <PropertyGroup> | ||||||||||
| <CoreLibAssemblyName>System.Private.CoreLib</CoreLibAssemblyName> | ||||||||||
| <CoreLibOutputPath>$([MSBuild]::NormalizePath('$(BinDir)', '$(CoreLibAssemblyName).dll'))</CoreLibOutputPath> | ||||||||||
| <CrossgenCoreLibOutputPath>$(CoreLibOutputPath)</CrossgenCoreLibOutputPath> | ||||||||||
| <CrossgenCoreLibComponentOutputPath></CrossgenCoreLibComponentOutputPath> | ||||||||||
| <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> | ||||||||||
|
|
||||||||||
| <PropertyGroup Condition="'$(TargetsAppleMobile)' == 'true'"> | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe condition on |
||||||||||
| <CoreLibObjOutputPath>$([MSBuild]::NormalizePath('$(IntermediateOutputPath)', '$(CoreLibAssemblyName).o'))</CoreLibObjOutputPath> | ||||||||||
| <CrossgenCoreLibOutputPath>$(CoreLibObjOutputPath)</CrossgenCoreLibOutputPath> | ||||||||||
| <CoreLibDylibOutputPath>$([MSBuild]::NormalizePath('$(BinDir)', '$(CoreLibAssemblyName).dylib'))</CoreLibDylibOutputPath> | ||||||||||
| </PropertyGroup> | ||||||||||
|
|
||||||||||
| <PropertyGroup Condition="'$(UseComposite)' == 'true'"> | ||||||||||
| <CrossgenCoreLibComponentOutputPath>$([MSBuild]::NormalizePath('$(IntermediateOutputPath)', '$(CoreLibAssemblyName).dll'))</CrossgenCoreLibComponentOutputPath> | ||||||||||
| </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. --> | ||||||||||
|
|
@@ -88,30 +117,25 @@ | |||||||||
| <Target Name="CreateMergedMibcFile" | ||||||||||
| DependsOnTargets="ResolveProjectReferences;MergeMibcFiles" /> | ||||||||||
|
|
||||||||||
| <Target Name="PrepareInvokeCrossgen" DependsOnTargets="ResolveProjectReferences;CreateMergedMibcFile"> | ||||||||||
| <Target Name="PrepareInvokeCrossgen2" DependsOnTargets="ResolveProjectReferences;CreateMergedMibcFile"> | ||||||||||
| <ItemGroup> | ||||||||||
| <Crossgen2Inputs Include="@(CoreLib)" /> | ||||||||||
| <Crossgen2Inputs Include="$(MergedMibcPath)" /> | ||||||||||
| <Crossgen2Inputs Include="@(Crossgen2Files->Metadata('OutputPath'))" /> | ||||||||||
| </ItemGroup> | ||||||||||
| </Target> | ||||||||||
|
|
||||||||||
| <Target Name="InvokeCrossgenBrowser" | ||||||||||
| DependsOnTargets="PrepareInvokeCrossgen" | ||||||||||
| Inputs="@(Crossgen2Inputs)" | ||||||||||
| Outputs="$(CoreLibOutputPath)" | ||||||||||
| Condition="'$(TargetOS)' == 'browser'" | ||||||||||
| AfterTargets="Build"> | ||||||||||
| <!-- TODO-WASM: we will have WASM R2R later, for now we just need to copy the file into expected location --> | ||||||||||
| <Target Name="CopyILCoreLib" | ||||||||||
| DependsOnTargets="ResolveProjectReferences" | ||||||||||
| Inputs="@(CoreLib)" | ||||||||||
| Outputs="$(CoreLibOutputPath)"> | ||||||||||
| <Copy SourceFiles="@(CoreLib)" DestinationFiles="$(CoreLibOutputPath)" UseHardlinksIfPossible="true" /> | ||||||||||
| </Target> | ||||||||||
|
|
||||||||||
| <Target Name="InvokeCrossgen" | ||||||||||
| DependsOnTargets="PrepareInvokeCrossgen;CreateMergedMibcFile" | ||||||||||
| <Target Name="InvokeCrossgen2" | ||||||||||
| DependsOnTargets="PrepareInvokeCrossgen2;CreateMergedMibcFile" | ||||||||||
| Inputs="@(Crossgen2Inputs)" | ||||||||||
| Outputs="$(CoreLibOutputPath);$(CoreLibNiPdbPath);$(CoreLibPerfMapPath)" | ||||||||||
| Condition="'$(TargetOS)' != 'browser'" | ||||||||||
| AfterTargets="Build"> | ||||||||||
| Outputs="$(CoreLibOutputPath);$(CoreLibNiPdbPath);$(CoreLibPerfMapPath);$(CrossgenCoreLibOutputPath);$(CrossgenCoreLibComponentOutputPath)"> | ||||||||||
|
|
||||||||||
| <MakeDir | ||||||||||
| Directories="$(BinDir);$(IntermediatesDir);$(LogsDir)" /> | ||||||||||
|
|
@@ -121,9 +145,11 @@ | |||||||||
|
|
||||||||||
| <PropertyGroup> | ||||||||||
| <CrossGenDllCmd>@(Crossgen2Files->Metadata('OutputPath')->WithMetadataValue('Filename','crossgen2')->WithMetadataValue('Extension','$(ExeSuffix)'))</CrossGenDllCmd> | ||||||||||
| <CrossGenDllCmd>$(CrossGenDllCmd) -o:$(CoreLibOutputPath)</CrossGenDllCmd> | ||||||||||
| <CrossGenDllCmd>$(CrossGenDllCmd) -o:$(CrossgenCoreLibOutputPath)</CrossGenDllCmd> | ||||||||||
| <CrossGenDllCmd>$(CrossGenDllCmd) -r:$([MSBuild]::NormalizePath('$(BinDir)', 'IL', '*.dll'))</CrossGenDllCmd> | ||||||||||
| <CrossGenDllCmd>$(CrossGenDllCmd) --targetarch:$(TargetArchitecture)</CrossGenDllCmd> | ||||||||||
| <CrossGenDllCmd Condition="'$(PublishReadyToRunContainerFormat)' != ''">$(CrossGenDllCmd) --obj-format:$(PublishReadyToRunContainerFormat)</CrossGenDllCmd> | ||||||||||
| <CrossGenDllCmd Condition="'$(UseComposite)' == 'true'">$(CrossGenDllCmd) --composite</CrossGenDllCmd> | ||||||||||
|
Comment on lines
+151
to
+152
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| <CrossGenDllCmd Condition="'$(TargetsAndroid)' != 'true'">$(CrossGenDllCmd) --targetos:$(TargetOS)</CrossGenDllCmd> | ||||||||||
| <!-- Unless and until Android requires R2R specific customizations, we're just dealing with another linux --> | ||||||||||
| <CrossGenDllCmd Condition="'$(TargetsAndroid)' == 'true'">$(CrossGenDllCmd) --targetos:linux</CrossGenDllCmd> | ||||||||||
|
|
@@ -145,21 +171,113 @@ | |||||||||
| <CrossGenDllCmd>$(CrossGenDllCmd) --perfmap --perfmap-path:$(BinDir)</CrossGenDllCmd> | ||||||||||
| </PropertyGroup> | ||||||||||
|
|
||||||||||
| <Message Condition="$(BuildDll)" Importance="High" Text="$(CrossGenDllCmd)" /> | ||||||||||
| <Message Importance="High" Text="$(CrossGenDllCmd)" /> | ||||||||||
|
|
||||||||||
| <Exec Command="$(CrossGenDllCmd)" /> | ||||||||||
|
|
||||||||||
| <Message Importance="High" Text="Crossgenning of System.Private.CoreLib succeeded." /> | ||||||||||
| <Message Importance="High" Text="Product binaries are available at $(BinDir)" /> | ||||||||||
| </Target> | ||||||||||
|
|
||||||||||
| <Target Name="CopyR2RComponentCoreLib" | ||||||||||
| DependsOnTargets="InvokeCrossgen2" | ||||||||||
| Inputs="$(CrossgenCoreLibComponentOutputPath)" | ||||||||||
| Outputs="$(CoreLibOutputPath)"> | ||||||||||
| <Copy SourceFiles="$(CrossgenCoreLibComponentOutputPath)" DestinationFiles="$(CoreLibOutputPath)" UseHardlinksIfPossible="true" /> | ||||||||||
| </Target> | ||||||||||
|
|
||||||||||
| <Target | ||||||||||
| Name="LinkCoreLibMachO" | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we reuse |
||||||||||
| Inputs="$(CoreLibObjOutputPath)" | ||||||||||
| Outputs="$(CoreLibDylibOutputPath)"> | ||||||||||
| <PropertyGroup> | ||||||||||
| <_AppleTargetArchitecture Condition="'$(TargetArchitecture)' == 'x64'">x86_64</_AppleTargetArchitecture> | ||||||||||
| <_AppleTargetArchitecture Condition="'$(TargetArchitecture)' == 'arm64'">arm64</_AppleTargetArchitecture> | ||||||||||
| </PropertyGroup> | ||||||||||
|
|
||||||||||
| <PropertyGroup> | ||||||||||
| <AppleMinOSVersion Condition="'$(AppleMinOSVersion)' == '' and '$(TargetOS)' == 'osx'">12.0</AppleMinOSVersion> | ||||||||||
| <AppleMinOSVersion Condition="'$(AppleMinOSVersion)' == '' and '$(TargetOS)' == 'maccatalyst'">15.0</AppleMinOSVersion> | ||||||||||
| <AppleMinOSVersion Condition="'$(AppleMinOSVersion)' == '' and ($(TargetOS.StartsWith('ios')) or $(TargetOS.StartsWith('tvos')))">12.2</AppleMinOSVersion> | ||||||||||
|
|
||||||||||
| <_AppleSdkName Condition="'$(TargetOS)' == 'ios'">iphoneos</_AppleSdkName> | ||||||||||
| <_AppleSdkName Condition="'$(TargetOS)' == 'iossimulator'">iphonesimulator</_AppleSdkName> | ||||||||||
| <_AppleSdkName Condition="'$(TargetOS)' == 'tvos'">appletvos</_AppleSdkName> | ||||||||||
| <_AppleSdkName Condition="'$(TargetOS)' == 'tvossimulator'">appletvsimulator</_AppleSdkName> | ||||||||||
| <_AppleSdkName Condition="'$(TargetOS)' == 'maccatalyst' or '$(TargetOS)' == 'osx'">macosx</_AppleSdkName> | ||||||||||
|
|
||||||||||
| <_AppleTripleOS Condition="'$(TargetOS)' == 'osx'">macos</_AppleTripleOS> | ||||||||||
| <_AppleTripleOS Condition="'$(TargetOS)' == 'maccatalyst' or $(TargetOS.StartsWith('ios'))">ios</_AppleTripleOS> | ||||||||||
| <_AppleTripleOS Condition="$(TargetOS.StartsWith('tvos'))">tvos</_AppleTripleOS> | ||||||||||
|
|
||||||||||
| <_AppleTripleAbi Condition="'$(TargetOS)' == 'ios' or '$(TargetOS)' == 'tvos'">macho</_AppleTripleAbi> | ||||||||||
| <_AppleTripleAbi Condition="'$(TargetOS)' == 'maccatalyst'">macabi</_AppleTripleAbi> | ||||||||||
| <_AppleTripleAbi Condition="$(TargetOS.EndsWith('simulator'))">simulator</_AppleTripleAbi> | ||||||||||
|
|
||||||||||
| <TargetTriple Condition="'$(_AppleTripleAbi)' == ''">$(_AppleTargetArchitecture)-apple-$(_AppleTripleOS)$(AppleMinOSVersion)</TargetTriple> | ||||||||||
| <TargetTriple Condition="'$(_AppleTripleAbi)' != ''">$(_AppleTargetArchitecture)-apple-$(_AppleTripleOS)$(AppleMinOSVersion)-$(_AppleTripleAbi)</TargetTriple> | ||||||||||
| </PropertyGroup> | ||||||||||
|
|
||||||||||
| <Exec Condition="$(BuildDll)" Command="$(CrossGenDllCmd)" /> | ||||||||||
| <PropertyGroup> | ||||||||||
| <Xcrun Condition="'$(Xcrun)' == ''">xcrun</Xcrun> | ||||||||||
| <_WhereXcrun>0</_WhereXcrun> | ||||||||||
| </PropertyGroup> | ||||||||||
|
|
||||||||||
| <Message Condition="$(BuildPdb)" Importance="High" Text="$(CrossGenPdbCmd)" /> | ||||||||||
| <Exec Command="command -v "$(Xcrun)"" IgnoreExitCode="true" StandardOutputImportance="Low"> | ||||||||||
| <Output TaskParameter="ExitCode" PropertyName="_WhereXcrun" /> | ||||||||||
| </Exec> | ||||||||||
| <Error Condition="'$(_WhereXcrun)' != '0'" | ||||||||||
| Text="'$(Xcrun)' not found in PATH. Make sure '$(Xcrun)' is available in PATH." /> | ||||||||||
|
|
||||||||||
| <Exec Condition="$(BuildPdb) and '$(CrossGenPdbCmd)' != ''" Command="$(CrossGenPdbCmd)" /> | ||||||||||
| <Exec Command=""$(Xcrun)" --sdk $(_AppleSdkName) --show-sdk-path" IgnoreExitCode="true" StandardOutputImportance="Low" ConsoleToMsBuild="true"> | ||||||||||
| <Output TaskParameter="ConsoleOutput" PropertyName="SysRoot" /> | ||||||||||
| </Exec> | ||||||||||
|
|
||||||||||
| <Message Condition="$(BuildPerfMap)" Importance="High" Text="$(CrossGenPerfMapCmd)" /> | ||||||||||
| <Error Condition="!Exists('$(SysRoot)')" | ||||||||||
| Text="Apple SDK was not found in: '$(SysRoot)'" /> | ||||||||||
|
|
||||||||||
| <Exec Condition="$(BuildPerfMap) and '$(CrossGenPerfMapCmd)' != ''" Command="$(CrossGenPerfMapCmd)" /> | ||||||||||
| <Exec Command=""$(Xcrun)" --sdk $(_AppleSdkName) --find clang" IgnoreExitCode="true" StandardOutputImportance="Low" ConsoleToMsBuild="true"> | ||||||||||
| <Output TaskParameter="ConsoleOutput" PropertyName="_AppleClang" /> | ||||||||||
| </Exec> | ||||||||||
|
|
||||||||||
| <Copy Condition="!$(BuildDll)" SourceFiles="@(CoreLib)" DestinationFiles="$(CoreLibOutputPath)" UseHardlinksIfPossible="true" /> | ||||||||||
| <Error Condition="!Exists('$(_AppleClang)')" | ||||||||||
| Text="Apple Clang was not found at: '$(_AppleClang)'" /> | ||||||||||
|
|
||||||||||
| <Message Importance="High" Text="Crossgenning of System.Private.CoreLib succeeded." /> | ||||||||||
| <Message Importance="High" Text="Product binaries are available at $(BinDir)" /> | ||||||||||
| <ItemGroup> | ||||||||||
| <_MachLinkerArg Include="-gz=zlib" /> | ||||||||||
| <_MachLinkerArg Include="-isysroot "$(SysRoot)"" /> | ||||||||||
| <_MachLinkerArg Include="--target=$(TargetTriple)" /> | ||||||||||
| <_MachLinkerArg Include="-g" /> | ||||||||||
| <_MachLinkerArg Include="-dynamiclib" /> | ||||||||||
| <_MachLinkerArg Include="-Wl,-dead_strip" /> | ||||||||||
| </ItemGroup> | ||||||||||
|
|
||||||||||
| <Exec Command=""$(_AppleClang)" --version" IgnoreExitCode="true" StandardOutputImportance="Low" ConsoleToMSBuild="true"> | ||||||||||
| <Output TaskParameter="ExitCode" PropertyName="_XcodeVersionStringExitCode" /> | ||||||||||
| <Output TaskParameter="ConsoleOutput" PropertyName="_XcodeVersionString" /> | ||||||||||
| </Exec> | ||||||||||
|
|
||||||||||
| <PropertyGroup Condition="('$(_XcodeVersionStringExitCode)' == '0' or '$(_XcodeVersionStringExitCode)' == '1') and '$(_XcodeVersionString)' != ''"> | ||||||||||
| <_XcodeVersion>$([System.Text.RegularExpressions.Regex]::Match($(_XcodeVersionString), '[1-9]\d*'))</_XcodeVersion> | ||||||||||
| </PropertyGroup> | ||||||||||
|
|
||||||||||
| <ItemGroup Condition="'$(UseLdClassicXCodeLinker)' != 'false'"> | ||||||||||
| <_MachLinkerArg Condition="'$(UseLdClassicXCodeLinker)' == 'true' or '$(_XcodeVersion)' == '15' or '$(_XcodeVersion)' == '16'" Include="-ld_classic" /> | ||||||||||
| </ItemGroup> | ||||||||||
|
|
||||||||||
| <ItemGroup> | ||||||||||
| <_MachLinkerArg Include="-Wl,-install_name,"@rpath/$(CoreLibAssemblyName).dylib"" /> | ||||||||||
| <_MachLinkerArg Include="$(CoreLibObjOutputPath)" /> | ||||||||||
| <_MachLinkerArg Include="-o $(CoreLibDylibOutputPath)" /> | ||||||||||
| </ItemGroup> | ||||||||||
|
|
||||||||||
| <MakeDir Directories="$([System.IO.Path]::GetDirectoryName($(CoreLibDylibOutputPath)))" /> | ||||||||||
|
|
||||||||||
| <Exec Command=""$(_AppleClang)" @(_MachLinkerArg, ' ')" /> | ||||||||||
|
|
||||||||||
| <!-- remove executable flag --> | ||||||||||
| <Exec Command="chmod 644 "$(CoreLibDylibOutputPath)"" /> | ||||||||||
| </Target> | ||||||||||
|
|
||||||||||
| <Target Name="CrossgenCoreLib" DependsOnTargets="$(CrossgenTargetName)" AfterTargets="CoreBuild" /> | ||||||||||
| </Project> | ||||||||||
Uh oh!
There was an error while loading. Please reload this page.