Enable NativeAOT library tests on Apple mobile platforms#125437
Enable NativeAOT library tests on Apple mobile platforms#125437kotlarmilos wants to merge 51 commits intodotnet:mainfrom
Conversation
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>
There was a problem hiding this comment.
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.ymlsubmission of libraries tests. - Use
eng/pipelines/libraries/helix-queues-setup.ymland passNeedsToBuildAppsOnHelix=truefor 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.
…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
…bb6-53258cb4f260' into enable-nativeaot-libs-tests-mobile
There was a problem hiding this comment.
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.
93b6448 to
aa765b8
Compare
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>
aa765b8 to
5947a8d
Compare
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>
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>
| <PropertyGroup Condition="'$(UseNativeAOTRuntime)' == 'true' and '$(IncludesTestRunner)' == 'true'"> | ||
| <NoWarn>$(NoWarn);IL3000;IL3001;IL3002;IL3003;IL3050;IL3051;IL3052;IL3053</NoWarn> | ||
| <TrimMode>partial</TrimMode> | ||
| <IlcTrimMetadata>false</IlcTrimMetadata> |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Yes, trying to achieve that. On Helix we should only do app bundling + signing. ILC and trimming should execute on the build machine.
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>
| <!-- 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> |
There was a problem hiding this comment.
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.
| </PropertyGroup> | ||
|
|
||
| <!-- Explicitly set IntermediateAssembly so ManagedBinary resolves correctly for NativeAOT --> | ||
| <ItemGroup Condition="'$(UseNativeAOTRuntime)' == 'true' and '$(IncludesTestRunner)' == 'true'"> |
There was a problem hiding this comment.
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.
| <ItemGroup Condition="'$(UseNativeAOTRuntime)' == 'true' and '$(IncludesTestRunner)' == 'true'"> | |
| <ItemGroup Condition="'$(UseNativeAOTRuntime)' == 'true'"> |
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