-
Notifications
You must be signed in to change notification settings - Fork 555
[dotnet] Add support for ReadyToRun. #24437
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5208583
[dotnet] Add workaround for https://github.com/dotnet/runtime/issues/…
rolfbjarne a329e9d
[runtime] Download host_runtime_contract.h from dotnet/runtime.
rolfbjarne 347dc23
[dotnet] Add a workaround for finding the R2R compiler.
rolfbjarne 452b5d4
[dotnet] Add ReadyToRun support for CoreCLR and update related config…
kotlarmilos 01ac6ca
[dotnet] Add support for creating a .framework or .dylib from the Rea…
rolfbjarne f7b4957
[dotnet] Exclude user assemblies from ReadyToRun compilation unless w…
kotlarmilos 33cafbb
[xharness] Add missing flags for a few CoreCLR variations.
rolfbjarne 09ce0a5
[tests] Enable ReadyToRun app size test.
rolfbjarne File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,328 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
| <!-- Workaround for https://github.com/dotnet/runtime/issues/79902 --> | ||
| <Target Name="_FixR2ROutputPaths" AfterTargets="_PrepareForReadyToRunCompilation"> | ||
| <ItemGroup> | ||
| <_ReadyToRunFilesToPublishFixed Include="@(_ReadyToRunFilesToPublish->'$(_ReadyToRunOutputPath)/%(Filename)%(Extension)')" /> | ||
| <_ReadyToRunFilesToPublish Remove="@(_ReadyToRunFilesToPublish)" /> | ||
| <_ReadyToRunFilesToPublish Include="@(_ReadyToRunFilesToPublishFixed)" /> | ||
| </ItemGroup> | ||
| </Target> | ||
|
|
||
| <!-- Workaround for https://github.com/dotnet/runtime/issues/122985 --> | ||
| <Target Name="ResolveReadyToRunCompilers" Condition="'$(PublishReadyToRun)' == 'true' And '$(UseMonoRuntime)' != 'true'"> | ||
| <PropertyGroup> | ||
| <_Crossgen2Path Condition="'$(Crossgen2Path)' != ''">$(Crossgen2Path)</_Crossgen2Path> | ||
| <_FlattenedCrossgen2Packs>@(ResolvedCrossgen2Pack->'%(PackageDirectory)')</_FlattenedCrossgen2Packs> | ||
| <_Crossgen2Path Condition="'$(Crossgen2Path)' == ''">$(_FlattenedCrossgen2Packs)/tools/crossgen2</_Crossgen2Path> | ||
|
|
||
| <_TargetArch>$(RuntimeIdentifier.Split('-')[1])</_TargetArch> | ||
| <_TargetOS>$(RuntimeIdentifier.Split('-')[0])</_TargetOS> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <Crossgen2Tool Include="$(_Crossgen2Path)" | ||
| TargetArch="$(_TargetArch)" | ||
| TargetOS="$(_TargetOS)" | ||
| PerfmapFormatVersion="$(PublishReadyToRunPerfmapFormatVersion)"/> | ||
| </ItemGroup> | ||
|
|
||
| <Message Text="Using crossgen2: $(_Crossgen2Path)" Importance="high" /> | ||
| <Message Text=" RuntimeIdentifier: $(RuntimeIdentifier)" Importance="high" /> | ||
| <Message Text=" TargetArch: $(_TargetArch)" Importance="high" /> | ||
| <Message Text=" TargetOS: $(_TargetOS)" Importance="high" /> | ||
|
|
||
| <Error Condition="!Exists('$(_Crossgen2Path)')" Text="The crossgen2 executable '$(_Crossgen2Path)' does not exist." /> | ||
| </Target> | ||
|
|
||
| <!-- Set some default properties --> | ||
| <PropertyGroup Condition="'$(PublishReadyToRun)' == 'true' And '$(UseMonoRuntime)' == 'false' And '$(_UseNativeAot)' != 'true'"> | ||
| <CreateR2RFramework Condition="'$(CreateR2RFramework)' == '' ">true</CreateR2RFramework> | ||
| <CreateR2RDylib Condition="'$(CreateR2RDylib)' == '' And '$(CreateR2RFramework)' != 'true'">true</CreateR2RDylib> | ||
|
|
||
| <FilterReadyToRunAssemblies Condition="'$(FilterReadyToRunAssemblies)' == '' And '$(Configuration)' != 'Release'">true</FilterReadyToRunAssemblies> | ||
| </PropertyGroup> | ||
|
|
||
|
|
||
| <!-- Exclude user assemblies from R2R composite so they run interpreted for debugging --> | ||
| <Target Name="_SelectR2RAssemblies" | ||
| Condition="'$(FilterReadyToRunAssemblies)' == 'true'" | ||
| BeforeTargets="ResolveReadyToRunCompilers"> | ||
| <ItemGroup> | ||
| <_ResolvedAssembliesToPublish Include="@(ResolvedFileToPublish)" Condition="'%(Extension)' == '.dll' And '%(ResolvedFileToPublish.Culture)' == '' And '%(ResolvedFileToPublish.DestinationSubDirectory)' == ''" /> | ||
| <_NonUserAssemblies | ||
| Include="@(_ResolvedAssembliesToPublish)" | ||
| Condition="( | ||
| '%(_ResolvedAssembliesToPublish.NuGetPackageId)' == 'Microsoft.NETCore.App.Ref' Or | ||
| '%(_ResolvedAssembliesToPublish.NuGetPackageId)' == '$(_MonoNugetPackageId)' Or | ||
| '%(_ResolvedAssembliesToPublish.NuGetPackageId)' == '$(_XamarinNugetPackageId)' Or | ||
| '%(_ResolvedAssembliesToPublish.NuGetPackageId)' == '$(_XamarinNugetManagedPackageId)' | ||
| )" /> | ||
| <_UserAssemblies Include="@(_ResolvedAssembliesToPublish)" Exclude="@(_NonUserAssemblies)" /> | ||
| <PublishReadyToRunExcludeTest Include="@(_UserAssemblies -> '%(Filename)')" /> | ||
| </ItemGroup> | ||
| </Target> | ||
|
|
||
| <!-- | ||
| The following section is to create either a .dylib or a .framework from the Composite | ||
| ReadyToRun output (which is an object file, which must be linked into a dynamic library). | ||
| --> | ||
|
|
||
| <!-- Create a framework from the composite R2R output --> | ||
| <PropertyGroup> | ||
| <_CreateR2RFrameworkDependsOn> | ||
| _PrepareR2RFrameworkCreation; | ||
| _CreateR2RFrameworkStructure; | ||
| _ForceLinkR2RFramework; | ||
| _LinkR2RFramework; | ||
| </_CreateR2RFrameworkDependsOn> | ||
| </PropertyGroup> | ||
|
|
||
| <!-- Prepare properties and item groups for r2r framework creation --> | ||
| <Target Name="_PrepareR2RFrameworkCreation" | ||
| DependsOnTargets="CreateReadyToRunImages" | ||
| > | ||
| <PropertyGroup> | ||
| <_DesktopFramework Condition="'$(_PlatformName)' == 'macOS' Or '$(_PlatformName)' == 'MacCatalyst'">true</_DesktopFramework> | ||
| <_DesktopFramework Condition="'$(_PlatformName)' != 'macOS' And '$(_PlatformName)' != 'MacCatalyst'">false</_DesktopFramework> | ||
|
|
||
| <_R2RFrameworkBinaryInfix Condition="'$(_DesktopFramework)' == 'true'">/Versions/A</_R2RFrameworkBinaryInfix> | ||
| <_R2RFrameworkResourcesInfix Condition="'$(_DesktopFramework)' == 'true'">/Versions/A/Resources</_R2RFrameworkResourcesInfix> | ||
|
|
||
| <_R2RFrameworkIntermediateOutputPath Condition="'$(_R2RFrameworkIntermediateOutputPath)' == ''">$(DeviceSpecificIntermediateOutputPath)r2rframework/</_R2RFrameworkIntermediateOutputPath> | ||
| <_R2RFrameworkName Condition="'$(_R2RFrameworkName)' == ''">$(AssemblyName)</_R2RFrameworkName> | ||
| <_R2RFrameworkPath Condition="'$(_R2RFrameworkPath)' == ''">$(_R2RFrameworkIntermediateOutputPath)$(_R2RFrameworkName).framework</_R2RFrameworkPath> | ||
| <_R2RFrameworkOutput Condition="'$(_R2RFrameworkOutput)' == ''">$(_R2RFrameworkPath)$(_R2RFrameworkBinaryInfix)/$(_R2RFrameworkName)</_R2RFrameworkOutput> | ||
|
|
||
| <_R2RFrameworkStructureStampFile>$(_R2RFrameworkIntermediateOutputPath)$(_R2RFrameworkName)-structure.stamp</_R2RFrameworkStructureStampFile> | ||
|
|
||
| <_R2RFrameworkInfoPlistPath>$(_R2RFrameworkPath)$(_R2RFrameworkResourcesInfix)/Info.plist</_R2RFrameworkInfoPlistPath> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <_R2RFrameworkDirectories Include="$(_R2RFrameworkPath)" /> | ||
|
|
||
| <_R2RFrameworkInputs Include="@(_ReadyToRunCompileList->'%(OutputR2RImage)')" /> | ||
| <_R2RFrameworkLinkerFlags Include="-dynamiclib" /> | ||
| <_R2RFrameworkLinkerFlags Include="-Wl,-dead_strip" /> | ||
| <_R2RFrameworkLinkerFlags Include="-Wl,-install_name,@rpath/$(_R2RFrameworkName).framework/$(_R2RFrameworkName)" /> | ||
|
|
||
| <_FrameworkNativeReference Include="$(_R2RFrameworkPath)/$(_R2RFrameworkName)" Kind="Framework" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup Condition="'$(_DesktopFramework)' == 'true'"> | ||
| <_R2RFrameworkDirectories Include="$(_R2RFrameworkPath)/Versions/A/Resources" /> | ||
|
|
||
| <_R2RFrameworkSymlinks Include="$(_R2RFrameworkPath)/Resources" SymlinkTo="Versions/A/Resources" /> | ||
| <_R2RFrameworkSymlinks Include="$(_R2RFrameworkPath)/$(_R2RFrameworkName)" SymlinkTo="Versions/A/$(_R2RFrameworkName)" /> | ||
| <_R2RFrameworkSymlinks Include="$(_R2RFrameworkPath)/Versions/Current" SymlinkTo="A" /> | ||
| </ItemGroup> | ||
|
|
||
| <!-- write a hash of all the relevant input so that we can force a re-link if necessary --> | ||
kotlarmilos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| <PropertyGroup> | ||
| <_R2RFrameworkCachePath>$(_R2RFrameworkIntermediateOutputPath)cache.txt</_R2RFrameworkCachePath> | ||
| <_R2RFrameworkCachePath2>$(_R2RFrameworkCachePath).uptodate</_R2RFrameworkCachePath2> | ||
| </PropertyGroup> | ||
| <ItemGroup> | ||
| <_R2RFrameworkCache Include="@(_R2RFrameworkInputs)" /> | ||
| <_R2RFrameworkCache Include="@(_R2RFrameworkLinkerFlags)" /> | ||
| <_R2RFrameworkCache Include="$(_R2RFrameworkOutput)" /> | ||
| <_R2RFrameworkCache Include="$(_MinimumOSVersion)" /> | ||
| </ItemGroup> | ||
|
|
||
| <Hash | ||
| ItemsToHash="@(_R2RFrameworkCache)" | ||
| IgnoreCase="false"> | ||
| <Output TaskParameter="HashResult" PropertyName="_R2RFrameworkCacheHash" /> | ||
| </Hash> | ||
|
|
||
| <WriteLinesToFile Lines="$(_R2RFrameworkCacheHash)" File="$(_R2RFrameworkCachePath)" Overwrite="true" WriteOnlyWhenDifferent="true" /> | ||
|
|
||
| <ItemGroup> | ||
| <FileWrites Include="$(_R2RFrameworkCachePath)" /> | ||
| </ItemGroup> | ||
| </Target> | ||
|
|
||
| <Target Name="_CreateR2RFrameworkStructure" | ||
| Outputs="$(_R2RFrameworkStructureStampFile)" | ||
| > | ||
|
|
||
| <MakeDir | ||
| SessionId="$(BuildSessionId)" | ||
| Directories="@(_R2RFrameworkDirectories)" | ||
| /> | ||
|
|
||
| <Exec | ||
| SessionId="$(BuildSessionId)" | ||
| Command="ln -fs "%(SymlinkTo)" "@(_R2RFrameworkSymlinks)"" | ||
| Condition="@(_R2RFrameworkSymlinks->Count()) > 0" | ||
| /> | ||
|
|
||
| <CompileAppManifest | ||
| SessionId="$(BuildSessionId)" | ||
| AppBundleName="$(_R2RFrameworkName)" | ||
| ApplicationId="$(_BundleIdentifier).r2rframework" | ||
| BundleExecutable="$(_R2RFrameworkName)" | ||
| CompiledAppManifest="$(_R2RFrameworkInfoPlistPath)" | ||
| DefaultSdkVersion="$(_SdkVersion)" | ||
| GenerateApplicationManifest="true" | ||
| IsAppExtension="false" | ||
| IsFramework="true" | ||
| MinSupportedOSPlatformVersion="$(MinSupportedOSPlatformVersion)" | ||
| ProjectDir="$(MSBuildProjectDirectory)" | ||
| ResourcePrefix="$(_ResourcePrefix)" | ||
| SdkIsSimulator="$(_SdkIsSimulator)" | ||
| SdkVersion="$(_SdkVersion)" | ||
| SupportedOSPlatformVersion="$(SupportedOSPlatformVersion)" | ||
| TargetArchitectures="$(TargetArchitectures)" | ||
| TargetFrameworkMoniker="$(_ComputedTargetFrameworkMoniker)" | ||
| /> | ||
|
|
||
| <Touch | ||
| Files="$(_R2RFrameworkStructureStampFile)" | ||
| AlwaysCreate="True" | ||
| /> | ||
|
|
||
| <ItemGroup> | ||
| <FileWrites Include="@(_R2RFrameworkSymlinks)" /> | ||
| <FileWrites Include="$(_R2RFrameworkInfoPlistPath)" /> | ||
| <FileWrites Include="$(_R2RFrameworkStructureStampFile)" /> | ||
| </ItemGroup> | ||
| </Target> | ||
|
|
||
| <!-- force the r2r framework executable to be re-created by deleting the executable file--> | ||
| <Target Name="_ForceLinkR2RFramework" | ||
| Inputs="$(_R2RFrameworkCachePath)" | ||
| Outputs="$(_R2RFrameworkCachePath2)" | ||
| > | ||
| <Delete Files="$(_R2RFrameworkOutput)" /> | ||
| <Copy SourceFiles="$(_R2RFrameworkCachePath)" DestinationFiles="$(_R2RFrameworkCachePath2)" /> | ||
| <ItemGroup> | ||
| <FileWrites Include="$(_R2RFrameworkCachePath2)" /> | ||
| </ItemGroup> | ||
| </Target> | ||
|
|
||
| <!-- link the object file created by the r2r compiler into a dynamic library we're going to put into the r2r framework --> | ||
| <Target Name="_LinkR2RFramework" | ||
| Inputs="@(_R2RFrameworkInputs)" | ||
| Outputs="$(_R2RFrameworkOutput)" | ||
| > | ||
|
|
||
| <MakeDir | ||
| SessionId="$(BuildSessionId)" | ||
| Directories="$(_R2RFrameworkPath)" | ||
| /> | ||
|
|
||
| <LinkNativeCode | ||
| SessionId="$(BuildSessionId)" | ||
| ObjectFiles="@(_R2RFrameworkInputs)" | ||
| OutputFile="$(_R2RFrameworkOutput)" | ||
| LinkerFlags="@(_R2RFrameworkLinkerFlags)" | ||
|
|
||
| MinimumOSVersion="$(_MinimumOSVersion)" | ||
| SdkDevPath="$(_SdkDevPath)" | ||
| SdkIsSimulator="$(_SdkIsSimulator)" | ||
| SdkRoot="$(_SdkRoot)" | ||
| TargetArchitectures="$(TargetArchitectures)" | ||
| TargetFrameworkMoniker="$(_ComputedTargetFrameworkMoniker)" | ||
| /> | ||
| </Target> | ||
|
|
||
| <Target Name="_CreateR2RFramework" | ||
| Condition="'$(CreateR2RFramework)' == 'true'" | ||
| DependsOnTargets="$(_CreateR2RFrameworkDependsOn)" | ||
| AfterTargets="CreateReadyToRunImages" | ||
| /> | ||
|
|
||
| <!-- Create a dylib from the composite R2R output --> | ||
| <PropertyGroup> | ||
| <_CreateR2RDylibDependsOn> | ||
| _PrepareR2RDylibCreation; | ||
| _ForceLinkR2RDylib; | ||
| _LinkR2RDylib; | ||
| </_CreateR2RDylibDependsOn> | ||
| </PropertyGroup> | ||
|
|
||
| <Target Name="_PrepareR2RDylibCreation" | ||
| DependsOnTargets="CreateReadyToRunImages" | ||
| > | ||
| <PropertyGroup> | ||
| <_R2RDylibIntermediateOutputPath Condition="'$(_R2RFrameworkIntermediateOutputPath)' == ''">$(DeviceSpecificIntermediateOutputPath)r2rdylib/</_R2RDylibIntermediateOutputPath> | ||
| <_R2RDylibName Condition="'$(_R2RDylibName)' == ''">$(AssemblyName)</_R2RDylibName> | ||
| <_R2RDylibPath Condition="'$(_R2RDylibPath)' == ''">$(_R2RDylibIntermediateOutputPath)</_R2RDylibPath> | ||
| <_R2RDylibOutput Condition="'$(_R2RDylibOutput)' == ''">$(_R2RDylibPath)$(_R2RDylibName).r2r.dylib</_R2RDylibOutput> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <_R2RDylibInputs Include="@(_ReadyToRunCompileList->'%(OutputR2RImage)')" /> | ||
| <_R2RDylibLinkerFlags Include="-dynamiclib" /> | ||
| <_R2RDylibLinkerFlags Include="-Wl,-dead_strip" /> | ||
| <_R2RDylibLinkerFlags Include="-Wl,-install_name,@rpath/$(_R2RDylibName).r2r.dylib" /> | ||
|
|
||
| <_FileNativeReference Include="$(_R2RDylibOutput)" Kind="Dynamic" /> | ||
| </ItemGroup> | ||
|
|
||
| <!-- write a hash of all the relevant input so that we can force a re-link if necessary --> | ||
| <PropertyGroup> | ||
| <_R2RDylibCachePath>$(_R2RDylibIntermediateOutputPath)cache.txt</_R2RDylibCachePath> | ||
| <_R2RDylibCachePath2>$(_R2RDylibCachePath).uptodate</_R2RDylibCachePath2> | ||
| </PropertyGroup> | ||
| <ItemGroup> | ||
| <_R2RDylibCache Include="@(_R2RDylibInputs)" /> | ||
| <_R2RDylibCache Include="@(_R2RDylibLinkerFlags)" /> | ||
| <_R2RDylibCache Include="$(_R2RDylibOutput)" /> | ||
| <_R2RDylibCache Include="$(_MinimumOSVersion)" /> | ||
| </ItemGroup> | ||
|
|
||
| <Hash | ||
| ItemsToHash="@(_R2RDylibCache)" | ||
| IgnoreCase="false"> | ||
| <Output TaskParameter="HashResult" PropertyName="_R2RDylibCacheHash" /> | ||
| </Hash> | ||
|
|
||
| <WriteLinesToFile Lines="$(_R2RDylibCacheHash)" File="$(_R2RDylibCachePath)" Overwrite="true" WriteOnlyWhenDifferent="true" /> | ||
|
|
||
| <ItemGroup> | ||
| <FileWrites Include="$(_R2RDylibCachePath)" /> | ||
| </ItemGroup> | ||
| </Target> | ||
|
|
||
| <!-- force the r2r dylib to be re-created by deleting the executable file--> | ||
| <Target Name="_ForceLinkR2RDylib" | ||
| Inputs="$(_R2RDylibCachePath)" | ||
| Outputs="$(_R2RDylibCachePath2)" | ||
| > | ||
| <Delete Files="$(_R2RDylibOutput)" /> | ||
| <Copy SourceFiles="$(_R2RDylibCachePath)" DestinationFiles="$(_R2RDylibCachePath2)" /> | ||
| <ItemGroup> | ||
| <FileWrites Include="$(_R2RDylibCachePath2)" /> | ||
| </ItemGroup> | ||
| </Target> | ||
|
|
||
| <!-- link the object file created by the r2r compiler into a dynamic library --> | ||
| <Target Name="_LinkR2RDylib" | ||
| Inputs="@(_R2RDylibInputs)" | ||
| Outputs="$(_R2RDylibOutput)" | ||
| > | ||
|
|
||
| <LinkNativeCode | ||
| SessionId="$(BuildSessionId)" | ||
| ObjectFiles="@(_R2RDylibInputs)" | ||
| OutputFile="$(_R2RDylibOutput)" | ||
| LinkerFlags="@(_R2RDylibLinkerFlags)" | ||
|
|
||
| MinimumOSVersion="$(_MinimumOSVersion)" | ||
| SdkDevPath="$(_SdkDevPath)" | ||
| SdkIsSimulator="$(_SdkIsSimulator)" | ||
| SdkRoot="$(_SdkRoot)" | ||
| TargetArchitectures="$(TargetArchitectures)" | ||
| TargetFrameworkMoniker="$(_ComputedTargetFrameworkMoniker)" | ||
| /> | ||
| </Target> | ||
|
|
||
| <Target Name="_CreateR2RDylib" | ||
| Condition="'$(CreateR2RDylib)' == 'true'" | ||
| DependsOnTargets="$(_CreateR2RDylibDependsOn)" | ||
| AfterTargets="CreateReadyToRunImages" | ||
| /> | ||
| </Project> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.