Skip to content

Commit

Permalink
[AOT] Pass the hybrid option to AOT compiler, if enabled
Browse files Browse the repository at this point in the history
Fixes: #7088

When the AOT hybrid mode is enabled via the
`<AndroidAotMode>Hybrid</AndroidAotMode>` MSBuild property, 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.

Mode is set after processing the `AotAdditionalArguments` 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 committed Aug 17, 2022
1 parent f9dc964 commit 36ac3d2
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 36ac3d2

Please sign in to comment.