Skip to content

[NativeAOT] Make workload linker the default for NativeAOT builds#11340

Open
sbomer wants to merge 4 commits into
mainfrom
dev/sbomer/workload-aot-testing
Open

[NativeAOT] Make workload linker the default for NativeAOT builds#11340
sbomer wants to merge 4 commits into
mainfrom
dev/sbomer/workload-aot-testing

Conversation

@sbomer
Copy link
Copy Markdown
Member

@sbomer sbomer commented May 14, 2026

Change _AndroidUseWorkloadNativeLinker default from false to true so NativeAOT builds use the workload-provided linker and sysroot by default, removing the NDK requirement.

Update SetRuntime(NativeAOT) to set _SkipNdkResolution=true so all existing NativeAOT tests exercise the NDK-free workload linker path.

Update NativeAotBuildTests with three tests covering the full matrix:

  • BuildNativeAot_WithoutNdk: workload linker (default), no NDK -> succeeds
  • BuildNativeAot_WithNdkLinker: opt-out to NDK linker, with NDK -> succeeds
  • BuildNativeAot_WithoutNdk_WorkloadLinkerDisabled_Fails: opt-out, no NDK -> fails

Change _AndroidUseWorkloadNativeLinker default from false to true so
NativeAOT builds use the workload-provided linker and sysroot by default,
removing the NDK requirement.

Update SetRuntime(NativeAOT) to set _SkipNdkResolution=true so all
existing NativeAOT tests exercise the NDK-free workload linker path.

Update NativeAotBuildTests with three tests covering the full matrix:
- BuildNativeAot_WithoutNdk: workload linker (default), no NDK -> succeeds
- BuildNativeAot_WithNdkLinker: opt-out to NDK linker, with NDK -> succeeds
- BuildNativeAot_WithoutNdk_WorkloadLinkerDisabled_Fails: opt-out, no NDK -> fails

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Assisted-by: Claude:claude-opus-4.6-1m
Copilot AI review requested due to automatic review settings May 14, 2026 00:15
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 switches NativeAOT builds to use the workload-provided linker/sysroot by default (removing the NDK requirement for the default path) and adjusts the test suite to validate both the default workload-linker behavior and the opt-out NDK-linker behavior.

Changes:

  • Default _AndroidUseWorkloadNativeLinker to true for NativeAOT builds.
  • Update the NativeAOT test runtime helper to skip NDK resolution by default for NativeAOT test projects.
  • Revise/expand NativeAotBuildTests to cover success/failure across the workload-linker vs NDK-linker matrix.
Show a summary per file
File Description
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/ProjectExtensions.cs Changes NativeAOT test runtime setup to force the NDK-free path.
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/NativeAotBuildTests.cs Updates/extends NativeAOT build tests for the new default and opt-out behavior.
src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.NativeAOT.targets Switches the default NativeAOT linker selection toward workload-provided tooling.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 2

Comment on lines 26 to 28
project.SetPublishAot (true);
project.SetProperty ("_SkipNdkResolution", "true");
EnablePreviewFeaturesIfNeeded (project, runtime);
sbomer and others added 2 commits May 13, 2026 17:34
The default was set inside _AndroidLinkNativeAotSharedLibrary, but
SetIlcToolchainPath in _AndroidBeforeIlcCompile runs earlier and
checks the property. With the default set too late, ILC would use
the NDK bin dir instead of AndroidBinUtilsDirectory when the property
was not explicitly set.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Assisted-by: Claude:claude-opus-4.6-1m
Update _NdkRequired in GetAndroidDependencies to only require NDK for
PublishAot when _AndroidUseWorkloadNativeLinker is not enabled. Update
NativeAotRequiresNdk test to explicitly opt out of the workload linker
so it continues to verify NDK is required on the old path.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Assisted-by: Claude:claude-opus-4.6-1m
@sbomer sbomer self-assigned this May 14, 2026
Skip EnableLLVM and AndroidEnableProfiledAot for NativeAOT (Mono
concepts not applicable). AotAssemblies+NativeAOT continues to run
and correctly asserts NDK is not required.

Fix NativeAotRequiresNdk to override _SkipNdkResolution=false so
NDK resolution runs and the ndk-bundle dependency can be detected
when testing the opt-out path.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Assisted-by: Claude:claude-opus-4.6-1m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants