From 478e01fadc05a006fbc503e8b0ec2062879233e6 Mon Sep 17 00:00:00 2001 From: Ivan Povazan Date: Tue, 23 May 2023 12:04:50 +0200 Subject: [PATCH 01/20] HelloiOS sample improvements and sync with main branch --- src/mono/sample/iOS-NativeAOT/Makefile | 2 ++ src/mono/sample/iOS-NativeAOT/Program.csproj | 13 +++++++------ .../Templates/CMakeLists.txt.template | 2 ++ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/mono/sample/iOS-NativeAOT/Makefile b/src/mono/sample/iOS-NativeAOT/Makefile index e1e295a75d9e7..33f13ba28832b 100644 --- a/src/mono/sample/iOS-NativeAOT/Makefile +++ b/src/mono/sample/iOS-NativeAOT/Makefile @@ -7,6 +7,7 @@ TARGET_ARCH?=$(shell . $(TOP)eng/native/init-os-and-arch.sh && echo $${arch}) TARGET_OS?=iossimulator DEPLOY_AND_RUN?=false STRIP_DEBUG_SYMBOLS?=false +RUNTIME_PACKS?=false REPO_DIR=$(realpath $(TOP)) TASKS_DIR=$(REPO_DIR)/src/tasks @@ -44,6 +45,7 @@ hello-app: clean -p:TargetArchitecture=$(TARGET_ARCH) \ -p:DeployAndRun=$(DEPLOY_AND_RUN) \ -p:StripDebugSymbols=$(STRIP_DEBUG_SYMBOLS) \ + -p:PublishAotUsingRuntimePack=$(RUNTIME_PACKS) \ -bl clean: diff --git a/src/mono/sample/iOS-NativeAOT/Program.csproj b/src/mono/sample/iOS-NativeAOT/Program.csproj index aa08743cddbab..c8b7daaab5469 100644 --- a/src/mono/sample/iOS-NativeAOT/Program.csproj +++ b/src/mono/sample/iOS-NativeAOT/Program.csproj @@ -14,8 +14,7 @@ static true true - - true + $(OutputPath)/publish @@ -23,6 +22,7 @@ + @@ -30,7 +30,7 @@ false - + @@ -40,8 +40,8 @@ $([MSBuild]::NormalizeDirectory('$(RepoRoot)', 'artifacts', 'bin', 'coreclr', '$(HostOS).$(BuildArchitecture).$(CoreCLRConfiguration)', 'ilc')) $(IlcPath) $(CoreCLRAotSdkDir) - $(LibrariesAllBinArtifactsPath) - $(LibrariesAllBinArtifactsPath) + $(LibrariesAllBinArtifactsPath) + $(LibrariesAllBinArtifactsPath) @@ -75,7 +75,8 @@ Optimized="$(Optimized)" InvariantGlobalization="$(InvariantGlobalization)" StripSymbolTable="$(StripDebugSymbols)" - AppDir="$(MSBuildThisFileDirectory)$(PublishDir)" > + AppDir="$(MSBuildThisFileDirectory)$(PublishDir)" + ExtraLinkerArguments="@(ExtraLinkerArguments)" > diff --git a/src/tasks/AppleAppBuilder/Templates/CMakeLists.txt.template b/src/tasks/AppleAppBuilder/Templates/CMakeLists.txt.template index a95bf1da9a550..29f0b6eae626c 100644 --- a/src/tasks/AppleAppBuilder/Templates/CMakeLists.txt.template +++ b/src/tasks/AppleAppBuilder/Templates/CMakeLists.txt.template @@ -82,6 +82,8 @@ target_link_libraries( if(%UseNativeAOTRuntime%) target_link_libraries( %ProjectName% + PRIVATE "-Wl,-u,_NativeAOT_StaticInitialization" + "-Wl,-segprot,__THUNKS,rx,rx" ) endif() \ No newline at end of file From 9ca9c3fc304c8f2a40c746f84f110ec263e4dedf Mon Sep 17 00:00:00 2001 From: Ivan Povazan Date: Tue, 23 May 2023 15:25:31 +0200 Subject: [PATCH 02/20] Fix the way we are passing extra linker arguments from AppleAppBuilder --- .../Templates/CMakeLists.txt.template | 13 +++++-------- src/tasks/AppleAppBuilder/Xcode.cs | 12 ++++-------- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/src/tasks/AppleAppBuilder/Templates/CMakeLists.txt.template b/src/tasks/AppleAppBuilder/Templates/CMakeLists.txt.template index 29f0b6eae626c..8bd0126f7d2aa 100644 --- a/src/tasks/AppleAppBuilder/Templates/CMakeLists.txt.template +++ b/src/tasks/AppleAppBuilder/Templates/CMakeLists.txt.template @@ -76,14 +76,11 @@ target_link_libraries( "-lc++" "-liconv" %NativeLibrariesToLink% -%APP_LINKER_ARGS% + %APP_LINK_LIBRARIES% ) -if(%UseNativeAOTRuntime%) -target_link_libraries( - %ProjectName% - PRIVATE - "-Wl,-u,_NativeAOT_StaticInitialization" - "-Wl,-segprot,__THUNKS,rx,rx" +set_target_properties( + %ProjectName% + PROPERTIES LINK_FLAGS + %EXTRA_LINKER_ARGS% ) -endif() \ No newline at end of file diff --git a/src/tasks/AppleAppBuilder/Xcode.cs b/src/tasks/AppleAppBuilder/Xcode.cs index 1937e46c10166..cb8a3e78e03ba 100644 --- a/src/tasks/AppleAppBuilder/Xcode.cs +++ b/src/tasks/AppleAppBuilder/Xcode.cs @@ -408,16 +408,12 @@ public string GenerateCMake( frameworks = "\"-framework GSS\""; } - string appLinkerArgs = ""; - foreach(string linkerArg in extraLinkerArgs) - { - appLinkerArgs += $" \"{linkerArg}\"{Environment.NewLine}"; - } - - appLinkerArgs += $" {frameworks}{Environment.NewLine}"; + string appLinkLibraries = $" {frameworks}{Environment.NewLine}"; + string extraLinkerArgsConcat = $"\"{string.Join('\n', extraLinkerArgs)}\""; cmakeLists = cmakeLists.Replace("%NativeLibrariesToLink%", toLink); - cmakeLists = cmakeLists.Replace("%APP_LINKER_ARGS%", appLinkerArgs); + cmakeLists = cmakeLists.Replace("%APP_LINK_LIBRARIES%", appLinkLibraries); + cmakeLists = cmakeLists.Replace("%EXTRA_LINKER_ARGS%", extraLinkerArgsConcat); cmakeLists = cmakeLists.Replace("%AotSources%", aotSources); cmakeLists = cmakeLists.Replace("%AotTargetsList%", aotList); cmakeLists = cmakeLists.Replace("%AotModulesSource%", string.IsNullOrEmpty(aotSources) ? "" : "modules.m"); From daa1c0c257d2f28b4627157558cfcd94afc578a0 Mon Sep 17 00:00:00 2001 From: Ivan Povazan Date: Tue, 23 May 2023 15:26:19 +0200 Subject: [PATCH 03/20] Use ILC collected linker arguments for bundling the application --- src/mono/sample/iOS-NativeAOT/Program.csproj | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/mono/sample/iOS-NativeAOT/Program.csproj b/src/mono/sample/iOS-NativeAOT/Program.csproj index c8b7daaab5469..cd61ba821c247 100644 --- a/src/mono/sample/iOS-NativeAOT/Program.csproj +++ b/src/mono/sample/iOS-NativeAOT/Program.csproj @@ -22,7 +22,6 @@ - @@ -56,14 +55,17 @@ - + <_LinkerFlagsToDrop Include="@(NativeFramework->'-framework %(Identity)')" /> + <_LinkerFlagsToDrop Include="@(LinkerArg)" Condition="$([System.String]::new('%(Identity)').Contains('swift'))" /> + + Date: Tue, 23 May 2023 15:39:06 +0200 Subject: [PATCH 04/20] Use better naming in the Makefile --- src/mono/sample/iOS-NativeAOT/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mono/sample/iOS-NativeAOT/Makefile b/src/mono/sample/iOS-NativeAOT/Makefile index 33f13ba28832b..4b3101cc3123f 100644 --- a/src/mono/sample/iOS-NativeAOT/Makefile +++ b/src/mono/sample/iOS-NativeAOT/Makefile @@ -7,7 +7,7 @@ TARGET_ARCH?=$(shell . $(TOP)eng/native/init-os-and-arch.sh && echo $${arch}) TARGET_OS?=iossimulator DEPLOY_AND_RUN?=false STRIP_DEBUG_SYMBOLS?=false -RUNTIME_PACKS?=false +USE_RUNTIME_PACKS?=false REPO_DIR=$(realpath $(TOP)) TASKS_DIR=$(REPO_DIR)/src/tasks @@ -45,7 +45,7 @@ hello-app: clean -p:TargetArchitecture=$(TARGET_ARCH) \ -p:DeployAndRun=$(DEPLOY_AND_RUN) \ -p:StripDebugSymbols=$(STRIP_DEBUG_SYMBOLS) \ - -p:PublishAotUsingRuntimePack=$(RUNTIME_PACKS) \ + -p:PublishAotUsingRuntimePack=$(USE_RUNTIME_PACKS) \ -bl clean: From c94e9f0dfc5338d024bdc8d345de27573070d445 Mon Sep 17 00:00:00 2001 From: Ivan Povazan Date: Tue, 23 May 2023 16:44:10 +0200 Subject: [PATCH 05/20] Prepare grounds for PublishAotUsingRuntimePack = true --- src/mono/sample/iOS-NativeAOT/Program.csproj | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/mono/sample/iOS-NativeAOT/Program.csproj b/src/mono/sample/iOS-NativeAOT/Program.csproj index cd61ba821c247..aae1380bad7b2 100644 --- a/src/mono/sample/iOS-NativeAOT/Program.csproj +++ b/src/mono/sample/iOS-NativeAOT/Program.csproj @@ -33,7 +33,7 @@ - + $([MSBuild]::NormalizeDirectory('$(RepoRoot)', 'artifacts', 'bin', 'coreclr', '$(HostOS).$(BuildArchitecture).$(CoreCLRConfiguration)', 'ilc')) @@ -44,6 +44,16 @@ + + + + + + + From 9afd5fb411acafa4d19db3ca2581257356db1d23 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Tue, 9 May 2023 19:20:19 +0200 Subject: [PATCH 06/20] 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)" /> - - + + - - - - - + + + + + diff --git a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets index 607028701561f..4367f3b560600 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. + + <_NETCoreAppFrameworkReference Include="@(ResolvedFrameworkReference)" Condition="'%(ResolvedFrameworkReference.RuntimePackName)' == 'Microsoft.NETCore.App.Runtime.NativeAOT.$(RuntimeIdentifier)'" /> + + $(IlcHostPackagePath)\tools\ $(RuntimePackagePath)\sdk\ - $(RuntimePackagePath)\framework\ - $(RuntimePackagePath)\framework\ + $(RuntimePackagePath)\framework\ + <_NETCoreAppRuntimePackPath>%(_NETCoreAppFrameworkReference.RuntimePackPath)/runtimes/$(RuntimeIdentifier)/ + $(_NETCoreAppRuntimePackPath)\native\ + $(RuntimePackagePath)\framework\ + $(IlcFrameworkNativePath) + $(IlcSdkPath) $(RuntimePackagePath)\mibc\ - - + + + + + + + - - + + + + From 5f2fe86ec85945233937b5ade23e68c2eacd87c9 Mon Sep 17 00:00:00 2001 From: Ivan Povazan Date: Tue, 23 May 2023 17:20:11 +0200 Subject: [PATCH 07/20] Enable using runtime pack from NuGet --- src/mono/sample/iOS-NativeAOT/Program.csproj | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/mono/sample/iOS-NativeAOT/Program.csproj b/src/mono/sample/iOS-NativeAOT/Program.csproj index aae1380bad7b2..31ea247997dd9 100644 --- a/src/mono/sample/iOS-NativeAOT/Program.csproj +++ b/src/mono/sample/iOS-NativeAOT/Program.csproj @@ -17,6 +17,7 @@ $(OutputPath)/publish + false @@ -44,16 +45,6 @@ - - - - - - - From 08126df51e697ea3d4ab47a8c24b771840e0c211 Mon Sep 17 00:00:00 2001 From: Ivan Povazan Date: Thu, 25 May 2023 12:03:19 +0200 Subject: [PATCH 08/20] Use publish instead --- src/mono/sample/iOS-NativeAOT/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/sample/iOS-NativeAOT/Makefile b/src/mono/sample/iOS-NativeAOT/Makefile index 4b3101cc3123f..599441ce3bf8a 100644 --- a/src/mono/sample/iOS-NativeAOT/Makefile +++ b/src/mono/sample/iOS-NativeAOT/Makefile @@ -40,7 +40,7 @@ appbuilder: hello-app: clean $(DOTNET) \ - build -c $(BUILD_CONFIG) \ + publish -c $(BUILD_CONFIG) \ -p:TargetOS=$(TARGET_OS) \ -p:TargetArchitecture=$(TARGET_ARCH) \ -p:DeployAndRun=$(DEPLOY_AND_RUN) \ From a8665cedfb92156d0151d8a060f126ee3d99882b Mon Sep 17 00:00:00 2001 From: Ivan Povazan Date: Tue, 23 May 2023 18:08:44 +0200 Subject: [PATCH 09/20] FIXME: revert once testing is finished --- global.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/global.json b/global.json index 49a2074ecc83d..d2f2cd248c57c 100644 --- a/global.json +++ b/global.json @@ -1,11 +1,11 @@ { "sdk": { - "version": "8.0.100-preview.4.23260.5", + "version": "8.0.100-preview.5.23267.7", "allowPrerelease": true, "rollForward": "major" }, "tools": { - "dotnet": "8.0.100-preview.4.23260.5" + "dotnet": "8.0.100-preview.5.23267.7" }, "msbuild-sdks": { "Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.23268.1", @@ -15,4 +15,4 @@ "Microsoft.Build.Traversal": "3.4.0", "Microsoft.NET.Sdk.IL": "8.0.0-preview.5.23265.1" } -} +} \ No newline at end of file From c2eeead5cdc1f2732de471a1b81fe4d7b5f2aa14 Mon Sep 17 00:00:00 2001 From: Ivan Povazan Date: Thu, 25 May 2023 12:16:47 +0200 Subject: [PATCH 10/20] Cleaning up the code --- src/mono/sample/iOS-NativeAOT/Program.csproj | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mono/sample/iOS-NativeAOT/Program.csproj b/src/mono/sample/iOS-NativeAOT/Program.csproj index 31ea247997dd9..87d50e56532d5 100644 --- a/src/mono/sample/iOS-NativeAOT/Program.csproj +++ b/src/mono/sample/iOS-NativeAOT/Program.csproj @@ -60,13 +60,14 @@ <_LinkerFlagsToDrop Include="@(LinkerArg)" Condition="$([System.String]::new('%(Identity)').Contains('swift'))" /> + <_NativeDependencies Include="%(ManagedBinary.IlcOutputFile)" /> Date: Mon, 29 May 2023 17:04:13 +0200 Subject: [PATCH 11/20] Fix for using publish targets --- src/mono/sample/iOS-NativeAOT/Makefile | 13 +++-- src/mono/sample/iOS-NativeAOT/Program.csproj | 53 +++++++++++++------- 2 files changed, 44 insertions(+), 22 deletions(-) diff --git a/src/mono/sample/iOS-NativeAOT/Makefile b/src/mono/sample/iOS-NativeAOT/Makefile index 599441ce3bf8a..f3cf2970d1b1f 100644 --- a/src/mono/sample/iOS-NativeAOT/Makefile +++ b/src/mono/sample/iOS-NativeAOT/Makefile @@ -17,19 +17,26 @@ BUILD_SCRIPT=$(REPO_DIR)/build.sh world: build-deps all # build all dependencies: runtime, nativeAot and all the libs +ifeq ($(USE_RUNTIME_PACKS),false) build-deps: build-runtime-ilc build-libs-all +else +build-deps: build-runtime-ilc-packs build-libs-all-packs +endif # building for host build-runtime-ilc: $(BUILD_SCRIPT) clr+clr.aot -c $(BUILD_CONFIG) -build-ilc: - $(BUILD_SCRIPT) clr.aot -c $(BUILD_CONFIG) +build-runtime-ilc-packs: + $(BUILD_SCRIPT) clr+clr.aot+libs+packs -c $(BUILD_CONFIG) # building for target platform build-libs-all: $(BUILD_SCRIPT) clr.nativeaotruntime+clr.nativeaotlibs+libs -c $(BUILD_CONFIG) -os $(TARGET_OS) -arch $(TARGET_ARCH) +build-libs-all-packs: + $(BUILD_SCRIPT) clr.nativeaotruntime+clr.nativeaotlibs+libs+packs -c $(BUILD_CONFIG) -os $(TARGET_OS) -arch $(TARGET_ARCH) /p:BuildNativeAOTRuntimePack=true + build-libs-nativeaot: $(BUILD_SCRIPT) clr.nativeaotruntime+clr.nativeaotlibs -c $(BUILD_CONFIG) -os $(TARGET_OS) -arch $(TARGET_ARCH) @@ -49,4 +56,4 @@ hello-app: clean -bl clean: - rm -rf obj bin \ No newline at end of file + rm -rf obj bin *.binlog \ No newline at end of file diff --git a/src/mono/sample/iOS-NativeAOT/Program.csproj b/src/mono/sample/iOS-NativeAOT/Program.csproj index 87d50e56532d5..2d13da76fb649 100644 --- a/src/mono/sample/iOS-NativeAOT/Program.csproj +++ b/src/mono/sample/iOS-NativeAOT/Program.csproj @@ -4,20 +4,21 @@ bin $(MSBuildThisFileDirectory)/obj/ $(NetCoreAppCurrent) - ios - iossimulator + iossimulator true $(TargetOS)-$(TargetArchitecture) HelloiOS - false - + true + $(OutputPath)/publish static true - true + - - $(OutputPath)/publish - false + + true + $(MSBuildWarningsAsErrors);NU1603 + false + $([MSBuild]::NormalizeDirectory('$(RepoRoot)', 'artifacts', 'packages', '$(CoreCLRConfiguration)', 'Shipping')) @@ -25,34 +26,47 @@ - - adhoc - false - - - + + + + + + + + + + + + 8.0.0-dev + + + + - + $([MSBuild]::NormalizeDirectory('$(RepoRoot)', 'artifacts', 'bin', 'coreclr', '$(HostOS).$(BuildArchitecture).$(CoreCLRConfiguration)', 'ilc')) $(IlcPath) $(CoreCLRAotSdkDir) - $(LibrariesAllBinArtifactsPath) - $(LibrariesAllBinArtifactsPath) + $(LibrariesAllBinArtifactsPath) + $(LibrariesAllBinArtifactsPath) + DependsOnTargets="IlcCompile;CopyFilesToPublishDirectory"> $(MSBuildThisFileDirectory)$(PublishDir)\app - iPhone 11 True + false + adhoc + false @@ -78,6 +92,7 @@ OutputDirectory="$(AppDir)" Optimized="$(Optimized)" InvariantGlobalization="$(InvariantGlobalization)" + EnableAppSandbox="$(EnableAppSandbox)" StripSymbolTable="$(StripDebugSymbols)" AppDir="$(MSBuildThisFileDirectory)$(PublishDir)" ExtraLinkerArguments="@(ExtraLinkerArguments)" > From 65de62ff11e558482653665febb5b8ef2201a8bc Mon Sep 17 00:00:00 2001 From: Ivan Povazan Date: Wed, 31 May 2023 14:29:51 +0200 Subject: [PATCH 12/20] Prevent building invalid Microsoft.DotNet.ILCompiler package --- src/installer/pkg/projects/nativeaot-packages.proj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/installer/pkg/projects/nativeaot-packages.proj b/src/installer/pkg/projects/nativeaot-packages.proj index 592b456515421..b9ec2ee88108c 100644 --- a/src/installer/pkg/projects/nativeaot-packages.proj +++ b/src/installer/pkg/projects/nativeaot-packages.proj @@ -3,7 +3,7 @@ - + From ae968cf07bd49133a88d0461e43b18c9da0b9a60 Mon Sep 17 00:00:00 2001 From: Ivan Povazan Date: Thu, 1 Jun 2023 12:29:57 +0200 Subject: [PATCH 13/20] Updating README.md to reflect the changes --- src/mono/sample/iOS-NativeAOT/README.md | 62 ++++++++++++++++++++----- 1 file changed, 51 insertions(+), 11 deletions(-) diff --git a/src/mono/sample/iOS-NativeAOT/README.md b/src/mono/sample/iOS-NativeAOT/README.md index fe6fcb1a45cd6..fe14a8a1f3da8 100644 --- a/src/mono/sample/iOS-NativeAOT/README.md +++ b/src/mono/sample/iOS-NativeAOT/README.md @@ -11,29 +11,67 @@ This sample application is intended to be used by developers who work on enablin The sample shares the source code with the Mono sample specified at: `../iOS/Program.cs` and in general should have the same behavior as MonoAOT. -## Limitations +## Scenarios -The application is **_currently_** relying on the following: -1. Internal dependencies - locally building the internals is required as runtime and tools nuget packages are still not being produced -2. Invariant globalization - `System.Globalization.Native` is currently not being built as part of NativeAOT framework for iOS-like platforms -3. No publish targets - the SDK and MSBuild integration is still not complete +There are two scenarios for building and testing the NativeAOT support for iOS: +1. Testing against locally built internals + - Uses locally built ILCompiler, build integration targets, framework and runtime libraries + - Should be used in CI testing +2. Testing against locally built packages - **end-to-end** testing + - References locally built ILCompiler and runtime packages + - Should be used by developers performing end-to-end validation ## How to build and test -### Building for the first time +### 1. Testing against locally built internals When building for the first time (on a clean checkout) run from this directory the following `make` command: ``` bash make world ``` -This will first build all required runtime components and dependencies, after which it will build the sample app and bundle it into an application bundle. + +The command performs the following: +1. Build all required runtime components and dependencies +2. Build the sample app and bundle it into an application bundle + By default the build will use `Debug` build configuration and target `iossimulator`. To change this behavior, specify the desired setting in the following way: ``` bash make world BUILD_CONFIG=Release TARGET_OS=ios ``` -### To avoid building all the dependencies +### 2. Testing against locally built packages - end-to-end testing + +When building for the first time (on a clean checkout) run from this directory the following `make` command: +``` bash +make world USE_RUNTIME_PACKS=true +``` + +The command performs the following: +1. Builds ILCompiler and runtime packages: + - `Microsoft.DotNet.ILCompiler.8.0.0-dev` (host) + - `runtime.-.Microsoft.DotNet.ILCompiler.8.0.0-dev` (host) + - `Microsoft.NETCore.App.Runtime.NativeAOT.-.8.0.0-dev` (target) + + NOTE: + - The packages can be found at: `artifacts/packages//Shipping/*.8.0.0-dev.nupkg` + - For testing incremental changes make sure to remove the **restored** nuget packages listed above with `8.0.0-dev` from your nuget restore directory (usually `~/.nuget/packages`). Failing to do so, can lead to unexpected behavior, as nuget will refuse to install newly generate package with a same version - `8.0.0-dev`. Something like: + ``` + rm -rf ~/.nuget/packages/microsoft.dotnet.ilcompiler/8.0.0-dev + rm -rf ~/.nuget/packages/runtime.osx-arm64.microsoft.dotnet.ilcompiler/8.0.0-dev + rm -rf ~/.nuget/packages/microsoft.netcore.app.runtime.nativeaot.ios-arm64/8.0.0-dev + ``` +2. Build the sample app using locally built packages 1) and bundle it into an application bundle + +By default the build will use `Debug` build configuration and target `iossimulator`. +To change this behavior, specify the desired setting in the following way: +``` bash +make world USE_RUNTIME_PACKS=true BUILD_CONFIG=Release TARGET_OS=ios +``` + +NOTE: In general, the make variable `USE_RUNTIME_PACKS` controls which scenario will be used during the build (the default value is `false`) + +#### To avoid building all the dependencies For future builds, you can run just: ``` bash @@ -46,16 +84,18 @@ For convenience, it is also possible to rebuild only the application it self wit make hello-app ``` -### Deploy and run +NOTE: Pay attention to the scenario you are testing `USE_RUNTIME_PACKS=true or false` + +#### Deploy and run -#### Simulator +##### Simulator To test the application on a simulator include the following in your make command `DEPLOY_AND_RUN=true` e.g.,: ``` bash make hello-app DEPLOY_AND_RUN=true ``` -#### Device +##### Device To test the application on a device, a provisioning profile needs to be specified. This can be achieved by defining `DevTeamProvisioning` environment variable with a valid team ID (see [developer.apple.com/account/#/membership](https://developer.apple.com/account/#/membership), scroll down to `Team ID`) for example: From ce1c9c4a88b1285ad0ac7d03190213211a6157b0 Mon Sep 17 00:00:00 2001 From: Ivan Povazan Date: Thu, 1 Jun 2023 12:37:05 +0200 Subject: [PATCH 14/20] PR feedback --- .../Microsoft.NETCore.Native.Unix.targets | 10 +++++----- .../BuildIntegration/Microsoft.NETCore.Native.targets | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets index 4b9fc0234654f..d6e4fdfb751ba 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. - - - - - + + + + + diff --git a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets index 4367f3b560600..d7fc036520bab 100644 --- a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets +++ b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets @@ -138,19 +138,19 @@ The .NET Foundation licenses this file to you under the MIT license. <_NETCoreAppRuntimePackPath>%(_NETCoreAppFrameworkReference.RuntimePackPath)/runtimes/$(RuntimeIdentifier)/ $(_NETCoreAppRuntimePackPath)\native\ $(RuntimePackagePath)\framework\ - $(IlcFrameworkNativePath) - $(IlcSdkPath) + $(IlcFrameworkNativePath) + $(IlcSdkPath) $(RuntimePackagePath)\mibc\ - + - + From 808b12114f61c6295fa43d03c2bbe20bb9dd5b8a Mon Sep 17 00:00:00 2001 From: Ivan Povazan Date: Thu, 1 Jun 2023 14:13:48 +0200 Subject: [PATCH 15/20] Fix markdownlint errors --- src/mono/sample/iOS-NativeAOT/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mono/sample/iOS-NativeAOT/README.md b/src/mono/sample/iOS-NativeAOT/README.md index fe14a8a1f3da8..76d9dabe0aba7 100644 --- a/src/mono/sample/iOS-NativeAOT/README.md +++ b/src/mono/sample/iOS-NativeAOT/README.md @@ -30,7 +30,7 @@ When building for the first time (on a clean checkout) run from this directory t make world ``` -The command performs the following: +The command performs the following: 1. Build all required runtime components and dependencies 2. Build the sample app and bundle it into an application bundle @@ -47,13 +47,13 @@ When building for the first time (on a clean checkout) run from this directory t make world USE_RUNTIME_PACKS=true ``` -The command performs the following: +The command performs the following: 1. Builds ILCompiler and runtime packages: - `Microsoft.DotNet.ILCompiler.8.0.0-dev` (host) - `runtime.-.Microsoft.DotNet.ILCompiler.8.0.0-dev` (host) - `Microsoft.NETCore.App.Runtime.NativeAOT.-.8.0.0-dev` (target) - - NOTE: + + NOTE: - The packages can be found at: `artifacts/packages//Shipping/*.8.0.0-dev.nupkg` - For testing incremental changes make sure to remove the **restored** nuget packages listed above with `8.0.0-dev` from your nuget restore directory (usually `~/.nuget/packages`). Failing to do so, can lead to unexpected behavior, as nuget will refuse to install newly generate package with a same version - `8.0.0-dev`. Something like: ``` From 5693fd3ad6b308ae062d3b5ace5d29296e0dedca Mon Sep 17 00:00:00 2001 From: Ivan Povazan Date: Fri, 2 Jun 2023 13:44:55 +0200 Subject: [PATCH 16/20] Escape NativeAOT bundling targets --- src/mono/sample/iOS-NativeAOT/Program.csproj | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/mono/sample/iOS-NativeAOT/Program.csproj b/src/mono/sample/iOS-NativeAOT/Program.csproj index 2d13da76fb649..f7a5b8b72f3a3 100644 --- a/src/mono/sample/iOS-NativeAOT/Program.csproj +++ b/src/mono/sample/iOS-NativeAOT/Program.csproj @@ -12,6 +12,9 @@ $(OutputPath)/publish static true + + false + Compile;ComputeIlcCompileInputs;SetupOSSpecificProps;PrepareForILLink @@ -30,11 +33,6 @@ - - - - - From a221b5a4969b20718acd0f5a4c06e97065cac26f Mon Sep 17 00:00:00 2001 From: Ivan Povazan Date: Fri, 2 Jun 2023 14:04:33 +0200 Subject: [PATCH 17/20] Use local folder for restore packages --- src/mono/sample/iOS-NativeAOT/Makefile | 11 ++++++++++- src/mono/sample/iOS-NativeAOT/README.md | 7 +------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/mono/sample/iOS-NativeAOT/Makefile b/src/mono/sample/iOS-NativeAOT/Makefile index f3cf2970d1b1f..2ef3ea826d5d5 100644 --- a/src/mono/sample/iOS-NativeAOT/Makefile +++ b/src/mono/sample/iOS-NativeAOT/Makefile @@ -13,6 +13,11 @@ REPO_DIR=$(realpath $(TOP)) TASKS_DIR=$(REPO_DIR)/src/tasks DOTNET=$(REPO_DIR)/dotnet.sh BUILD_SCRIPT=$(REPO_DIR)/build.sh +ifeq ($(USE_RUNTIME_PACKS),false) +LOCAL_NUGET_RESTORE_DIR= +else +LOCAL_NUGET_RESTORE_DIR=$(realpath .)/packages +endif world: build-deps all @@ -45,6 +50,10 @@ all: appbuilder hello-app appbuilder: $(DOTNET) build -c $(BUILD_CONFIG) $(TASKS_DIR)/AppleAppBuilder/AppleAppBuilder.csproj +ifeq ($(USE_RUNTIME_PACKS),true) +hello-app: export NUGET_PACKAGES = $(LOCAL_NUGET_RESTORE_DIR) +endif + hello-app: clean $(DOTNET) \ publish -c $(BUILD_CONFIG) \ @@ -56,4 +65,4 @@ hello-app: clean -bl clean: - rm -rf obj bin *.binlog \ No newline at end of file + rm -rf obj bin *.binlog $(LOCAL_NUGET_RESTORE_DIR) \ No newline at end of file diff --git a/src/mono/sample/iOS-NativeAOT/README.md b/src/mono/sample/iOS-NativeAOT/README.md index 76d9dabe0aba7..3353a2afb46a3 100644 --- a/src/mono/sample/iOS-NativeAOT/README.md +++ b/src/mono/sample/iOS-NativeAOT/README.md @@ -55,12 +55,7 @@ The command performs the following: NOTE: - The packages can be found at: `artifacts/packages//Shipping/*.8.0.0-dev.nupkg` - - For testing incremental changes make sure to remove the **restored** nuget packages listed above with `8.0.0-dev` from your nuget restore directory (usually `~/.nuget/packages`). Failing to do so, can lead to unexpected behavior, as nuget will refuse to install newly generate package with a same version - `8.0.0-dev`. Something like: - ``` - rm -rf ~/.nuget/packages/microsoft.dotnet.ilcompiler/8.0.0-dev - rm -rf ~/.nuget/packages/runtime.osx-arm64.microsoft.dotnet.ilcompiler/8.0.0-dev - rm -rf ~/.nuget/packages/microsoft.netcore.app.runtime.nativeaot.ios-arm64/8.0.0-dev - ``` + - During the build of the application NuGet is instructed to use the local `./packages` folder (in the current directory) as the folder for restored packages, which should be deleted when testing incremental changes. This is required as the packages built locally always have the same version - `8.0.0-dev`. For convenience, targets in the `Makefile` are automatically removing this folder on a rebuild. 2. Build the sample app using locally built packages 1) and bundle it into an application bundle By default the build will use `Debug` build configuration and target `iossimulator`. From 6514512ade62dacb2a4377b2b8c90f0d0b65609a Mon Sep 17 00:00:00 2001 From: Ivan Povazan Date: Sat, 3 Jun 2023 00:20:43 +0200 Subject: [PATCH 18/20] PR feedback on documentation --- src/mono/sample/iOS-NativeAOT/README.md | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/mono/sample/iOS-NativeAOT/README.md b/src/mono/sample/iOS-NativeAOT/README.md index 3353a2afb46a3..af6bee72791e8 100644 --- a/src/mono/sample/iOS-NativeAOT/README.md +++ b/src/mono/sample/iOS-NativeAOT/README.md @@ -66,7 +66,7 @@ make world USE_RUNTIME_PACKS=true BUILD_CONFIG=Release TARGET_OS=ios NOTE: In general, the make variable `USE_RUNTIME_PACKS` controls which scenario will be used during the build (the default value is `false`) -#### To avoid building all the dependencies +### To avoid building all the dependencies For future builds, you can run just: ``` bash @@ -81,16 +81,16 @@ make hello-app NOTE: Pay attention to the scenario you are testing `USE_RUNTIME_PACKS=true or false` -#### Deploy and run +### Deploy and run -##### Simulator +#### Simulator To test the application on a simulator include the following in your make command `DEPLOY_AND_RUN=true` e.g.,: ``` bash make hello-app DEPLOY_AND_RUN=true ``` -##### Device +#### Device To test the application on a device, a provisioning profile needs to be specified. This can be achieved by defining `DevTeamProvisioning` environment variable with a valid team ID (see [developer.apple.com/account/#/membership](https://developer.apple.com/account/#/membership), scroll down to `Team ID`) for example: @@ -99,7 +99,7 @@ export DevTeamProvisioning=A1B2C3D4E5; make hello-app TARGET_OS=ios DEPLOY_AND_R ``` Assuming `A1B2C3D4E5` is a valid team ID. -#### One-liner +### One-liners On a clean dotnet/runtime checkout, from this directory, run: @@ -107,8 +107,14 @@ On a clean dotnet/runtime checkout, from this directory, run: export DevTeamProvisioning=A1B2C3D4E5; make world BUILD_CONFIG=Release TARGET_OS=ios DEPLOY_AND_RUN=true ``` -This command will build everything necessary to run and deploy the application on an iOS device. +- This command will build everything necessary to run and deploy the application on an iOS device using the locally built internals. + +``` bash +export DevTeamProvisioning=A1B2C3D4E5; make world BUILD_CONFIG=Release TARGET_OS=ios DEPLOY_AND_RUN=true USE_RUNTIME_PACKS=true +``` + +- This command will build everything necessary to run and deploy the application on an iOS device using the locally built packages. ### Custom builds -Check the `Makefile` for individual list of targets and variables to customize the build. +Check the `Makefile` for individual list of targets and variables to further customize your builds. From 7c0fd97bec6faee586175600938ea7d425a86801 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Sat, 3 Jun 2023 14:48:23 +0200 Subject: [PATCH 19/20] Use IlcSdkPath instead of IlcPrivateSdkPath --- .../Microsoft.NETCore.Native.Unix.targets | 10 +++++----- .../BuildIntegration/Microsoft.NETCore.Native.targets | 9 ++++----- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets index 177522e36b811..ad2c022f4be7f 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. - - - - - + + + + + diff --git a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets index 155e50acc27c4..68440fa06f98c 100644 --- a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets +++ b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets @@ -133,24 +133,23 @@ The .NET Foundation licenses this file to you under the MIT license. $(IlcHostPackagePath)\tools\ - $(RuntimePackagePath)\sdk\ $(RuntimePackagePath)\framework\ <_NETCoreAppRuntimePackPath>%(_NETCoreAppFrameworkReference.RuntimePackPath)/runtimes/$(RuntimeIdentifier)/ $(_NETCoreAppRuntimePackPath)\native\ $(RuntimePackagePath)\framework\ - $(IlcFrameworkNativePath) - $(IlcSdkPath) + $(IlcFrameworkNativePath) + $(RuntimePackagePath)\sdk\ $(RuntimePackagePath)\mibc\ - + - + From c9d5543d3aa59c7a5b6a3056b18aea291a67b0f4 Mon Sep 17 00:00:00 2001 From: Ivan Povazan Date: Mon, 5 Jun 2023 16:07:47 +0200 Subject: [PATCH 20/20] Revert "FIXME: revert once testing is finished" This reverts commit a8665cedfb92156d0151d8a060f126ee3d99882b. --- global.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/global.json b/global.json index 0f7f79dcf5910..8c5ca950977af 100644 --- a/global.json +++ b/global.json @@ -1,11 +1,11 @@ { "sdk": { - "version": "8.0.100-preview.5.23267.7", + "version": "8.0.100-preview.4.23260.5", "allowPrerelease": true, "rollForward": "major" }, "tools": { - "dotnet": "8.0.100-preview.5.23267.7" + "dotnet": "8.0.100-preview.4.23260.5" }, "msbuild-sdks": { "Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.23280.3", @@ -15,4 +15,4 @@ "Microsoft.Build.Traversal": "3.4.0", "Microsoft.NET.Sdk.IL": "8.0.0-preview.5.23279.2" } -} \ No newline at end of file +}