diff --git a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Publish.targets b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Publish.targets
index 69b7b1fa452a8..8b1846092059a 100644
--- a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Publish.targets
+++ b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Publish.targets
@@ -72,8 +72,8 @@
Text="Add a PackageReference for '$(_hostPackageName)' to allow cross-compilation for $(_targetArchitecture)" />
-
-
+
+
+
+ <_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)
+ $(RuntimePackagePath)\sdk\
$(RuntimePackagePath)\mibc\
-
-
+
+
+
+
+
+
+
-
-
+
+
+
+
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 @@
-
+
diff --git a/src/mono/sample/iOS-NativeAOT/Makefile b/src/mono/sample/iOS-NativeAOT/Makefile
index e1e295a75d9e7..2ef3ea826d5d5 100644
--- a/src/mono/sample/iOS-NativeAOT/Makefile
+++ b/src/mono/sample/iOS-NativeAOT/Makefile
@@ -7,28 +7,41 @@ TARGET_ARCH?=$(shell . $(TOP)eng/native/init-os-and-arch.sh && echo $${arch})
TARGET_OS?=iossimulator
DEPLOY_AND_RUN?=false
STRIP_DEBUG_SYMBOLS?=false
+USE_RUNTIME_PACKS?=false
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
# 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)
@@ -37,14 +50,19 @@ 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) \
- build -c $(BUILD_CONFIG) \
+ publish -c $(BUILD_CONFIG) \
-p:TargetOS=$(TARGET_OS) \
-p:TargetArchitecture=$(TARGET_ARCH) \
-p:DeployAndRun=$(DEPLOY_AND_RUN) \
-p:StripDebugSymbols=$(STRIP_DEBUG_SYMBOLS) \
+ -p:PublishAotUsingRuntimePack=$(USE_RUNTIME_PACKS) \
-bl
clean:
- rm -rf obj bin
\ 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/Program.csproj b/src/mono/sample/iOS-NativeAOT/Program.csproj
index c76b6530d811d..f7a5b8b72f3a3 100644
--- a/src/mono/sample/iOS-NativeAOT/Program.csproj
+++ b/src/mono/sample/iOS-NativeAOT/Program.csproj
@@ -4,20 +4,24 @@
bin
$(MSBuildThisFileDirectory)/obj/
$(NetCoreAppCurrent)
- ios
- iossimulator
+ iossimulator
true
$(TargetOS)-$(TargetArchitecture)
HelloiOS
- false
-
- static
- true
true
-
- true
-
$(OutputPath)/publish
+ static
+ true
+
+ false
+ Compile;ComputeIlcCompileInputs;SetupOSSpecificProps;PrepareForILLink
+
+
+
+ true
+ $(MSBuildWarningsAsErrors);NU1603
+ false
+ $([MSBuild]::NormalizeDirectory('$(RepoRoot)', 'artifacts', 'packages', '$(CoreCLRConfiguration)', 'Shipping'))
@@ -25,17 +29,23 @@
-
- adhoc
- false
-
-
-
+
-
-
+
+
+
+
+
+ 8.0.0-dev
+
+
+
+
+
+
$([MSBuild]::NormalizeDirectory('$(RepoRoot)', 'artifacts', 'bin', 'coreclr', '$(HostOS).$(BuildArchitecture).$(CoreCLRConfiguration)', 'ilc'))
$(IlcPath)
@@ -47,23 +57,29 @@
+ DependsOnTargets="IlcCompile;CopyFilesToPublishDirectory">
$(MSBuildThisFileDirectory)$(PublishDir)\app
- iPhone 11
True
+ false
+ adhoc
+ false
-
+ <_LinkerFlagsToDrop Include="@(NativeFramework->'-framework %(Identity)')" />
+ <_LinkerFlagsToDrop Include="@(LinkerArg)" Condition="$([System.String]::new('%(Identity)').Contains('swift'))" />
+
+
+ <_NativeDependencies Include="%(ManagedBinary.IlcOutputFile)" />
+ AppDir="$(MSBuildThisFileDirectory)$(PublishDir)"
+ ExtraLinkerArguments="@(ExtraLinkerArguments)" >
diff --git a/src/mono/sample/iOS-NativeAOT/README.md b/src/mono/sample/iOS-NativeAOT/README.md
index fe6fcb1a45cd6..af6bee72791e8 100644
--- a/src/mono/sample/iOS-NativeAOT/README.md
+++ b/src/mono/sample/iOS-NativeAOT/README.md
@@ -11,28 +11,61 @@ 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
```
+### 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`
+ - 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`.
+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:
@@ -46,6 +79,8 @@ For convenience, it is also possible to rebuild only the application it self wit
make hello-app
```
+NOTE: Pay attention to the scenario you are testing `USE_RUNTIME_PACKS=true or false`
+
### Deploy and run
#### Simulator
@@ -64,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:
@@ -72,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.
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 58d183b698fdd..616d267f53af9 100644
--- a/src/tasks/AppleAppBuilder/Xcode.cs
+++ b/src/tasks/AppleAppBuilder/Xcode.cs
@@ -411,16 +411,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");