Skip to content

Commit 596a1f7

Browse files
authored
ILCompiler: support publishing using a non-portable ILCompiler build. (#99148)
* ILCompiler: support publishing using a non-portable ILCompiler build. * Use HostOS from top-level Directory.Build.props. * And same for BuildArchitecture.
1 parent fde0fd3 commit 596a1f7

File tree

5 files changed

+9
-13
lines changed

5 files changed

+9
-13
lines changed

src/coreclr/nativeaot/BuildIntegration/Microsoft.DotNet.ILCompiler.SingleEntry.targets

+6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
<!-- Define the name of the runtime specific compiler package to import -->
55
<_hostOS>$(NETCoreSdkPortableRuntimeIdentifier.SubString(0, $(NETCoreSdkPortableRuntimeIdentifier.LastIndexOf('-'))))</_hostOS>
66

7+
<_targetsNonPortableSdkRid>false</_targetsNonPortableSdkRid>
8+
<_targetsNonPortableSdkRid Condition="'$(RuntimeIdentifier)' == '$(NETCoreSdkRuntimeIdentifier)' and '$(RuntimeIdentifier)' != '$(NETCoreSdkPortableRuntimeIdentifier)'">true</_targetsNonPortableSdkRid>
9+
710
<_originalTargetOS>$(RuntimeIdentifier.SubString(0, $(RuntimeIdentifier.LastIndexOf('-'))))</_originalTargetOS>
11+
<_originalTargetOS Condition="'$(_targetsNonPortableSdkRid)' == 'true'">$(NETCoreSdkPortableRuntimeIdentifier.SubString(0, $(NETCoreSdkPortableRuntimeIdentifier.LastIndexOf('-'))))</_originalTargetOS>
812
<_originalTargetOS Condition="$(_originalTargetOS.Contains('.'))">$(_originalTargetOS.SubString(0, $(_originalTargetOS.IndexOf('.'))))</_originalTargetOS>
913
<_originalTargetOS Condition="$(_originalTargetOS.StartsWith('win'))">win</_originalTargetOS>
1014

@@ -17,7 +21,9 @@
1721
<_targetArchitecture>$(RuntimeIdentifier.SubString($([MSBuild]::Add($(RuntimeIdentifier.LastIndexOf('-')), 1))))</_targetArchitecture>
1822

1923
<_hostPackageName>runtime.$(_hostOS)-$(_hostArchitecture).Microsoft.DotNet.ILCompiler</_hostPackageName>
24+
<_hostPackageName Condition="'$(_targetsNonPortableSdkRid)' == 'true'">runtime.$(RuntimeIdentifier).Microsoft.DotNet.ILCompiler</_hostPackageName>
2025
<_targetPackageName>runtime.$(_originalTargetOS)-$(_targetArchitecture).Microsoft.DotNet.ILCompiler</_targetPackageName>
26+
<_targetPackageName Condition="'$(_targetsNonPortableSdkRid)' == 'true'">runtime.$(RuntimeIdentifier).Microsoft.DotNet.ILCompiler</_targetPackageName>
2127

2228
<!-- Treat linux-musl and linux-bionic etc. as linux -->
2329
<_targetOS>$(_originalTargetOS)</_targetOS>

src/coreclr/tools/aot/ILCompiler/ILCompiler.csproj

+2-9
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
<!-- BEGIN: Workaround for https://github.com/dotnet/runtime/issues/67742 -->
1111
<PropertyGroup Condition="'$(BuildingInsideVisualStudio)' != 'true'">
1212
<PublishDir>$(RuntimeBinDir)ilc-published/</PublishDir>
13-
<!-- Can't use NativeAOT in source build yet https://github.com/dotnet/runtime/issues/66859 -->
14-
<NativeAotSupported Condition="'$(DotNetBuildSourceOnly)' == 'true'">false</NativeAotSupported>
1513
<NativeAotSupported Condition="$(OutputRID.StartsWith('tizen')) == 'true'">false</NativeAotSupported>
1614
<NativeAotSupported Condition="$(OutputRID.EndsWith('-arm')) == 'true'">false</NativeAotSupported>
1715
<NativeAotSupported Condition="$(OutputRID.EndsWith('-x86')) == 'true'">false</NativeAotSupported>
@@ -23,16 +21,11 @@
2321
<PublishSingleFile Condition="'$(NativeAotSupported)' != 'true'">true</PublishSingleFile>
2422
<PublishTrimmed Condition="'$(NativeAotSupported)' != 'true'">true</PublishTrimmed>
2523
<SuppressGenerateILCompilerExplicitPackageReferenceWarning>true</SuppressGenerateILCompilerExplicitPackageReferenceWarning>
26-
<!-- Compute host package name (taken from Microsoft.DotNet.ILCompiler.SingleEntry.targets) -->
27-
<_hostOS>$(NETCoreSdkPortableRuntimeIdentifier.SubString(0, $(NETCoreSdkPortableRuntimeIdentifier.LastIndexOf('-'))))</_hostOS>
28-
<_hostArchitecture Condition="'$(OS)' != 'Windows_NT'">$(NETCoreSdkPortableRuntimeIdentifier.SubString($([MSBuild]::Add($(NETCoreSdkPortableRuntimeIdentifier.LastIndexOf('-')), 1))))</_hostArchitecture>
29-
<_hostArchitecture Condition="'$(OS)' == 'Windows_NT'">$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture.ToString().ToLowerInvariant)</_hostArchitecture>
30-
<_hostPackageName>runtime.$(_hostOS)-$(_hostArchitecture).Microsoft.DotNet.ILCompiler</_hostPackageName>
3124
</PropertyGroup>
3225

3326
<ItemGroup Condition="'$(NativeAotSupported)' == 'true'">
3427
<PackageReference Include="Microsoft.DotNet.ILCompiler" Version="$(MicrosoftDotNetILCompilerVersion)" />
35-
<PackageReference Include="$(_hostPackageName)" Version="$(MicrosoftDotNetILCompilerVersion)" />
28+
<PackageReference Include="runtime.$(ToolsRID).Microsoft.DotNet.ILCompiler" Version="$(MicrosoftDotNetILCompilerVersion)" />
3629
</ItemGroup>
3730

3831
<!-- Needed for the amd64 -> amd64 musl cross-build to pass the target flag. -->
@@ -94,7 +87,7 @@
9487
</Target>
9588

9689
<ItemGroup Condition="'$(NativeAotSupported)' == 'true'">
97-
<CustomLinkerArg Condition="'$(CrossBuild)' == 'true' and '$(_hostArchitecture)' == '$(_targetArchitecture)' and '$(_hostOS)' != 'windows' and '$(_IsApplePlatform)' != 'true'" Include="--gcc-toolchain=$(ROOTFS_DIR)/usr" />
90+
<CustomLinkerArg Condition="'$(CrossBuild)' == 'true' and '$(BuildArchitecture)' == '$(_targetArchitecture)' and '$(HostOS)' != 'windows' and '$(_IsApplePlatform)' != 'true'" Include="--gcc-toolchain=$(ROOTFS_DIR)/usr" />
9891
</ItemGroup>
9992

10093
<Target Name="PublishCompiler"

src/coreclr/tools/aot/crossgen2/crossgen2_publish.csproj

-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
88

99
<PropertyGroup>
10-
<!-- Can't use NativeAOT in non-portable build yet https://github.com/dotnet/runtime/issues/66859 -->
11-
<NativeAotSupported Condition="'$(PortableBuild)' != 'true'">false</NativeAotSupported>
1210
<NativeAotSupported Condition="$(OutputRID.StartsWith('tizen')) == 'true'">false</NativeAotSupported>
1311
<NativeAotSupported Condition="$(OutputRID.EndsWith('-arm')) == 'true'">false</NativeAotSupported>
1412
<NativeAotSupported Condition="$(OutputRID.EndsWith('-x86')) == 'true'">false</NativeAotSupported>

src/installer/pkg/projects/Microsoft.DotNet.ILCompiler/ILCompilerRIDs.props

+1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@
1414
<OfficialBuildRID Include="win-x64" Platform="x64" />
1515
<OfficialBuildRID Include="freebsd-x64" Platform="x64" />
1616
<OfficialBuildRID Include="freebsd-arm64" Platform="arm64" />
17+
<OfficialBuildRID Include="$(OutputRID)" Platform="$(TargetArchitecture)" Exclude="@(OfficialBuildRID)" />
1718
</ItemGroup>
1819
</Project>

src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Crossgen2.sfxproj

-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
<ShouldVerifyClosure>false</ShouldVerifyClosure>
1818
<!-- Publish crossgen2 as a single-file app on native-OS builds. Cross-OS NativeAOT compilation is not supported yet -->
1919
<NativeAotSupported Condition="'$(CrossBuild)' == 'true' and '$(TargetOS)' != '$(HostOS)'">false</NativeAotSupported>
20-
<!-- Can't use NativeAOT in source build yet https://github.com/dotnet/runtime/issues/66859 -->
21-
<NativeAotSupported Condition="'$(DotNetBuildSourceOnly)' == 'true'">false</NativeAotSupported>
2220
</PropertyGroup>
2321

2422
<ItemGroup>

0 commit comments

Comments
 (0)