Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,15 @@
Update="Microsoft.NETCore.App"
TargetingPackVersion="$(MicrosoftNETCoreAppRefPackageVersion)"
RuntimeFrameworkVersion="$(MicrosoftNETCoreAppRuntimePackageVersion)" />
<KnownILCompilerPack Update="Microsoft.DotNet.ILCompiler"
ILCompilerPackVersion="$(MicrosoftNETCoreAppRuntimePackageVersion)" />
<!-- Exact pack RID matches do not require the distro-specific RID to be in the portable RID graph. -->
<KnownFrameworkReference Update="Microsoft.NETCore.App"
Condition="'$(DotNetBuildSourceOnly)' == 'true' and '$(TargetRid)' != ''">
<RuntimePackRuntimeIdentifiers>%(RuntimePackRuntimeIdentifiers);$(TargetRid)</RuntimePackRuntimeIdentifiers>
</KnownFrameworkReference>
<KnownILCompilerPack Update="Microsoft.DotNet.ILCompiler">
<ILCompilerPackVersion>$(MicrosoftNETCoreAppRuntimePackageVersion)</ILCompilerPackVersion>
<ILCompilerRuntimeIdentifiers Condition="'$(DotNetBuildSourceOnly)' == 'true' and '$(TargetRid)' != ''">%(ILCompilerRuntimeIdentifiers);$(TargetRid)</ILCompilerRuntimeIdentifiers>
</KnownILCompilerPack>
<KnownILLinkPack Update="Microsoft.NET.ILLink.Tasks"
ILLinkPackVersion="$(MicrosoftNETCoreAppRuntimePackageVersion)" />
<KnownWebAssemblySdkPack Update="Microsoft.NET.Sdk.WebAssembly.Pack"
Expand All @@ -64,6 +71,7 @@
<KnownFrameworkReference Update="Microsoft.AspNetCore.App">
<LatestRuntimeFrameworkVersion>$(MicrosoftAspNetCoreAppRefPackageVersion)</LatestRuntimeFrameworkVersion>
<RuntimePackRuntimeIdentifiers>$(SupportedRuntimeIdentifiers)</RuntimePackRuntimeIdentifiers>
<RuntimePackRuntimeIdentifiers Condition="'$(DotNetBuildSourceOnly)' == 'true' and '$(TargetRid)' != ''">%(RuntimePackRuntimeIdentifiers);$(TargetRid)</RuntimePackRuntimeIdentifiers>
<TargetingPackVersion>$(MicrosoftAspNetCoreAppRefPackageVersion)</TargetingPackVersion>
<DefaultRuntimeFrameworkVersion>$(MicrosoftAspNetCoreAppRefPackageVersion)</DefaultRuntimeFrameworkVersion>
</KnownFrameworkReference>
Expand Down
31 changes: 14 additions & 17 deletions src/Layout/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
<IsRPMBasedDistro Condition="$(HostRid.StartsWith('centos'))">true</IsRPMBasedDistro>
</PropertyGroup>

<Import Project="$(RepositoryEngineeringDir)common\native\NativeAotSupported.props" />

<PropertyGroup>
<!--
Whether to publish the dotnet-aot NativeAOT shared library (see the PublishDotnetAot target
Expand All @@ -22,13 +24,12 @@
NativeAOT can produce the dotnet-aot library for the build host's operating system, either
natively (targeting the host architecture) or cross-compiling to another architecture of the
*same* OS. Cross-compilation across operating systems is not supported. We therefore publish
for supported win/linux/osx RIDs whenever the target OS equals the build host OS:
for supported Windows, Linux, and macOS RIDs whenever the target OS equals the build host OS.
PortableTargetRid is used for platform checks because Source Build can use a distro-specific
TargetRid (for example, azurelinux.3-x64) while its portable parent is linux-x64:
* native builds, where the target architecture matches the build host architecture
(TargetArchitecture == BuildArchitecture). We do not compare TargetRid == HostRid
directly: on Linux HostRid is the distro-specific RID (e.g. azurelinux.3-x64) while
TargetRid is the portable RID (e.g. linux-x64), so an exact comparison fails even for a
native build. TargetArchitecture vs BuildArchitecture is the canonical native-vs-cross
signal across all platforms.
(TargetArchitecture == BuildArchitecture). TargetArchitecture vs BuildArchitecture is
the canonical native-vs-cross signal across all platforms.
Comment thread
baronfel marked this conversation as resolved.
* same-OS cross-arch builds, where NativeAOT targets a different architecture from the build
host (TargetArchitecture != BuildArchitecture). This is supported on all three operating
systems: win-x64 -> win-arm64 and osx-x64 -> osx-arm64 (clang/link are multi-target and
Expand All @@ -37,17 +38,15 @@
inputs (CrossBuild/TargetArchitecture/TargetRid) are forwarded to the child dotnet-aot
Publish in GenerateLayout.targets; ROOTFS_DIR flows via the environment on Linux.
-->
Comment thread
baronfel marked this conversation as resolved.
Outdated
<_DotnetAotTargetRidSupported Condition="$(TargetRid.StartsWith('win')) or $(TargetRid.StartsWith('linux')) or $(TargetRid.StartsWith('osx'))">true</_DotnetAotTargetRidSupported>
<_DotnetAotTargetOSSupported Condition="'$(TargetOS)' == 'windows' or '$(TargetOS)' == 'linux' or '$(TargetOS)' == 'osx'">true</_DotnetAotTargetOSSupported>

<!-- The target OS (from the TargetRid prefix) equals the build host OS. NativeAOT can only
target the host OS, so this is a prerequisite for both native and cross-arch publishing. -->
<_DotnetAotIsSameOSBuild Condition="$([MSBuild]::IsOSPlatform('WINDOWS')) and $(TargetRid.StartsWith('win'))">true</_DotnetAotIsSameOSBuild>
<_DotnetAotIsSameOSBuild Condition="$([MSBuild]::IsOSPlatform('OSX')) and $(TargetRid.StartsWith('osx'))">true</_DotnetAotIsSameOSBuild>
<_DotnetAotIsSameOSBuild Condition="$([MSBuild]::IsOSPlatform('LINUX')) and $(TargetRid.StartsWith('linux'))">true</_DotnetAotIsSameOSBuild>
<!-- The target OS equals the build host OS. NativeAOT can only target the host OS, so this is
a prerequisite for both native and cross-arch publishing. -->
<_DotnetAotIsSameOSBuild Condition="'$(TargetOS)' == '$(HostOS)'">true</_DotnetAotIsSameOSBuild>

<!-- Native: same OS and same architecture as the build host (and not an explicit cross-build).
linux-musl is excluded because its NativeAOT toolchain is not wired up here. -->
<_DotnetAotIsNativeBuild Condition="'$(_DotnetAotIsSameOSBuild)' == 'true' and '$(TargetArchitecture)' == '$(BuildArchitecture)' and '$(CrossBuild)' != 'true' and '$(DotNetBuildSourceOnly)' != 'true' and !$(TargetRid.StartsWith('linux-musl'))">true</_DotnetAotIsNativeBuild>
<_DotnetAotIsNativeBuild Condition="'$(_DotnetAotIsSameOSBuild)' == 'true' and '$(TargetArchitecture)' == '$(BuildArchitecture)' and '$(CrossBuild)' != 'true' and '$(OSName)' != 'linux-musl'">true</_DotnetAotIsNativeBuild>

<!-- Cross: same OS but a different architecture from the build host. On Windows/macOS the cross
toolchain (MSVC arm64 linker / clang) is multi-target, so an architecture mismatch alone is
Expand All @@ -56,9 +55,9 @@
azurelinux cross-prereq container (providing clang + the sysroot via ROOTFS_DIR). Without
that guard the regular linux-arm64 legs (e.g. TestBuild), which build on the x64 pool with
no arm64 sysroot, would try to cross-link and fail. -->
<_DotnetAotIsCrossBuild Condition="'$(_DotnetAotIsSameOSBuild)' == 'true' and '$(TargetArchitecture)' != '$(BuildArchitecture)' and '$(DotNetBuildSourceOnly)' != 'true' and !$(TargetRid.StartsWith('linux-musl')) and !($(TargetRid.StartsWith('linux')) and '$(CrossBuild)' != 'true')">true</_DotnetAotIsCrossBuild>
<_DotnetAotIsCrossBuild Condition="'$(_DotnetAotIsSameOSBuild)' == 'true' and '$(TargetArchitecture)' != '$(BuildArchitecture)' and '$(OSName)' != 'linux-musl' and !('$(TargetOS)' == 'linux' and '$(CrossBuild)' != 'true')">true</_DotnetAotIsCrossBuild>

<_ShouldPublishDotnetAot Condition="'$(_ShouldPublishDotnetAot)' == '' and '$(_DotnetAotTargetRidSupported)' == 'true' and ('$(_DotnetAotIsNativeBuild)' == 'true' or '$(_DotnetAotIsCrossBuild)' == 'true')">true</_ShouldPublishDotnetAot>
<_ShouldPublishDotnetAot Condition="'$(_ShouldPublishDotnetAot)' == '' and '$(_DotnetAotTargetOSSupported)' == 'true' and '$(NativeAotSupported)' == 'true' and '$(DotNetBuildUseMonoRuntime)' != 'true' and ('$(_DotnetAotIsNativeBuild)' == 'true' or '$(_DotnetAotIsCrossBuild)' == 'true')">true</_ShouldPublishDotnetAot>
<_ShouldPublishDotnetAot Condition="'$(_ShouldPublishDotnetAot)' == ''">false</_ShouldPublishDotnetAot>
</PropertyGroup>

Expand Down Expand Up @@ -98,8 +97,6 @@
)">true</SkipBuildingInstallers>
</PropertyGroup>

<Import Project="$(RepositoryEngineeringDir)common\native\NativeAotSupported.props" />

<PropertyGroup>
<GenerateSdkBundleOnly Condition="'$(DotNetBuildPass)' == '3' and '$(OS)' == 'Windows_NT'">true</GenerateSdkBundleOnly>
<BundleRuntimePacks Condition="'$(BundleRuntimePacks)' == '' and '$(DotNetBuildSourceOnly)' == 'true'">true</BundleRuntimePacks>
Expand Down
8 changes: 4 additions & 4 deletions src/Layout/redist/redist.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@
race over shared bin\ and obj\ directories. This ProjectReference sequences the outer
Build to complete before redist's GenerateSdkLayout target runs.

Conditioned on the same check as the PublishDotnetAot target itself (_ShouldPublishDotnetAot);
when NativeAOT publish doesn't run (e.g. source-build with TargetRid like centos.10-x64),
pulling dotnet-aot.csproj into the restore graph would demand the ILCompiler RID-specific
runtime pack, which isn't available from source-built feeds (NU1100). -->
Conditioned on the same check as the PublishDotnetAot target itself (_ShouldPublishDotnetAot)
so unsupported target platforms don't pull NativeAOT compiler/runtime packs into the restore
graph. Supported Source Build configurations produce these packs from source and retain this
project reference. -->
<ProjectReference Include="$(RepoRoot)src\Cli\dotnet-aot\dotnet-aot.csproj"
Condition="'$(_ShouldPublishDotnetAot)' == 'true'"
ReferenceOutputAssembly="false" SkipGetTargetFrameworkProperties="true" Private="false" />
Expand Down
21 changes: 10 additions & 11 deletions src/Layout/redist/targets/GenerateLayout.targets
Original file line number Diff line number Diff line change
Expand Up @@ -532,11 +532,11 @@
them entirely in native code, falling back to the managed dotnet.dll for other commands.
The output is placed next to dotnet.dll so it's packaged with the SDK.

Runs for native builds (target OS/arch match the build host) on supported platforms, and for
same-OS cross-arch builds where NativeAOT targets a different architecture from the build host
(win-x64 -> win-arm64, osx-x64 -> osx-arm64, and Linux via the azurelinux cross containers that
provide a cross toolchain and target sysroot via ROOTFS_DIR). See the _ShouldPublishDotnetAot
property in src/Layout/Directory.Build.props.
Runs for native builds (target OS/arch match the build host) on supported platforms, including
Source Build with a distro-specific RID, and for same-OS cross-arch builds where NativeAOT targets
a different architecture from the build host (win-x64 -> win-arm64, osx-x64 -> osx-arm64, and
Linux via the azurelinux cross containers that provide a cross toolchain and target sysroot via
ROOTFS_DIR). See the _ShouldPublishDotnetAot property in src/Layout/Directory.Build.props.
-->
<Target Name="PublishDotnetAot"
Condition="'$(_ShouldPublishDotnetAot)' == 'true'">
Expand All @@ -550,14 +550,13 @@

<!--
Global properties for the dotnet-aot Publish below. _IsPublishing=true is always required
(see the note below). For same-OS cross-arch builds (win/osx/linux) we also forward the
cross-compilation inputs: the MSBuild task doesn't flow the outer build's global properties
to the child project, so CrossBuild and the target architecture/RID must be passed
explicitly. On Linux the child then maps SysRoot from the ROOTFS_DIR environment variable
via LocateNativeCompiler.targets; on Windows/macOS no sysroot is needed.
(see the note below). The outer build's target properties are already global and are inherited
by the MSBuild task. Same-OS cross-arch builds only need CrossBuild=true added explicitly. On
Linux the child maps SysRoot from the ROOTFS_DIR environment variable via
LocateNativeCompiler.targets; on Windows/macOS no sysroot is needed.
-->
<_DotnetAotPublishProperties>_IsPublishing=true</_DotnetAotPublishProperties>
<_DotnetAotPublishProperties Condition="'$(_DotnetAotIsCrossBuild)' == 'true'">$(_DotnetAotPublishProperties);CrossBuild=true;TargetArchitecture=$(TargetArchitecture);TargetRid=$(TargetRid)</_DotnetAotPublishProperties>
<_DotnetAotPublishProperties Condition="'$(_DotnetAotIsCrossBuild)' == 'true'">$(_DotnetAotPublishProperties);CrossBuild=true</_DotnetAotPublishProperties>
</PropertyGroup>

<!--
Expand Down
Loading