Add check for tizen in ilc and crossgen2 (#90310)
[platform/upstream/dotnet/runtime.git] / src / coreclr / tools / aot / ILCompiler / ILCompiler.csproj
1 <Project Sdk="Microsoft.NET.Sdk">
2   <PropertyGroup>
3     <OutputPath>$(RuntimeBinDir)ilc/</OutputPath>
4     <RuntimeIdentifier>$(PackageRID)</RuntimeIdentifier>
5   </PropertyGroup>
6
7   <Import Project="ILCompiler.props" />
8
9
10   <!-- BEGIN: Workaround for https://github.com/dotnet/runtime/issues/67742 -->
11   <PropertyGroup Condition="'$(BuildingInsideVisualStudio)' != 'true'">
12     <PublishDir>$(RuntimeBinDir)ilc-published/</PublishDir>
13     <!-- Can't use NativeAOT in source build yet https://github.com/dotnet/runtime/issues/66859 -->
14     <NativeAotSupported Condition="'$(DotNetBuildFromSource)' == 'true'">false</NativeAotSupported>
15     <NativeAotSupported Condition="$(OutputRID.StartsWith('tizen')) == 'true'">false</NativeAotSupported>
16     <!-- Disable native AOT on FreeBSD when cross building from Linux. -->
17     <NativeAotSupported Condition="'$(TargetOS)' == 'freebsd' and '$(CrossBuild)' == 'true'">false</NativeAotSupported>
18     <PublishAot Condition="'$(NativeAotSupported)' == 'true'">true</PublishAot>
19     <SysRoot Condition="'$(NativeAotSupported)' == 'true' and '$(CrossBuild)' == 'true' and '$(HostOS)' != 'windows'">$(ROOTFS_DIR)</SysRoot>
20     <PublishReadyToRun Condition="'$(NativeAotSupported)' != 'true'">true</PublishReadyToRun>
21     <PublishSingleFile Condition="'$(NativeAotSupported)' != 'true'">true</PublishSingleFile>
22     <PublishTrimmed Condition="'$(NativeAotSupported)' != 'true'">true</PublishTrimmed>
23     <SuppressGenerateILCompilerExplicitPackageReferenceWarning>true</SuppressGenerateILCompilerExplicitPackageReferenceWarning>
24     <!-- Compute host package name (taken from Microsoft.DotNet.ILCompiler.SingleEntry.targets) -->
25     <_hostOS>$(NETCoreSdkPortableRuntimeIdentifier.SubString(0, $(NETCoreSdkPortableRuntimeIdentifier.LastIndexOf('-'))))</_hostOS>
26     <_hostArchitecture Condition="'$(OS)' != 'Windows_NT'">$(NETCoreSdkPortableRuntimeIdentifier.SubString($([MSBuild]::Add($(NETCoreSdkPortableRuntimeIdentifier.LastIndexOf('-')), 1))))</_hostArchitecture>
27     <_hostArchitecture Condition="'$(OS)' == 'Windows_NT'">$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture.ToString().ToLowerInvariant)</_hostArchitecture>
28     <_hostPackageName>runtime.$(_hostOS)-$(_hostArchitecture).Microsoft.DotNet.ILCompiler</_hostPackageName>
29   </PropertyGroup>
30
31   <ItemGroup Condition="'$(NativeAotSupported)' == 'true'">
32     <PackageReference Include="Microsoft.DotNet.ILCompiler" Version="$(MicrosoftDotNetILCompilerVersion)" />
33     <PackageReference Include="$(_hostPackageName)" Version="$(MicrosoftDotNetILCompilerVersion)" />
34   </ItemGroup>
35
36   <!-- Needed for the amd64 -> amd64 musl cross-build to pass the target flag. -->
37   <Target Name="_FixIlcTargetTriple"
38           AfterTargets="SetupOSSpecificProps"
39           Condition="'$(CrossBuild)' == 'true' and '$(HostOS)' != 'windows'">
40     <!-- Compute CrossCompileRid, and copy the downstream logic as-is. -->
41     <PropertyGroup>
42       <CrossCompileRid>$(RuntimeIdentifier)</CrossCompileRid>
43
44       <CrossCompileArch />
45       <CrossCompileArch Condition="$(CrossCompileRid.EndsWith('-x64'))">x86_64</CrossCompileArch>
46       <CrossCompileArch Condition="$(CrossCompileRid.EndsWith('-arm64')) and '$(_IsApplePlatform)' != 'true'">aarch64</CrossCompileArch>
47       <CrossCompileArch Condition="$(CrossCompileRid.EndsWith('-arm64')) and '$(_IsApplePlatform)' == 'true'">arm64</CrossCompileArch>
48
49       <TargetTriple />
50       <TargetTriple Condition="'$(CrossCompileArch)' != ''">$(CrossCompileArch)-linux-gnu</TargetTriple>
51       <TargetTriple Condition="'$(CrossCompileArch)' != '' and ($(CrossCompileRid.StartsWith('linux-musl')) or $(CrossCompileRid.StartsWith('alpine')))">$(CrossCompileArch)-alpine-linux-musl</TargetTriple>
52       <TargetTriple Condition="'$(CrossCompileArch)' != '' and ($(CrossCompileRid.StartsWith('freebsd')))">$(CrossCompileArch)-unknown-freebsd12</TargetTriple>
53     </PropertyGroup>
54
55     <ItemGroup>
56       <LinkerArg Include="--target=$(TargetTriple)" Condition="'$(_IsApplePlatform)' != 'true' and '$(TargetTriple)' != ''" />
57     </ItemGroup>
58   </Target>
59
60   <Target Name="LocateNativeCompiler"
61           Condition="'$(NativeAotSupported)' == 'true' and '$(HostOS)' != 'windows'"
62           BeforeTargets="SetupOSSpecificProps">
63     <PropertyGroup>
64       <CppCompilerAndLinker Condition="'$(CppCompilerAndLinker)' == ''">clang</CppCompilerAndLinker>
65     </PropertyGroup>
66
67     <Exec Command="sh -c 'build_arch=&quot;$(TargetArchitecture)&quot; compiler=&quot;$(CppCompilerAndLinker)&quot; . &quot;$(RepositoryEngineeringDir)/common/native/init-compiler.sh&quot; &amp;&amp; echo &quot;$CC;$LDFLAGS&quot;' 2>/dev/null"
68           EchoOff="true"
69           ConsoleToMsBuild="true"
70           StandardOutputImportance="Low">
71       <Output TaskParameter="ConsoleOutput" PropertyName="_CC_LDFLAGS" />
72     </Exec>
73
74     <PropertyGroup>
75       <CppLinker>$(_CC_LDFLAGS.SubString(0, $(_CC_LDFLAGS.IndexOf(';'))))</CppLinker>
76       <_LDFLAGS>$(_CC_LDFLAGS.SubString($([MSBuild]::Add($(_CC_LDFLAGS.IndexOf(';')), 1))))</_LDFLAGS>
77       <LinkerFlavor Condition="$(_LDFLAGS.Contains('lld'))">lld</LinkerFlavor>
78     </PropertyGroup>
79   </Target>
80
81   <ItemGroup Condition="'$(NativeAotSupported)' == 'true'">
82     <CustomLinkerArg Condition="'$(CrossBuild)' == 'true' and '$(_hostArchitecture)' == '$(_targetArchitecture)' and '$(_hostOS)' != 'windows' and '$(_IsApplePlatform)' != 'true'" Include="--gcc-toolchain=$(ROOTFS_DIR)/usr" />
83   </ItemGroup>
84
85   <Target Name="PublishCompiler"
86           Condition="'$(BuildingInsideVisualStudio)' != 'true'"
87           AfterTargets="Build"
88           DependsOnTargets="Publish;StompSingleFileHostPath" />
89
90   <!--  HACK: liveBuilds stomps over SingleFileHostSourcePath, setting it to the host that we just built.
91         That's unfortunate because it's not the host we're supposed to use here. -->
92   <Target Name="StompSingleFileHostPath"
93           BeforeTargets="ResolveFrameworkReferences">
94     <PropertyGroup>
95       <SingleFileHostSourcePath></SingleFileHostSourcePath>
96     </PropertyGroup>
97   </Target>
98   <!-- END: Workaround for https://github.com/dotnet/runtime/issues/67742 -->
99 </Project>