Repository navigation
[One .NET] fix AOT builds with different settings - #6556
Merged
Merged
Conversation
dellis1972
approved these changes
Dec 8, 2021
jonathanpeppers
force-pushed
the
dotnet-aot-issues
branch
from
December 8, 2021 17:45
8fb948f to
33d7a12
Compare
Member
Author
|
I added: |
jonathanpeppers
force-pushed
the
dotnet-aot-issues
branch
from
December 8, 2021 23:35
33d7a12 to
63e7245
Compare
Building a .NET 6 `Release` app with `UseInterpreter=true` and
`RunAOTCompilation=true` would fail with:
Microsoft.Android.Sdk.Aot.targets(71,5): Unknown Mode value: Interpreter. 'Mode' must be one of: Normal,JustInterp,Full,FullInterp,Hybrid,LLVMOnly,LLVMOnlyInterp
Reviewing the code:
https://github.com/dotnet/runtime/blob/60edc0bdafce1849fec19e3ec4f766074de50fc3/src/tasks/AotCompilerTask/MonoAOTCompiler.cs#L1064-L1073
There does not appear to be a mode of `Normal` + `Interp`. So let's
just make AOT take precendence over `$(UseInterpreter)`. On Android
`$(UseInterpreter)` is a Debug-mode setting for Hot Reload.
Building a .NET 6 `Debug` app `RunAOTCompilation=true` would fail with:
Microsoft.Android.Sdk.Aot.targets(49,5): error MSB4044: The "GetAotAssemblies" task was not given a value for the required parameter "AndroidApiLevel".
This is because the linker was skipped, particularly this target:
<Target Name="_PrepareLinking"
Condition=" '$(PublishTrimmed)' == 'true' "
AfterTargets="ComputeResolvedFilesToPublishList"
DependsOnTargets="GetReferenceAssemblyPaths;_CreatePropertiesCache">
`_CreatePropertiesCache` doesn't run, and so we have some empty
properties in this case. We can simply add `_CreatePropertiesCache` to
the `_AndroidAot` MSBuild target's `DependsOnTargets` to solve this
issue.
jonathanpeppers
force-pushed
the
dotnet-aot-issues
branch
from
December 9, 2021 14:47
63e7245 to
40fe05e
Compare
Contributor
Building a .NET 6 `Release` app with `UseInterpreter=true` and
`RunAOTCompilation=true` would fail with:
Microsoft.Android.Sdk.Aot.targets(71,5): Unknown Mode value: Interpreter. 'Mode' must be one of: Normal,JustInterp,Full,FullInterp,Hybrid,LLVMOnly,LLVMOnlyInterp
Reviewing [Mono's AOT code][0]:
public enum MonoAotMode
{
Normal,
JustInterp,
Full,
FullInterp,
Hybrid,
LLVMOnly,
LLVMOnlyInterp
}
There does not appear to be a mode for `Normal` + `Interp`. So let's
instead have AOT take precedence over `$(UseInterpreter)`.
On Android, `$(UseInterpreter)` is a Debug-mode setting for
[Hot Reload][1]; the *expectation* is that AOT won't be enabled in
Debug config builds as Debug builds should be "fast" while AOT builds
are *slow*, so if AOT is explicitly enabled, *presumably* the
developer doesn't want the Interpreter.
To inform developers of this change, we now emit an XA0119 warning
when both `$(UseInterpreter)`=true and `$(RunAOTCompilation)`=true:
dotnet build -p:UseInterpreter=true -p:RunAOTCompilation=true
…
warning XA0119: Disabling the interpreter;
using the interpreter and AOT at the same time is not supported.
Use the interpreter for hot reload support in Debug configurations and
AOT for Release configurations.
While testing this new priority order, we found that building a
.NET 6 `Debug` config app with `$(RunAOTCompilation)`=true would
fail with:
Microsoft.Android.Sdk.Aot.targets(49,5): error MSB4044:
The "GetAotAssemblies" task was not given a value for the required parameter "AndroidApiLevel".
This is because the linker was skipped, particularly this target:
<Target Name="_PrepareLinking"
Condition=" '$(PublishTrimmed)' == 'true' "
AfterTargets="ComputeResolvedFilesToPublishList"
DependsOnTargets="GetReferenceAssemblyPaths;_CreatePropertiesCache">
The `_CreatePropertiesCache` target didn't run, and so we have some
empty properties in this case.
We can simply add `_CreatePropertiesCache` to the `_AndroidAot` MSBuild
target's `DependsOnTargets` to solve this issue.
[0]: https://github.com/dotnet/runtime/blob/60edc0bdafce1849fec19e3ec4f766074de50fc3/src/tasks/AotCompilerTask/MonoAOTCompiler.cs#L1064-L1073
[1]: https://docs.microsoft.com/visualstudio/debugger/hot-reload |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Building a .NET 6
Releaseapp withUseInterpreter=trueandRunAOTCompilation=truewould fail with:Reviewing the code:
https://github.com/dotnet/runtime/blob/60edc0bdafce1849fec19e3ec4f766074de50fc3/src/tasks/AotCompilerTask/MonoAOTCompiler.cs#L1064-L1073
There does not appear to be a mode of
Normal+Interp. So let'sjust make AOT take precendence over
$(UseInterpreter). On Android$(UseInterpreter)is a Debug-mode setting for Hot Reload.Building a .NET 6
DebugappRunAOTCompilation=truewould fail with:This is because the linker was skipped, particularly this target:
_CreatePropertiesCachedoesn't run, and so we have some emptyproperties in this case. We can simply add
_CreatePropertiesCachetothe
_AndroidAotMSBuild target'sDependsOnTargetsto solve thisissue.