Skip to content

Commit

Permalink
Add NativeAOT runtime pack build for iOS/tvOS/Catalyst
Browse files Browse the repository at this point in the history
Contributes to #81024
  • Loading branch information
akoeplinger committed Apr 19, 2023
1 parent 926062a commit fb651ae
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 16 deletions.
8 changes: 6 additions & 2 deletions eng/Subsets.props
Original file line number Diff line number Diff line change
Expand Up @@ -481,24 +481,28 @@

<Choose>
<When Condition="$(_subset.Contains('+packs.product+'))">
<ItemGroup Condition="'$(RuntimeFlavor)' != 'Mono'">
<ItemGroup Condition="'$(BuildNativeAOTRuntimePack)' != 'true' and '$(RuntimeFlavor)' != 'Mono'">
<SharedFrameworkProjectToBuild Include="$(InstallerProjectRoot)pkg\sfx\Microsoft.NETCore.App\Microsoft.NETCore.App.Runtime.Composite.sfxproj" />
<SharedFrameworkProjectToBuild Include="$(InstallerProjectRoot)pkg\sfx\bundle\Microsoft.NETCore.App.Composite.Bundle.bundleproj" />
</ItemGroup>
<ItemGroup Condition="'$(PgoInstrument)' != 'true'">
<SharedFrameworkProjectToBuild Condition="'$(BuildMonoAOTCrossCompilerOnly)' != 'true'" Include="$(InstallerProjectRoot)pkg\sfx\Microsoft.NETCore.App\Microsoft.NETCore.App.Ref.sfxproj" />
</ItemGroup>
<ItemGroup Condition="'$(BuildNativeAOTRuntimePack)' != 'true'">
<SharedFrameworkProjectToBuild Condition="'$(RuntimeFlavor)' == '$(PrimaryRuntimeFlavor)'" Include="$(InstallerProjectRoot)pkg\sfx\Microsoft.NETCore.App\Microsoft.NETCore.App.Host.sfxproj" />
<SharedFrameworkProjectToBuild Condition="'$(RuntimeFlavor)' != 'Mono'" Include="$(InstallerProjectRoot)pkg\sfx\Microsoft.NETCore.App\Microsoft.NETCore.App.Crossgen2.sfxproj" />
<SharedFrameworkProjectToBuild Condition="'$(RuntimeFlavor)' == '$(PrimaryRuntimeFlavor)'" Include="$(InstallerProjectRoot)pkg\sfx\installers\dotnet-host.proj" />
<SharedFrameworkProjectToBuild Condition="'$(RuntimeFlavor)' == '$(PrimaryRuntimeFlavor)'" Include="$(InstallerProjectRoot)pkg\sfx\installers\dotnet-hostfxr.proj" />
<SharedFrameworkProjectToBuild Condition="'$(RuntimeFlavor)' == '$(PrimaryRuntimeFlavor)'" Include="$(InstallerProjectRoot)pkg\sfx\installers\dotnet-runtime-deps\*.proj" />
<SharedFrameworkProjectToBuild Condition="'$(RuntimeFlavor)' == '$(PrimaryRuntimeFlavor)'" Include="$(InstallerProjectRoot)pkg\archives\dotnet-nethost.proj" />
<SharedFrameworkProjectToBuild Condition="'$(MonoCrossAOTTargetOS)' != ''" Include="$(InstallerProjectRoot)pkg\sfx\Microsoft.NETCore.App\monocrossaot.sfxproj" Pack="true" />
</ItemGroup>
<ItemGroup>
<ProjectToBuild Condition="'$(NativeAotSupported)' == 'true' and '$(RuntimeFlavor)' != 'Mono'" Include="$(InstallerProjectRoot)\pkg\projects\nativeaot-packages.proj" Category="packs" />
</ItemGroup>
<ItemGroup>
<SharedFrameworkProjectToBuild Condition="'$(BuildMonoAOTCrossCompilerOnly)' != 'true'" Include="$(InstallerProjectRoot)pkg\sfx\Microsoft.NETCore.App\Microsoft.NETCore.App.Runtime.sfxproj" />
<SharedFrameworkProjectToBuild Condition="'$(RuntimeFlavor)' == '$(PrimaryRuntimeFlavor)'" Include="$(InstallerProjectRoot)pkg\sfx\bundle\Microsoft.NETCore.App.Bundle.bundleproj" />
<SharedFrameworkProjectToBuild Condition="'$(BuildNativeAOTRuntimePack)' != 'true' and '$(RuntimeFlavor)' == '$(PrimaryRuntimeFlavor)'" Include="$(InstallerProjectRoot)pkg\sfx\bundle\Microsoft.NETCore.App.Bundle.bundleproj" />
<ProjectToBuild Include="@(SharedFrameworkProjectToBuild)" Category="packs" />
</ItemGroup>
</When>
Expand Down
9 changes: 8 additions & 1 deletion eng/liveBuilds.targets
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,14 @@
<MonoArtifactsPath>$([MSBuild]::NormalizeDirectory('$(MonoArtifactsPath)'))</MonoArtifactsPath>
</PropertyGroup>

<ItemGroup Condition="'$(RuntimeFlavor)' == 'CoreCLR'">
<ItemGroup Condition="'$(BuildNativeAOTRuntimePack)' == 'true'">
<_nativeAotRuntimeFiles Include="$(CoreCLRAotSdkDir)*" />
<RuntimeFiles Include="@(_nativeAotRuntimeFiles)" Condition="'%(Extension)' != '.xml'">
<IsNative>true</IsNative>
</RuntimeFiles>
</ItemGroup>

<ItemGroup Condition="'$(RuntimeFlavor)' == 'CoreCLR' and '$(BuildNativeAOTRuntimePack)' != 'true'">
<RuntimeFiles Include="$(CoreCLRSharedFrameworkDir)*.*" />
<RuntimeFiles Condition="'$(PgoInstrument)' == 'true'" Include="$(CoreCLRSharedFrameworkDir)PGD/*" />
<CoreCLRCrossTargetFiles Condition="'$(CoreCLRCrossTargetComponentDir)' != ''" Include="$(CoreCLRCrossTargetComponentDir)*.*" IsNative="true" />
Expand Down
25 changes: 25 additions & 0 deletions eng/pipelines/runtime-official.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,31 @@ extends:
- windows_x64
- windows_arm
- windows_arm64

#
# Build NativeAOT runtime packs
#
- template: /eng/pipelines/common/platform-matrix.yml
parameters:
jobTemplate: /eng/pipelines/common/global-build-job.yml
buildConfig: release
platforms:
- maccatalyst_x64
- maccatalyst_arm64
- tvossimulator_x64
- tvossimulator_arm64
- tvos_arm64
- iossimulator_x64
- iossimulator_arm64
- ios_arm64
jobParameters:
buildArgs: -s clr.nativeaotlibs+clr.nativeaotruntime+libs+packs -c $(_BuildConfig) /p:BuildNativeAOTRuntimePack=true
nameSuffix: AllSubsets_NativeAOT
isOfficialBuild: ${{ variables.isOfficialBuild }}
extraStepsTemplate: /eng/pipelines/common/upload-intermediate-artifacts-step.yml
extraStepsParameters:
name: NativeAOTRuntimePacks

#
# Build Mono runtime packs
#
Expand Down
4 changes: 3 additions & 1 deletion src/coreclr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ endif()
#----------------------------------------------------
# Build the test watchdog alongside the CLR
#----------------------------------------------------
add_subdirectory("${CLR_SRC_NATIVE_DIR}/watchdog" test-watchdog)
if(NOT CLR_CMAKE_HOST_MACCATALYST AND NOT CLR_CMAKE_HOST_IOS AND NOT CLR_CMAKE_HOST_TVOS)
add_subdirectory("${CLR_SRC_NATIVE_DIR}/watchdog" test-watchdog)
endif()

# Add this subdir. We install the headers for the jit.
add_subdirectory(pal/prebuilt/inc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<ItemGroup>
<File Include="$(CoreCLRBuildIntegrationDir)*" TargetPath="build" />
<File Include="$(CoreCLRILCompilerDir)netstandard\*" TargetPath="tools/netstandard" />
<File Include="sdk\Sdk.props" TargetPath="Sdk" />
<File Include="sdk\Sdk.props" TargetPath="sdk" />
</ItemGroup>
</Target>

Expand Down
14 changes: 14 additions & 0 deletions src/installer/pkg/sfx/Microsoft.NETCore.App/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,20 @@
<PlatformManifestFileEntry Include="Microsoft.DiaSymReader.Native.amd64.dll" IsNative="true" FallbackFileVersion="$(MicrosoftDiaSymReaderNativeFileVersion)" />
<PlatformManifestFileEntry Include="Microsoft.DiaSymReader.Native.arm.dll" IsNative="true" FallbackFileVersion="$(MicrosoftDiaSymReaderNativeFileVersion)" />
<PlatformManifestFileEntry Include="Microsoft.DiaSymReader.Native.arm64.dll" IsNative="true" FallbackFileVersion="$(MicrosoftDiaSymReaderNativeFileVersion)" />
<!-- NativeAOT specific files -->
<PlatformManifestFileEntry Include="libbootstrapper.a" IsNative="true" />
<PlatformManifestFileEntry Include="libbootstrapperdll.a" IsNative="true" />
<PlatformManifestFileEntry Include="libeventpipe-disabled.a" IsNative="true" />
<PlatformManifestFileEntry Include="libeventpipe-enabled.a" IsNative="true" />
<PlatformManifestFileEntry Include="libnumasupportdynamic.a" IsNative="true" />
<PlatformManifestFileEntry Include="libnumasupportstatic.a" IsNative="true" />
<PlatformManifestFileEntry Include="libRuntime.ServerGC.a" IsNative="true" />
<PlatformManifestFileEntry Include="libRuntime.WorkstationGC.a" IsNative="true" />
<PlatformManifestFileEntry Include="libstdc++compat.a" IsNative="true" />
<PlatformManifestFileEntry Include="System.Private.DisabledReflection.dll" />
<PlatformManifestFileEntry Include="System.Private.Reflection.Execution.dll" />
<PlatformManifestFileEntry Include="System.Private.StackTraceMetadata.dll" />
<PlatformManifestFileEntry Include="System.Private.TypeLoader.dll" />
<!-- Mono-specific files -->
<PlatformManifestFileEntry Include="monosgen-2.0.lib" IsNative="true" />
<PlatformManifestFileEntry Include="libmonosgen-2.0.a" IsNative="true" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
AddRuntimeFilesToPackage;
AddFrameworkFilesToPackage
</GetSharedFrameworkFilesForReadyToRunDependsOn>
<PublishReadyToRun Condition="'$(RuntimeFlavor)' != 'Mono'">true</PublishReadyToRun>
<PublishReadyToRun Condition="'$(RuntimeFlavor)' == 'Mono'">false</PublishReadyToRun>
<PublishReadyToRun Condition="'$(RuntimeFlavor)' != 'Mono' and '$(BuildNativeAOTRuntimePack)' != 'true'">true</PublishReadyToRun>
<PublishReadyToRun Condition="'$(RuntimeFlavor)' == 'Mono' or '$(BuildNativeAOTRuntimePack)' == 'true'">false</PublishReadyToRun>
<!-- Disable crossgen on NetBSD, illumos and Solaris for now. This can be revisited when we have full support. -->
<PublishReadyToRun Condition="'$(TargetOS)' == 'netbsd' or '$(TargetOS)' == 'illumos' or '$(TargetOS)' == 'solaris'">false</PublishReadyToRun>
<!-- Disable crossgen on FreeBSD when cross building from Linux. -->
Expand All @@ -17,6 +17,9 @@
<MacOSPackageDescription>The .NET Shared Framework</MacOSPackageDescription>
</PropertyGroup>

<PropertyGroup Condition="'$(BuildNativeAOTRuntimePack)' == 'true'">
<RuntimeSpecificFrameworkSuffix>NativeAOT</RuntimeSpecificFrameworkSuffix>
</PropertyGroup>
<PropertyGroup Condition="'$(RuntimeFlavor)' == 'Mono' and '$(RuntimeFlavor)' != '$(PrimaryRuntimeFlavor)'">
<RuntimeSpecificFrameworkSuffix>Mono</RuntimeSpecificFrameworkSuffix>
</PropertyGroup>
Expand All @@ -38,7 +41,7 @@
We add the entries here to ensure that we don't fail the validation that every file included in the runtime pack is in the platform manifest
without adding the entries to the manifest in the ref pack.
-->
<ItemGroup>
<ItemGroup Condition="'$(BuildNativeAOTRuntimePack)' != 'true'">
<PlatformManifestFileEntry Include="hostpolicy.dll" IsNative="true" />
<PlatformManifestFileEntry Include="libhostpolicy.so" IsNative="true" />
<PlatformManifestFileEntry Include="libhostpolicy.dylib" IsNative="true" />
Expand All @@ -47,14 +50,18 @@
<PlatformManifestFileEntry Include="libhostfxr.dylib" IsNative="true" />
</ItemGroup>

<ItemGroup Condition="'$(BuildNativeAOTRuntimePack)' == 'true'">
<IgnoredDuplicateType Include="Internal.Runtime.CompilerHelpers.LibraryInitializer" />
</ItemGroup>

<Target Name="AddLinuxPackageInformation" BeforeTargets="GetDebInstallerJsonProperties;GetRpmInstallerJsonProperties">
<ItemGroup>
<LinuxPackageDependency Include="dotnet-hostfxr-$(MajorVersion).$(MinorVersion);dotnet-runtime-deps-$(MajorVersion).$(MinorVersion)" Version="$(InstallerPackageVersion)" />
</ItemGroup>
</Target>

<!-- Mobile uses a different hosting model, so we don't include the .NET host components. -->
<ItemGroup Condition="'$(TargetsMobile)' != 'true'">
<!-- Mobile and NativeAOT use a different hosting model, so we don't include the .NET host components. -->
<ItemGroup Condition="'$(TargetsMobile)' != 'true' and '$(BuildNativeAOTRuntimePack)' != 'true'">
<NativeRuntimeAsset Include="$(DotNetHostBinDir)/$(LibPrefix)hostpolicy$(LibSuffix)" />
<NativeRuntimeAsset Include="$(DotNetHostBinDir)/$(LibPrefix)hostfxr$(LibSuffix)" PackOnly="true" />
</ItemGroup>
Expand All @@ -64,7 +71,8 @@
<RuntimeFiles Condition="'%(RuntimeFiles.IsNative)' == 'true'">
<TargetPath>runtimes/$(RuntimeIdentifier)/native</TargetPath>
</RuntimeFiles>

</ItemGroup>
<ItemGroup Condition="'$(BuildNativeAOTRuntimePack)' != 'true'">
<RuntimeFiles Condition="'%(FileName)' == 'crossgen'">
<TargetPath>tools</TargetPath>
</RuntimeFiles>
Expand All @@ -87,7 +95,7 @@
<TargetPath>runtimes/$(RuntimeIdentifier)/native/Mono.debug.framework/%(RecursiveDir)</TargetPath>
</RuntimeFiles>

<RuntimeFiles Condition="'$(RuntimeFlavor)' == 'mono'"
<RuntimeFiles Condition="'$(RuntimeFlavor)' == 'Mono'"
Include="$(MonoArtifactsPath)\build\**\*.*"
ExcludeFromDataFiles="true">
<TargetPath>runtimes/$(RuntimeIdentifier)/build/%(RecursiveDir)</TargetPath>
Expand All @@ -110,6 +118,8 @@
Condition="Exists('$(CoreCLRArtifactsPath)StandardOptimizationData.mibc')">
<TargetPath>tools</TargetPath>
</CoreCLROptimizationFiles>
</ItemGroup>
<ItemGroup>
<ReferenceCopyLocalPaths Include="@(RuntimeFiles);@(CoreCLRCrossTargetFiles);@(CoreCLROptimizationFiles)" />
</ItemGroup>
</Target>
Expand All @@ -123,7 +133,7 @@
</ItemGroup>
</Target>

<PropertyGroup Condition="'$(TargetOS)' == 'windows'">
<PropertyGroup Condition="'$(BuildNativeAOTRuntimePack)' != 'true' and '$(TargetOS)' == 'windows'">
<!-- DiaSymReader for the host architecture, which is used for [cross-]compilation -->
<_diaSymArch>$(_hostArch)</_diaSymArch>
<_diaSymReaderPath>$(PkgMicrosoft_DiaSymReader_Native)/runtimes/win/native/Microsoft.DiaSymReader.Native.$(_diaSymArch).dll</_diaSymReaderPath>
Expand All @@ -134,7 +144,7 @@
<_diaSymReaderTargetArchPath>$(PkgMicrosoft_DiaSymReader_Native)/runtimes/win/native/Microsoft.DiaSymReader.Native.$(_diaSymTargetArch).dll</_diaSymReaderTargetArchPath>
</PropertyGroup>

<ItemGroup Condition="'$(TargetOS)' == 'windows'">
<ItemGroup Condition="'$(BuildNativeAOTRuntimePack)' != 'true' and '$(TargetOS)' == 'windows'">
<NativeRuntimeAsset Include="$(_diaSymReaderTargetArchPath)" />
<NativeRuntimeAsset Include="$(_diaSymReaderPath)" Condition="'$(CoreCLRCrossTargetComponentDirName)' != ''">
<TargetPath>runtimes/$(CoreCLRCrossTargetComponentDirName)_$(TargetArchitecture)/native</TargetPath>
Expand All @@ -160,10 +170,10 @@
</ItemGroup>
</Target>

<Import Project="$(Crossgen2SdkOverridePropsPath)" Condition="'$(Crossgen2SdkOverridePropsPath)' != ''" />
<Import Project="$(Crossgen2SdkOverridePropsPath)" Condition="'$(BuildNativeAOTRuntimePack)' != 'true' and '$(Crossgen2SdkOverridePropsPath)' != ''" />
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
<Import Project="Sdk.targets" Sdk="Microsoft.DotNet.SharedFramework.Sdk" />
<Import Project="$(Crossgen2SdkOverrideTargetsPath)" Condition="'$(Crossgen2SdkOverrideTargetsPath)' != ''" />
<Import Project="$(Crossgen2SdkOverrideTargetsPath)" Condition="'$(BuildNativeAOTRuntimePack)' != 'true' and '$(Crossgen2SdkOverrideTargetsPath)' != ''" />
<PropertyGroup>
<PublishReadyToRunComposite Condition="$(ForcePublishReadyToRunComposite) == 'true'">true</PublishReadyToRunComposite>
</PropertyGroup>
Expand Down

0 comments on commit fb651ae

Please sign in to comment.