Skip to content

Commit

Permalink
[Xamarin.Android.Build.Tasks] Pass hybrid to AOT, if enabled (#7263)
Browse files Browse the repository at this point in the history
Fixes: #7088

When the AOT hybrid mode is enabled when the `$(AndroidAotMode)`
MSBuild property is set to `Hybrid`, we failed to inform the AOT
compiler about its desired mode by omitting the `hybrid` argument
from the list of options passed to the compiler via `--aot`.

The same would apply to the full AOT mode.

Add `hybrid` and `full` options to the AOT compiler command line, if
enabled via the `$(AndroidAotMode)` MSBuild property.

The mode is set after processing the `$(AndroidAotAdditionalArguments)`
MSBuild property.  The `$(AndroidAotMode)` property should always be
the definitive source of AOT compiler mode, as it specifies the
options directly supported by us.

Note that the AOT compiler doesn't appear to validate options passed
to it too rigorously, so setting multiple modes in some way, may have
weird/invalid effects.  I don't think it's our place to verify the
modes, thus I'm not adding any code to that effect.
  • Loading branch information
grendello authored Aug 22, 2022
1 parent b2c59ae commit fde885c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Xamarin.Android.Build.Tasks/Tasks/Aot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,19 @@ IEnumerable<Config> GetAotConfigs (NdkTools ndk)
aotOptions.Add ($"ld-flags={LdFlags}");
}

// We don't check whether any mode option was added via `AotAdditionalArguments`, the `AndroidAotMode` property should always win here.
// Modes not supported by us directly can be set by setting `AndroidAotMode` to "normal" and adding the desired mode name to the
// `AotAdditionalArguments` property.
switch (AotMode) {
case AotMode.Full:
aotOptions.Add ("full");
break;

case AotMode.Hybrid:
aotOptions.Add ("hybrid");
break;
}

// we need to quote the entire --aot arguments here to make sure it is parsed
// on windows as one argument. Otherwise it will be split up into multiple
// values, which wont work.
Expand Down

0 comments on commit fde885c

Please sign in to comment.