Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MacOS] The AOT compiler '' does not exist. #9093

Closed
bstrother1 opened this issue Jun 22, 2022 · 14 comments · Fixed by #9118
Closed

[MacOS] The AOT compiler '' does not exist. #9093

bstrother1 opened this issue Jun 22, 2022 · 14 comments · Fixed by #9118
Assignees
Labels
area/build Categorizes an issue or PR as relevant to build infrastructure difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working platform/macos 🍏 Categorizes an issue or PR as relevant to the macOS platform

Comments

@bstrother1
Copy link

Current behavior

Getting The AOT compiler '' does not exist. When trying to run MacOS after following (#7833). Attached is the MSBuild binlog. I'm on the latest uno-check: v1.5.0.0 Uno-template: 4.4.0-dev.302, everything passes with green outside of recommending Download .NET SDK (6.0.400-preview.22301.10)

msbuild.binlog.zip

Expected behavior

For MacOS to build

How to reproduce it (as minimally and precisely as possible)

-Be on latest Uno Check/Template
-Make Project
-Try to build MacOS

  • AOT does not exist

Workaround

N/A

Works on UWP/WinUI

Yes

Environment

Uno.UI / Uno.UI.WebAssembly / Uno.UI.Skia

NuGet package version(s)

PackageReference Include="Uno.UI" Version="4.4.0-dev.302"
PackageReference Include="Uno.UI.RemoteControl" Version="4.4.0-dev.302 Condition="'$(Configuration)'=='Debug'"
PackageReference Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" Version="4.4.0-dev.302"
PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0"
PackageReference Include="Microsoft.Extensions.Logging.Console" Version="5.0.0"

Affected platforms

macOS

IDE

Visual Studio 2022

IDE version

17.3 Preview (17.3 build 1038)

Relevant plugins

No response

Anything else we need to know?

This is occurring on an ARM64 environment and occurs both when building using Visual Studios and When running from the command line. MacCatalyst does build from the command line but there doesn't
seem to be a way to specify to run Catalyst from Visual Studios.

@bstrother1 bstrother1 added difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification labels Jun 22, 2022
@jeromelaban jeromelaban added platform/macos 🍏 Categorizes an issue or PR as relevant to the macOS platform area/build Categorizes an issue or PR as relevant to build infrastructure and removed triage/untriaged Indicates an issue requires triaging or verification labels Jun 22, 2022
@spouliot
Copy link
Contributor

Thanks for the instructions and binlogs. I'll ask a look ASAP...

At first glance it seems something inside the msbuild files must be incorrect, like not guarded by a proper condition.

net6.0-macos is based on CoreCLR, not Mono [1], like the Xamarin.Mac (legacy) SDK was using. As such there's no AOT compiler currently [2] available for the macOS platform.

[1] unlike other Xamarin workloads. Even the new macCatalyst support is based on the Mono runtime as it requires Full AOT to be able to submit applications (not possible with CoreCLR).

[2] that might change in the future, net7.0 adds support for Native AOT - but I'm not sure it's compatible with macOS yet.

@spouliot
Copy link
Contributor

The attached msbuild.binlog fails, quite early, with

/Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/msbuild/Current/bin/NuGet.targets(131,5): Invalid restore input. Invalid framework identifier ''.
Invalid framework identifier ''. [/Users/brittanystrother/Documents/Repos/TestingLatest/TestingLatest.Mobile/TestingLatest.Mobile.csproj]

There's no mention of AOT inside the logs.

Maybe it's a different file ? Can you try again and upload the correct one ? Thanks!

@bstrother1
Copy link
Author

The attached msbuild.binlog fails, quite early, with

/Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/msbuild/Current/bin/NuGet.targets(131,5): Invalid restore input. Invalid framework identifier ''.
Invalid framework identifier ''. [/Users/brittanystrother/Documents/Repos/TestingLatest/TestingLatest.Mobile/TestingLatest.Mobile.csproj]

There's no mention of AOT inside the logs.

Maybe it's a different file ? Can you try again and upload the correct one ? Thanks!

For this I ran:

  1. dotnet new unoapp-net6 -o TestApplication

  2. Ran: dotnet build TestApplication.Mobile -t:Run -f net6.0-macos

    1. Got /usr/local/share/dotnet/packs/Microsoft.macOS.Sdk/12.3.311/targets/Xamarin.Shared.Sdk.targets(973,3): error : The AOT compiler '' does not exist.
  3. Then went inside TestApplication.Mobile and ran msbuild /r /bl TestApplication.Mobile.csproj

    1. /Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/msbuild/Current/bin/NuGet.targets(131,5): error : Invalid restore input. Invalid framework identifier ''.
    2. /Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/msbuild/Current/bin/NuGet.targets(131,5): error : Invalid framework identifier ''.

msbuild.binlog.zip

@spouliot
Copy link
Contributor

Same result - but now I know why :)

The /bl of step 3 is what is creating the binlog file. That will only include what the msbuild command has done and the Invalid framework identifier ''. failure.

IOW what happened in step 2 will not be part of the binlog.

To get the AOT error inside the binlog you need to do

dotnet build TestApplication.Mobile -t:Run -f net6.0-macos -bl

for your step 2. The -bl argument will create the binlog.

And there's no step 3! If you do it then it would overwrite the msbuild.binlog from step 2.

FWIW you should not have to use msbuild command when dealing with net6 projects. Everything you need should be done thru the dotnet command.

@bstrother1
Copy link
Author

dotnet build TestApplication.Mobile -t:Run -f net6.0-macos -bl

Sorry about that. Here is the corrected build log.
msbuild.binlog.zip

@spouliot
Copy link
Contributor

The _RunAotCompiler variable gets set to false (normal) and then to true (not normal for macOS).

Screen Shot 2022-06-23 at 3 02 02 PM

but none of the condition seems to allow that

<PropertyGroup Condition="'$(_RunAotCompiler)' == ''">
	<!-- Don't run the AOT compiler by default -->
	<_RunAotCompiler>false</_RunAotCompiler>
	<!-- We need it for device builds for mobile platforms -->
	<_RunAotCompiler Condition="'$(_SdkIsSimulator)' != 'true' And '$(_PlatformName)' != 'macOS' And '$(_PlatformName)' != 'MacCatalyst'">true</_RunAotCompiler>
	<!-- We need it if the interpreter is enabled, no matter where -->
	<_RunAotCompiler Condition="'$(MtouchInterpreter)' != ''">true</_RunAotCompiler>
	<!-- We need it for Mac Catalyst on arm64 -->
	<_RunAotCompiler Condition="'$(RuntimeIdentifier)' == 'maccatalyst-arm64'">true</_RunAotCompiler>
	<!-- We need it for iOS/tvOS simulator on arm64 -->
	<_RunAotCompiler Condition="'$(RuntimeIdentifier)' == 'iossimulator-arm64' Or '$(RuntimeIdentifier)' == 'tvossimulator-arm64'">true</_RunAotCompiler>
</PropertyGroup>

Step by step

  1. _PlatformName is macOS so the first condition is not applied;
  2. MtouchInterpreter is set to all so the second condition is applied ‼️
  3. RuntimeIdentifier is osx-x64 so the 3rd condition is not applied;
  4. RuntimeIdentifier is osx-x64 so the 4th condition is not applied;

so the final value should be false... but something is setting MtouchInterpreter and breaking the build.

As a temporary workaround can you try to add the following XML inside your .csproj file ?

<PropertyGroup>
	<MtouchInterpreter></MtouchInterpreter>
</PropertyGroup>

That should empty the variable and take precedence over the all value.

Unrelated / Side note

net6.0-macos defaults to osx-x64 even on a arm64 computer. This will run fine because Rosetta will translate it to arm64 code. However performance will suffer.

You can add <RuntimeIdentifier>osx-arm64</RuntimeIdentifier> in a property group of you .csproj file to generate a arm64 executable and better performance.

@spouliot
Copy link
Contributor

This happens because of

<!-- Required for C# Hot Reload -->
<UseInterpreter Condition="'$(Configuration)' == 'Debug' and '$(TargetFramework)' != 'net6.0-maccatalyst'">True</UseInterpreter>

inside src/SolutionTemplate/UnoSolutionTemplate.net6/Mobile/UnoQuickStart.Mobile.csproj

while it's commented inside src/SolutionTemplate/UnoSolutionTemplate.WinUI.net6/Mobile/UnoQuickStart.Mobile.csproj for a different issue.

At least in theory net6.0-macos uses CoreCLR and does not need the interpreter (like Windows) for Hot Reload. I say in theory because I have not used hot reload for net-6.0-macos yet 😄

I also did not hit this issue personally because I'm doing benchmarks and always uses Release (not Debug) on net6 targets.

@spouliot
Copy link
Contributor

It's not clear why the interpreter was disabled for macCatalyst (which is mono based) inside 1e252d5
Maybe an old bug ? c.c. @jeromelaban

@spouliot
Copy link
Contributor

@bstrother1 an alternative (easier) workaround is to delete

<UseInterpreter Condition="'$(Configuration)' == 'Debug' and '$(TargetFramework)' != 'net6.0-maccatalyst'">True</UseInterpreter>

inside your .csproj file

@bstrother1
Copy link
Author

bstrother1 commented Jun 23, 2022

This happens because of

<!-- Required for C# Hot Reload -->
<UseInterpreter Condition="'$(Configuration)' == 'Debug' and '$(TargetFramework)' != 'net6.0-maccatalyst'">True</UseInterpreter>

inside src/SolutionTemplate/UnoSolutionTemplate.net6/Mobile/UnoQuickStart.Mobile.csproj

while it's commented inside src/SolutionTemplate/UnoSolutionTemplate.WinUI.net6/Mobile/UnoQuickStart.Mobile.csproj for a different issue.

At least in theory net6.0-macos uses CoreCLR and does not need the interpreter (like Windows) for Hot Reload. I say in theory because I have not used hot reload for net-6.0-macos yet 😄

I also did not hit this issue personally because I'm doing benchmarks and always uses Release (not Debug) on net6 targets.

Attempted:
<When Condition="'$(TargetFramework)'=='net6.0-macos'"> <PropertyGroup> <MtouchInterpreter></MtouchInterpreter> <TrimMode Condition="'$(Configuration)'=='Release'">link</TrimMode> </PropertyGroup> </When>

Still running into AOT bug. Are you running from Visual Studios with the release version or the command line? Attempting to run TestApplication.Mobile > Release > My Mac results in

Done building project "TestApplication.Mobile.csproj" -- FAILED.

@bstrother1
Copy link
Author

TestApplication/TestApplication.Mobile/Resources/values/resources_resw-strings.xml: Error APT2126: file not found. (APT2126) (TestApplication.Mobile)

@spouliot
Copy link
Contributor

Did removing <UseInterpreter ...> help ?

APT2126 looks like an Android (not macOS) error code. That should not be hit when using -f net6.0-macos.

Can you attach a newer binlog ? thanks!

@jeromelaban
Copy link
Member

@spouliot The interpreter has some issues with trampolines management: dotnet/runtime#68808.

@bstrother1
Copy link
Author

Did removing <UseInterpreter ...> help ?

APT2126 looks like an Android (not macOS) error code. That should not be hit when using -f net6.0-macos.

Can you attach a newer binlog ? thanks!

Ran dotnet build -c Release TestApplication.Mobile -t:Run -f net6.0-macos -bl and it built. This seems to be specific running it within Visual Studios.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/build Categorizes an issue or PR as relevant to build infrastructure difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working platform/macos 🍏 Categorizes an issue or PR as relevant to the macOS platform
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants