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

LLVM AOT doesn't work on MacCatalyst #57589

Closed
filipnavara opened this issue Aug 17, 2021 · 5 comments · Fixed by #57687
Closed

LLVM AOT doesn't work on MacCatalyst #57589

filipnavara opened this issue Aug 17, 2021 · 5 comments · Fixed by #57687
Assignees
Milestone

Comments

@filipnavara
Copy link
Member

Description

Example application (create from empty project with modified .csproj):
Archive.zip

Configuration

.NET 6.0.100-rc.1.21415.3
macOS 12.0 Beta
Xcode 13 beta 4 (iirc)

Regression?

It probably never worked?

Other information

  ld: building for Mac Catalyst, but linking in object file built for , file '/Users/filipnavara/Projects/llvmbug/obj/Debug/net6.0-maccatalyst/maccatalyst-arm64/nativelibraries/aot-output/arm64/llvmbug.dll.llvm.o'
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  
/usr/local/share/dotnet/packs/Microsoft.MacCatalyst.Sdk/15.0.100-preview.7.230/targets/Xamarin.Shared.Sdk.targets(847,3): error : clang++ exited with code 1 [/Users/filipnavara/Projects/llvmbug/llvmbug.csproj]
/usr/local/share/dotnet/packs/Microsoft.MacCatalyst.Sdk/15.0.100-preview.7.230/targets/Xamarin.Shared.Sdk.targets(847,3): error :          [/Users/filipnavara/Projects/llvmbug/llvmbug.csproj]

Looks like the LLVM compiler didn't get passed the -target arm64-apple-ios14.2-macabi. Note that other targets use -mtriple=... which doesn't work on MacCatalyst AFAIK.

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Aug 17, 2021
@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@lambdageek lambdageek added this to the 6.0.0 milestone Aug 18, 2021
@lambdageek
Copy link
Member

/cc @imhameed @SamMonoRT

@lambdageek
Copy link
Member

Update /cc @directhex @akoeplinger - may just be an issue with the AOT compiler task, not with codegen per se

@ghost
Copy link

ghost commented Aug 18, 2021

Tagging subscribers to this area: @directhex
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

Example application (create from empty project with modified .csproj):
Archive.zip

Configuration

.NET 6.0.100-rc.1.21415.3
macOS 12.0 Beta
Xcode 13 beta 4 (iirc)

Regression?

It probably never worked?

Other information

  ld: building for Mac Catalyst, but linking in object file built for , file '/Users/filipnavara/Projects/llvmbug/obj/Debug/net6.0-maccatalyst/maccatalyst-arm64/nativelibraries/aot-output/arm64/llvmbug.dll.llvm.o'
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  
/usr/local/share/dotnet/packs/Microsoft.MacCatalyst.Sdk/15.0.100-preview.7.230/targets/Xamarin.Shared.Sdk.targets(847,3): error : clang++ exited with code 1 [/Users/filipnavara/Projects/llvmbug/llvmbug.csproj]
/usr/local/share/dotnet/packs/Microsoft.MacCatalyst.Sdk/15.0.100-preview.7.230/targets/Xamarin.Shared.Sdk.targets(847,3): error :          [/Users/filipnavara/Projects/llvmbug/llvmbug.csproj]

Looks like the LLVM compiler didn't get passed the -target arm64-apple-ios14.2-macabi. Note that other targets use -mtriple=... which doesn't work on MacCatalyst AFAIK.

Author: filipnavara
Assignees: -
Labels:

untriaged, area-Infrastructure-mono, os-maccatalyst

Milestone: 6.0.0

@steveisok steveisok removed the untriaged New issue has not been triaged by the area owner label Aug 18, 2021
@directhex
Copy link
Member

Update /cc @directhex @akoeplinger - may just be an issue with the AOT compiler task, not with codegen per se

the error in Filip's output sure looks that way

directhex added a commit to directhex/runtime that referenced this issue Aug 18, 2021
Effectively, we are correctly saying "build a Mac Catalyst app from runtime
and these `-llvm.o` files, but the `-llvm.o` files are not correctly being
built in a Mac Catalyst compatible way, resulting in the error

```
  ld: building for Mac Catalyst, but linking in object file built for , file '/Users/filipnavara/Projects/llvmbug/obj/Debug/net6.0-maccatalyst/maccatalyst-arm64/nativelibraries/aot-output/arm64/llvmbug.dll.llvm.o'
```

The target platform parameter gets passed around a LOT -
`src/tasks/AotCompilerTask/MonoAOTCompiler.props` specifies
`<MonoAOTCompilerDefaultAotArguments Condition="'$(TargetArchitecture)' == 'arm64'" Include="mtriple=arm64-ios" />`
which passes through to MonoAOTCompiler.cs task which passes through to
the `mono --aot=llvmopts=mtriple=arm64-ios` flag, which is processed by
`src/mono/mono/mini/aot-compiler.c` and eventually regurgitated as
`llc -mtriple=arm64-ios -march=aarch64`, which results in .o files which
lack the required annotations to be considered Catalyst compatible.

Thankfully, it seems that `llc` accepts `clang`'s `-target` triplet
values as valid for `-mtriple`, so passing through Catalyst specific
values for `mtriple` in `MonoAOTCompiler.props` results in .o files
which are correctly linked later by `clang` during the AppleAppBuilder
task.

It's slow though! 🙀

Fixes dotnet#57589
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Aug 18, 2021
akoeplinger pushed a commit that referenced this issue Aug 19, 2021
…57687)

Effectively, we are correctly saying "build a Mac Catalyst app from runtime
and these `-llvm.o` files, but the `-llvm.o` files are not correctly being
built in a Mac Catalyst compatible way, resulting in the error

```
  ld: building for Mac Catalyst, but linking in object file built for , file '/Users/filipnavara/Projects/llvmbug/obj/Debug/net6.0-maccatalyst/maccatalyst-arm64/nativelibraries/aot-output/arm64/llvmbug.dll.llvm.o'
```

The target platform parameter gets passed around a LOT -
`src/tasks/AotCompilerTask/MonoAOTCompiler.props` specifies
`<MonoAOTCompilerDefaultAotArguments Condition="'$(TargetArchitecture)' == 'arm64'" Include="mtriple=arm64-ios" />`
which passes through to MonoAOTCompiler.cs task which passes through to
the `mono --aot=llvmopts=mtriple=arm64-ios` flag, which is processed by
`src/mono/mono/mini/aot-compiler.c` and eventually regurgitated as
`llc -mtriple=arm64-ios -march=aarch64`, which results in .o files which
lack the required annotations to be considered Catalyst compatible.

Thankfully, it seems that `llc` accepts `clang`'s `-target` triplet
values as valid for `-mtriple`, so passing through Catalyst specific
values for `mtriple` in `MonoAOTCompiler.props` results in .o files
which are correctly linked later by `clang` during the AppleAppBuilder
task.

It's slow though! 🙀

Fixes #57589
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Aug 19, 2021
mdh1418 pushed a commit to mdh1418/runtime that referenced this issue Sep 9, 2021
…otnet#57687)

Effectively, we are correctly saying "build a Mac Catalyst app from runtime
and these `-llvm.o` files, but the `-llvm.o` files are not correctly being
built in a Mac Catalyst compatible way, resulting in the error

```
  ld: building for Mac Catalyst, but linking in object file built for , file '/Users/filipnavara/Projects/llvmbug/obj/Debug/net6.0-maccatalyst/maccatalyst-arm64/nativelibraries/aot-output/arm64/llvmbug.dll.llvm.o'
```

The target platform parameter gets passed around a LOT -
`src/tasks/AotCompilerTask/MonoAOTCompiler.props` specifies
`<MonoAOTCompilerDefaultAotArguments Condition="'$(TargetArchitecture)' == 'arm64'" Include="mtriple=arm64-ios" />`
which passes through to MonoAOTCompiler.cs task which passes through to
the `mono --aot=llvmopts=mtriple=arm64-ios` flag, which is processed by
`src/mono/mono/mini/aot-compiler.c` and eventually regurgitated as
`llc -mtriple=arm64-ios -march=aarch64`, which results in .o files which
lack the required annotations to be considered Catalyst compatible.

Thankfully, it seems that `llc` accepts `clang`'s `-target` triplet
values as valid for `-mtriple`, so passing through Catalyst specific
values for `mtriple` in `MonoAOTCompiler.props` results in .o files
which are correctly linked later by `clang` during the AppleAppBuilder
task.

It's slow though! 🙀

Fixes dotnet#57589
@ghost ghost locked as resolved and limited conversation to collaborators Sep 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants