Skip to content

Enable NativeAOT library tests on Apple mobile platforms#125437

Draft
kotlarmilos wants to merge 51 commits intodotnet:mainfrom
kotlarmilos:enable-nativeaot-libs-tests-mobile
Draft

Enable NativeAOT library tests on Apple mobile platforms#125437
kotlarmilos wants to merge 51 commits intodotnet:mainfrom
kotlarmilos:enable-nativeaot-libs-tests-mobile

Conversation

@kotlarmilos
Copy link
Copy Markdown
Member

@kotlarmilos kotlarmilos commented Mar 11, 2026

Description

Replace NativeAOT runtime test legs with library test legs on iOS/tvOS devices, iOS/tvOS simulators, and Mac Catalyst.

Depends on dotnet/xharness#1554

Fixes #81075

Replace NativeAOT runtime test legs with library test legs on iOS/tvOS
devices, iOS/tvOS simulators, and Mac Catalyst. The runtime tests
(nativeaot/SmokeTests) provide minimal value on mobile since the compiler
doesn't meaningfully distinguish between iOS and macOS. Library tests
exercise OS-specific APIs (crypto, networking, etc.) that are the real
quality gate.

Changes:
- ioslike: remove NativeAOT runtime test leg, update existing library
  test leg to use dynamic smoke test arg
- ioslikesimulator: replace NativeAOT runtime test leg with library
  test leg, fix isiOSLikeSimulatorOnlyBuild parameter
- maccatalyst: replace both NativeAOT runtime test legs (regular +
  AppSandbox) with library test legs, fix coreclrContainsChange
  variable (was incorrectly using monoContainsChange)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Apple “extra platforms” CI legs to validate NativeAOT on iOS/tvOS devices, iOS/tvOS simulators, and Mac Catalyst by running libraries tests (via Helix) instead of the minimal NativeAOT runtime SmokeTests, improving OS-specific coverage (crypto/networking/globalization) on mobile.

Changes:

  • Switch NativeAOT Apple-mobile legs from runtime SmokeTests submission to eng/pipelines/libraries/helix.yml submission of libraries tests.
  • Use eng/pipelines/libraries/helix-queues-setup.yml and pass NeedsToBuildAppsOnHelix=true for the new legs.
  • Update naming/args to use $(_runSmokeTestsOnlyArg) and fix path-evaluation variable naming in affected legs.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
eng/pipelines/extra-platforms/runtime-extra-platforms-maccatalyst.yml Replaces NativeAOT runtime SmokeTests legs with libraries test legs (including App Sandbox variant) using libraries Helix templates/queues.
eng/pipelines/extra-platforms/runtime-extra-platforms-ioslikesimulator.yml Replaces NativeAOT runtime SmokeTests on iOS/tvOS simulators with libraries tests using libraries Helix templates/queues.
eng/pipelines/extra-platforms/runtime-extra-platforms-ioslike.yml Adjusts NativeAOT iOS/tvOS device leg to use $(_runSmokeTestsOnlyArg) for libraries tests and removes the old NativeAOT runtime SmokeTests device leg.

You can also share your feedback on Copilot code review. Take the survey.

dotnet-maestro bot and others added 5 commits March 12, 2026 10:30
…60312.1

On relative base path root
Microsoft.DotNet.XHarness.CLI , Microsoft.DotNet.XHarness.TestRunners.Common , Microsoft.DotNet.XHarness.TestRunners.Xunit From Version 11.0.0-prerelease.26160.2 -> To Version 11.0.0-prerelease.26162.1
…60312.3

On relative base path root
Microsoft.DotNet.XHarness.CLI , Microsoft.DotNet.XHarness.TestRunners.Common , Microsoft.DotNet.XHarness.TestRunners.Xunit From Version 11.0.0-prerelease.26160.2 -> To Version 11.0.0-prerelease.26162.3
…60314.3

On relative base path root
Microsoft.DotNet.XHarness.CLI , Microsoft.DotNet.XHarness.TestRunners.Common , Microsoft.DotNet.XHarness.TestRunners.Xunit From Version 11.0.0-prerelease.26160.2 -> To Version 11.0.0-prerelease.26164.3
…60317.2

On relative base path root
Microsoft.DotNet.XHarness.CLI , Microsoft.DotNet.XHarness.TestRunners.Common , Microsoft.DotNet.XHarness.TestRunners.Xunit From Version 11.0.0-prerelease.26160.2 -> To Version 11.0.0-prerelease.26167.2
…60318.1

On relative base path root
Microsoft.DotNet.XHarness.CLI , Microsoft.DotNet.XHarness.TestRunners.Common , Microsoft.DotNet.XHarness.TestRunners.Xunit From Version 11.0.0-prerelease.26160.2 -> To Version 11.0.0-prerelease.26168.1
@kotlarmilos kotlarmilos marked this pull request as draft March 18, 2026 12:57
…bb6-53258cb4f260' into enable-nativeaot-libs-tests-mobile
Copilot AI review requested due to automatic review settings March 18, 2026 13:02
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.


You can also share your feedback on Copilot code review. Take the survey.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.

Comment thread src/libraries/Common/tests/AppleTestRunner/AppleTestRunner.cs
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 16 out of 16 changed files in this pull request and generated no new comments.

The build command passes EnableAggressiveTrimming=true which sets
PublishTrimmed=true in tests.mobile.targets. This causes the SDK's
ILLink to run during the test project's dotnet publish, but ILLink
fails with IL1007 (Missing predefined System.NotSupportedException)
during cross-compilation for ios-arm64.

Fix: Set PublishTrimmed=false for all NativeAOT tests (including
functional tests) in tests.ioslike.targets. Trimming is correctly
handled by ILC's integrated ILLink via _CompileNativeAOTOnBuildMachine,
which invokes the ProxyProject's RunNativeAOTCompilation target on the
build machine. Only app bundling and signing happen on Helix (with
SkipIlcCompile=true).

Also remove the explicit ILLink targets import from AppleBuild.targets.
ILC targets set PublishTrimmed=true which causes the SDK to import
ILLink targets automatically. The explicit import caused MSB4011
(double-import error).

Also add DynamicCodeSupport=false since NativeAOT does not support
dynamic code generation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@kotlarmilos kotlarmilos force-pushed the enable-nativeaot-libs-tests-mobile branch from aa765b8 to 5947a8d Compare April 15, 2026 08:21
These tests should work on NativeAOT Apple mobile the same way they
work on other NativeAOT platforms without platform-specific exclusions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 15, 2026 15:16
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Comment thread eng/testing/tests.ioslike.targets
Comment thread eng/testing/tests.ioslike.targets Outdated
On Apple mobile, the test runner (AppleTestRunner.dll) is the IlcCompileInput while test assemblies are IlcReference. This causes ILC to trim module-level attributes, global fields/methods, and custom modifiers from test assemblies. Setting IlcTrimMetadata=false preserves all reflection metadata, fixing 16 test failures (ModifiedTypeTests, ModuleTests, GetCustomAttribute). Also restores ActiveIssue for DoubleTests.ParsePatterns (file path issue on iOS) and reformats MSBuild Properties for readability.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread src/libraries/System.Runtime/tests/System.Runtime.Tests/System/DoubleTests.cs Outdated
<PropertyGroup Condition="'$(UseNativeAOTRuntime)' == 'true' and '$(IncludesTestRunner)' == 'true'">
<NoWarn>$(NoWarn);IL3000;IL3001;IL3002;IL3003;IL3050;IL3051;IL3052;IL3053</NoWarn>
<TrimMode>partial</TrimMode>
<IlcTrimMetadata>false</IlcTrimMetadata>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed? (What this setting does is that it will consider everything that was compiled also available as a target of reflection. It will make some extra reflection in the program work. Mostly by luck.)

Is there any way we could set the TestNativeAot property to true when doing iDevice testing so the trimming/IlcPaths/everything is configured by the normal libs testing infrastructure? We might need to do some targeted exclusion for when TestNativeAot is trying to use the single file runner, but the rest should ideally come from the shared infra.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, trying to achieve that. On Helix we should only do app bundling + signing. ILC and trimming should execute on the build machine.

Copilot AI review requested due to automatic review settings April 17, 2026 08:23
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.

Comment thread eng/testing/tests.ioslike.targets
kotlarmilos and others added 2 commits April 17, 2026 11:59
When TestNativeAot=true on Apple mobile, the test project publishes as a
static library (NativeLib=Static) with OutputType != Exe, so ILLink does
not auto-root the main assembly under TrimMode=partial. This caused
IL1007 'Missing predefined System.NotSupportedException type' because
nothing reached into corelib. Explicitly root the test assembly so its
transitive closure (including System.Private.CoreLib) is resolved.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The previous refactor excluded OutputType=Exe for Apple mobile with
TestNativeAot=true to accommodate NativeLib=Static, but this left
ILLink without an entry assembly to root under TrimMode=partial,
causing IL1007 'Missing predefined System.NotSupportedException type'
because System.Private.CoreLib was never included in the trim closure.

ILC's NativeLib=Static produces a static library regardless of
OutputType, so OutputType=Exe (matching desktop NativeAOT) is
compatible: ILLink properly roots the entry assembly and resolves
corelib, while ILC still emits the .a consumed by AppleBuild on Helix.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 17, 2026 12:30
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Comment on lines +6 to +15
<!-- For NativeAOT on Apple mobile use the shared library-test NativeAOT infrastructure
(tests.singlefile.targets). The test project's own publish runs trimming and ILC,
producing a static library that AppleAppBuilder consumes in library-mode.
The test project becomes OutputType=Exe with AppleTestRunner.cs supplying Main,
matching how desktop NativeAOT library tests are structured. -->
<PropertyGroup Condition="'$(UseNativeAOTRuntime)' == 'true'">
<TestNativeAot>true</TestNativeAot>
<NativeLib>Static</NativeLib>
<CustomNativeMain>true</CustomNativeMain>
</PropertyGroup>
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new comment describes Apple NativeAOT as producing a static library that AppleAppBuilder consumes in “library-mode”, but this target only sets NativeLib/CustomNativeMain and doesn’t enable AppleAppBuilder’s IsLibraryMode path. In AppleBuild.props, NativeAOT “library mode” is currently tied to NativeLib == Shared (not static). Please update the comment to reflect the actual flow, or adjust properties so the build really runs in library-mode if that’s required.

Copilot uses AI. Check for mistakes.
</PropertyGroup>

<!-- Explicitly set IntermediateAssembly so ManagedBinary resolves correctly for NativeAOT -->
<ItemGroup Condition="'$(UseNativeAOTRuntime)' == 'true' and '$(IncludesTestRunner)' == 'true'">
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This IntermediateAssembly override is documented as necessary for NativeAOT so that ManagedBinary resolves correctly, but it’s currently gated on IncludesTestRunner == true. The Helix/mobile infrastructure also runs “run-only” apps with IncludesTestRunner=false, and those can still be NativeAOT; in that case ManagedBinary/%(ManagedBinary.IlcOutputFile) may end up empty and break linking/bundling. Consider applying this override for all UseNativeAOTRuntime==true cases (or at least when @(IntermediateAssembly) is otherwise empty), not only when the test runner is included.

Suggested change
<ItemGroup Condition="'$(UseNativeAOTRuntime)' == 'true' and '$(IncludesTestRunner)' == 'true'">
<ItemGroup Condition="'$(UseNativeAOTRuntime)' == 'true'">

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Enable building/running libraries tests on iOS simulator and device with NativeAOT

7 participants