Skip to content

Commit fde885c

Browse files
authored
[Xamarin.Android.Build.Tasks] Pass hybrid to AOT, if enabled (#7263)
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.
1 parent b2c59ae commit fde885c

File tree

1 file changed

+13
-0
lines changed
  • src/Xamarin.Android.Build.Tasks/Tasks

1 file changed

+13
-0
lines changed

src/Xamarin.Android.Build.Tasks/Tasks/Aot.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,19 @@ IEnumerable<Config> GetAotConfigs (NdkTools ndk)
173173
aotOptions.Add ($"ld-flags={LdFlags}");
174174
}
175175

176+
// We don't check whether any mode option was added via `AotAdditionalArguments`, the `AndroidAotMode` property should always win here.
177+
// Modes not supported by us directly can be set by setting `AndroidAotMode` to "normal" and adding the desired mode name to the
178+
// `AotAdditionalArguments` property.
179+
switch (AotMode) {
180+
case AotMode.Full:
181+
aotOptions.Add ("full");
182+
break;
183+
184+
case AotMode.Hybrid:
185+
aotOptions.Add ("hybrid");
186+
break;
187+
}
188+
176189
// we need to quote the entire --aot arguments here to make sure it is parsed
177190
// on windows as one argument. Otherwise it will be split up into multiple
178191
// values, which wont work.

0 commit comments

Comments
 (0)