Skip to content

Commit

Permalink
[builds] Automatically apply dotnet/runtime#85966.
Browse files Browse the repository at this point in the history
  • Loading branch information
rolfbjarne committed Jun 9, 2023
1 parent c698d16 commit 1b3a525
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 0 deletions.
100 changes: 100 additions & 0 deletions builds/85996-modified.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
From c11fa2be22891658a849b9320664057a7c433487 Mon Sep 17 00:00:00 2001
From: Filip Navara <navara@emclient.com>
Date: Tue, 9 May 2023 19:20:19 +0200
Subject: [PATCH] Update ILCompiler paths to handle
PublishAotUsingRuntimePack=true

---
.../Microsoft.NETCore.Native.Publish.targets | 4 +--
.../Microsoft.NETCore.Native.Unix.targets | 10 +++----
.../Microsoft.NETCore.Native.targets | 27 ++++++++++++++-----
3 files changed, 28 insertions(+), 13 deletions(-)

diff --git a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Publish.targets b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Publish.targets
index 6f672918b33e0..be1fbde77efc9 100644
--- a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Publish.targets
+++ b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Publish.targets
@@ -70,8 +70,8 @@
Text="Add a PackageReference for '$(_hostPackageName)' to allow cross-compilation for $(_targetArchitecture)" />

<!-- NativeAOT runtime pack assemblies need to be defined to avoid the default CoreCLR implementations being set as compiler inputs -->
- <Error Condition="'@(PrivateSdkAssemblies)' == ''" Text="The PrivateSdkAssemblies ItemGroup is required for _ComputeAssembliesToCompileToNative" />
- <Error Condition="'@(FrameworkAssemblies)' == ''" Text="The FrameworkAssemblies ItemGroup is required for _ComputeAssembliesToCompileToNative" />
+ <Error Condition="'@(PrivateSdkAssemblies)' == '' and '$(PublishAotUsingRuntimePack)' != 'true'" Text="The PrivateSdkAssemblies ItemGroup is required for _ComputeAssembliesToCompileToNative" />
+ <Error Condition="'@(FrameworkAssemblies)' == '' and '$(PublishAotUsingRuntimePack)' != 'true'" Text="The FrameworkAssemblies ItemGroup is required for _ComputeAssembliesToCompileToNative" />

<ComputeManagedAssembliesToCompileToNative
Assemblies="@(_ResolvedCopyLocalPublishAssets)"
diff --git a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets
index bb457c8c166bc..6b6b59ab7967b 100644
--- a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets
+++ b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets
@@ -53,11 +53,11 @@ The .NET Foundation licenses this file to you under the MIT license.

<ItemGroup>
<NativeLibrary Condition="'$(IlcMultiModule)' == 'true'" Include="$(SharedLibrary)" />
- <NativeLibrary Condition="'$(NativeLib)' == '' and '$(CustomNativeMain)' != 'true'" Include="$(IlcSdkPath)libbootstrapper.a" />
- <NativeLibrary Condition="'$(NativeLib)' != '' or '$(CustomNativeMain)' == 'true'" Include="$(IlcSdkPath)libbootstrapperdll.a" />
- <NativeLibrary Include="$(IlcSdkPath)$(FullRuntimeName).a" />
- <NativeLibrary Include="$(IlcSdkPath)$(EventPipeName)$(LibFileExt)" />
- <NativeLibrary Condition="'$(LinkStandardCPlusPlusLibrary)' != 'true' and '$(StaticICULinking)' != 'true'" Include="$(IlcSdkPath)libstdc++compat.a" />
+ <NativeLibrary Condition="'$(NativeLib)' == '' and '$(CustomNativeMain)' != 'true'" Include="$(IlcFrameworkSdkPath)libbootstrapper.a" />
+ <NativeLibrary Condition="'$(NativeLib)' != '' or '$(CustomNativeMain)' == 'true'" Include="$(IlcFrameworkSdkPath)libbootstrapperdll.a" />
+ <NativeLibrary Include="$(IlcFrameworkSdkPath)$(FullRuntimeName).a" />
+ <NativeLibrary Include="$(IlcFrameworkSdkPath)$(EventPipeName)$(LibFileExt)" />
+ <NativeLibrary Condition="'$(LinkStandardCPlusPlusLibrary)' != 'true' and '$(StaticICULinking)' != 'true'" Include="$(IlcFrameworkSdkPath)libstdc++compat.a" />
</ItemGroup>

<ItemGroup>
diff --git a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets
index fbcadcc71b597..afa1cc1a66b9f 100644
--- a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets
+++ b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets
@@ -126,26 +126,41 @@ The .NET Foundation licenses this file to you under the MIT license.

<!-- The properties below need to be defined only after we've found the correct runtime package reference -->
<Target Name="SetupProperties" DependsOnTargets="$(IlcSetupPropertiesDependsOn)" BeforeTargets="Publish">
+ <ItemGroup>
+ <_NETCoreAppFrameworkReference Include="@(ResolvedFrameworkReference)" Condition="'%(ResolvedFrameworkReference.RuntimePackName)' == 'Microsoft.NETCore.App.Runtime.NativeAOT.$(RuntimeIdentifier)'" />
+ </ItemGroup>
+
<PropertyGroup>
<!-- Define paths used in build targets to point to the runtime-specific ILCompiler implementation -->
<IlcToolsPath Condition="'$(IlcToolsPath)' == ''">$(IlcHostPackagePath)\tools\</IlcToolsPath>
<IlcSdkPath Condition="'$(IlcSdkPath)' == ''">$(RuntimePackagePath)\sdk\</IlcSdkPath>
- <IlcFrameworkPath Condition="'$(IlcFrameworkPath)' == ''">$(RuntimePackagePath)\framework\</IlcFrameworkPath>
- <IlcFrameworkNativePath Condition="'$(IlcFrameworkNativePath)' == ''">$(RuntimePackagePath)\framework\</IlcFrameworkNativePath>
+ <IlcFrameworkPath Condition="'$(IlcFrameworkPath)' == '' and '$(PublishAotUsingRuntimePack)' != 'true'">$(RuntimePackagePath)\framework\</IlcFrameworkPath>
+ <_NETCoreAppRuntimePackPath>%(_NETCoreAppFrameworkReference.RuntimePackPath)/runtimes/$(RuntimeIdentifier)/</_NETCoreAppRuntimePackPath>
+ <IlcFrameworkNativePath Condition="'$(IlcFrameworkNativePath)' == '' and '$(PublishAotUsingRuntimePack)' == 'true'">$(_NETCoreAppRuntimePackPath)\native\</IlcFrameworkNativePath>
+ <IlcFrameworkNativePath Condition="'$(IlcFrameworkNativePath)' == '' and '$(PublishAotUsingRuntimePack)' != 'true'">$(RuntimePackagePath)\framework\</IlcFrameworkNativePath>
+ <IlcFrameworkSdkPath Condition="'$(IlcFrameworkSdkPath)' == '' and '$(PublishAotUsingRuntimePack)' == 'true'">$(IlcFrameworkNativePath)</IlcFrameworkSdkPath>
+ <IlcFrameworkSdkPath Condition="'$(IlcFrameworkSdkPath)' == '' and '$(PublishAotUsingRuntimePack)' != 'true'">$(IlcSdkPath)</IlcFrameworkSdkPath>
<IlcMibcPath Condition="'$(IlcMibcPath)' == ''">$(RuntimePackagePath)\mibc\</IlcMibcPath>
</PropertyGroup>

- <ItemGroup>
- <PrivateSdkAssemblies Include="$(IlcSdkPath)*.dll" />
+ <ItemGroup Condition="'$(PublishAotUsingRuntimePack)' == 'true'">
+ <PrivateSdkAssemblies Include="$(IlcFrameworkSdkPath)*.dll"/>
+ <FrameworkAssemblies Include="@(RuntimePackAsset)" Condition="'%(Extension)' == '.dll'" />
+ <DefaultFrameworkAssemblies Include="@(FrameworkAssemblies)" />
+ </ItemGroup>

+ <ItemGroup Condition="'$(PublishAotUsingRuntimePack)' != 'true'">
+ <PrivateSdkAssemblies Include="$(IlcFrameworkSdkPath)*.dll"/>
<!-- Exclude unmanaged dlls -->
<FrameworkAssemblies Include="$(IlcFrameworkPath)*.dll" Exclude="$(IlcFrameworkPath)*.Native.dll;$(IlcFrameworkPath)msquic.dll" />

- <MibcFile Include="$(IlcMibcPath)*.mibc" Condition="'$(IlcPgoOptimize)' == 'true'" />
-
<DefaultFrameworkAssemblies Include="@(FrameworkAssemblies)" />
<DefaultFrameworkAssemblies Include="@(PrivateSdkAssemblies)" />
</ItemGroup>
+
+ <ItemGroup>
+ <MibcFile Include="$(IlcMibcPath)*.mibc" Condition="'$(IlcPgoOptimize)' == 'true'" />
+ </ItemGroup>
</Target>

<Target Name="ComputeIlcCompileInputs" DependsOnTargets="$(IlcDynamicBuildPropertyDependencies)" BeforeTargets="Publish">
10 changes: 10 additions & 0 deletions builds/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,15 @@ dotnet-install.sh: Makefile
fix-maccatalyst-assembly/bin/Debug/fix-maccatalyst-assembly.exe: $(wildcard fix-maccatalyst-assembly/*.cs*) Makefile
$(Q) $(SYSTEM_MSBUILD) "/bl:$@.binlog" /r fix-maccatalyst-assembly/fix-maccatalyst-assembly.csproj $(MSBUILD_VERBOSITY)

apply-filip-patch:
$(Q) $(MAKE) .stamp-apply-filip-patch-$(DOTNET_VERSION)

.stamp-apply-filip-patch-$(DOTNET_VERSION):
$(Q) cd $(abspath $(TOP)/packages/microsoft.dotnet.ilcompiler/$(BUNDLED_NETCORE_PLATFORMS_PACKAGE_VERSION)/build) && git init . && git config user.email "temporary@example.com" && git config user.name "Temporary" && git add . && git commit -m "Start" && cat $(CURDIR)/85996-modified.patch | git am -p 5 --ignore-space-change
$(Q) cd $(abspath $(TOP)/packages/runtime.osx-x64.microsoft.dotnet.ilcompiler/$(BUNDLED_NETCORE_PLATFORMS_PACKAGE_VERSION)/build) && git init . && git config user.email "temporary@example.com" && git config user.name "Temporary" && git add . && git commit -m "Start" && cat $(CURDIR)/85996-modified.patch | git am -p 5 --ignore-space-change
$(Q) touch $@
$(Q) echo "Applied Filip's fixes"

define FixMacCatalystAssembly
$(MONO_MACCATALYST_SDK_DESTDIR)/maccat-bcl/monotouch/$(1).dll: .stamp-$(MONO_BUILD_MODE)

Expand Down Expand Up @@ -161,6 +170,7 @@ package-download/all-package-references.csproj: $(TOP)/.git/HEAD $(TOP)/.git/ind
/bl \
$(DOTNET_BUILD_VERBOSITY)
$(MAKE) .stamp-install-custom-dotnet-runtime-workloads
$(Q) make apply-filip-patch
$(Q) touch $@

.stamp-install-t4: $(TOP)/.config/dotnet-tools.json .stamp-download-dotnet-packages
Expand Down
5 changes: 5 additions & 0 deletions builds/package-download/download-packages.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@

<!-- and get the emscripten workload(s) as well -->
<PackageDownload Include="Microsoft.NET.Workload.Emscripten.net7.Manifest-$(EmscriptenManifestVersionBand)" Version="[$(Emscriptennet7WorkloadVersion)]" Condition="'$(TrackingDotNetRuntimeSeparately)' != ''" />


<!-- ILCompiler -->
<PackageDownload Include="Microsoft.DotNet.ILCompiler" Version="[$(ActualPackageVersion)]" />
<PackageDownload Include="Runtime.osx-x64.Microsoft.DotNet.ILCompiler" Version="[$(ActualPackageVersion)]" />
</ItemGroup>

<Import Project="all-package-references.csproj" />
Expand Down

0 comments on commit 1b3a525

Please sign in to comment.