diff --git a/Documentation/docs-mobile/building-apps/build-properties.md b/Documentation/docs-mobile/building-apps/build-properties.md index 634d78840db..4f12aca2d42 100644 --- a/Documentation/docs-mobile/building-apps/build-properties.md +++ b/Documentation/docs-mobile/building-apps/build-properties.md @@ -1903,6 +1903,40 @@ ReadyToRun compilation is composite by default. See [`$(MauiEnableFullReadyToRun)`](#mauienablefullreadytorun) to opt in to full ReadyToRun. +For ARM64, .NET for Android defaults crossgen2 to: + +```text +--instruction-set:-optimistic,aes,crc,dotprod,lse,rcpc,rdma,sha1,sha2 +``` + +This disables automatic optimistic instruction-set additions and explicitly +enables the listed features, excluding RCPC2 without requiring RCPC2 to be +absent. The listed features become baseline requirements for the precompiled +image, rather than optional optimistic features. Devices without a required +feature can reject the image's ReadyToRun code and fall back to JIT compilation. + +Other CPU architectures default to `--instruction-set:-optimistic`, which +disables automatic optimistic instruction-set additions while retaining the +normal baseline requirements. Neither policy disables hardware-specific +optimizations in the JIT or tiered compilation. + +An explicit `--instruction-set` option in +`$(PublishReadyToRunCrossgen2ExtraArgs)` overrides this default. +An instruction-set option in +`$(PublishReadyToRunCrossgen2CompositeExtraArgs)` also opts the entire +build out of this default, including assemblies in +`@(PublishReadyToRunCompositeExclusions)`. The .NET SDK concatenates the +normal and composite arguments for the composite image, and crossgen2 +does not accept multiple `--instruction-set` options. The opt-out applies +even when `$(PublishReadyToRunComposite)` is `false`. + +To apply an instruction-set policy to both the composite image and +excluded assemblies, set it in +`$(PublishReadyToRunCrossgen2ExtraArgs)`, not in the composite-only +arguments. For example, `--instruction-set:-optimistic` in the normal +arguments keeps both conservative. Do not specify the option in both +argument properties. + For more information, see [Runtimes and compilation in .NET MAUI][maui-runtimes-compilation]. diff --git a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.CoreCLR.targets b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.CoreCLR.targets index 9d687057a26..0e1dc763530 100644 --- a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.CoreCLR.targets +++ b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.CoreCLR.targets @@ -25,6 +25,18 @@ This file contains the CoreCLR-specific MSBuild logic for .NET for Android. true + + + + $(PublishReadyToRunCrossgen2ExtraArgs);--instruction-set:-optimistic,aes,crc,dotprod,lse,rcpc,rdma,sha1,sha2 + $(PublishReadyToRunCrossgen2ExtraArgs);--instruction-set:-optimistic + + +