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

Cross-compile Wasm cross-compilers for ARM64 machines #74428

Conversation

directhex
Copy link
Contributor

@directhex directhex commented Aug 23, 2022

This PR enables building arbitrary cross-compilers for non-x64 hosts. Right now, only osx-arm64->browser-wasm and linux-arm64->browser-wasm are actually enabled, as runtime bugs prevent us from building any arm64->x86 or arm64->x64 cross-compilers. Getting this framework in will unblock workload work related to "native" wasm on M1 Mac.

BREAKING CHANGE FOR DEVELOPERS

MonoAOTLLVMDir no longer exists.

Old:

  • /p:MonoLLVMDir=/path/to/llvm specifies the directory with LLVM binaries compiled for $(TargetArchitecture), for compiling the Mono JIT on that target architecture
  • /p:MonoAOTLLVMDir=/path/to/llvm specifies the directory with LLVM binaries compiled for $(BuildArchitecture), for compiling the mono-aot-cross executable

New:

  • /p:MonoLLVMDir=/path/to/llvm specifies a parent-level directory with LLVM binaries compiled for relevant architectures - e.g. $(MonoLLVMDir)\x64 contains LLVM built for x64, current OS. $(MonoLLVMDir)\arm64 contains LLVM built for arm64, current OS.

You do not need to specify /p:MonoLLVMDir= manually, unless you are a developer who may be using custom, non-nupkg LLVM (i.e. your name is Zoltan)

This change is necessary to stop hardcoding the assumptions that a) $(BuildArchitecture) is always x64 and b) AOT binaries should be compiled for $(BuildArchitecture)

Closes: #74175

Mostly builds android-arm64 cross compiler for linux-arm64 on linux-x64, but
fails on linker step as we still try to use linux-x64 LLVM for linking.
@ghost
Copy link

ghost commented Aug 23, 2022

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

Issue Details

So far, I know this lets me build an android-arm64 cross-compiler for linux-arm64 from a linux-x64 host. Let's see what I broke

Closes: #74175

Author: directhex
Assignees: directhex
Labels:

area-Infrastructure-mono

Milestone: -

@directhex directhex changed the title Yo dawg i heard you like cross compilers so i cross compiled your cross compiler Cross-compile cross-compilers for non-x64 machines Aug 23, 2022
@directhex
Copy link
Contributor Author

Dunno about CI, but I've validated locally that this is producing what I expect.

Successfully created package '/Users/directhex/Projects/runtime/artifacts/packages/Release/Shipping/Microsoft.NETCore.App.Runtime.AOT.osx-arm64.Cross.browser-wasm.8.0.0-dev.nupkg'.

artifacts/bin/mono/OSX.arm64.Release/cross/osx-arm64/browser-wasm/mono-aot-cross: Mach-O 64-bit executable arm64

@directhex
Copy link
Contributor Author

Windows remains "entirely cursed" at this point.

When someone can show me a Mono JIT build for Windows ARM64, I will make a win-arm64->browser-wasm cross-compiler happen

…ike-cross-compilers-so-i-cross-compiled-your-cross-compiler
@directhex
Copy link
Contributor Author

I had to rebase this for an LLVM version bump in main.

@@ -170,11 +170,13 @@ jobs:
- eng/Versions.props
- eng/testing/scenarios/BuildWasmAppsJobsList.txt
- eng/testing/workloads-testing.targets
- src/installer/pkg/sfx/Microsoft.NETCore.App/*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@directhex
Copy link
Contributor Author

I don't think any test failures are related to my changes?

@radical
Copy link
Member

radical commented Jan 5, 2023

I don't think any test failures are related to my changes?

nope

Copy link
Member

@lewing lewing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@mmitche
Copy link
Member

mmitche commented Jan 6, 2023

@directhex
Copy link
Contributor Author

@mmitche I'll try to reproduce it

@directhex
Copy link
Contributor Author

I'm narrowing in on where it's going wrong - when monoaotcross.proj calls into sub-projects to do the cross-compiler builds, it's using a PackageRID of osx-wasm instead of browser-wasm, which causes mono-aot-cross to be copied to the wrong directory. I'm not certain why yet.

@directhex
Copy link
Contributor Author

Problem is specific to /p:CrossBuild=true.

@directhex
Copy link
Contributor Author

Working locally via #80316

radical pushed a commit that referenced this pull request Jan 7, 2023
Resolves official build breakage caused by #74428 (where `PackageRID` can be `linux-wasm` or `osx-wasm` instead of `browser-wasm` when `/p:PortableBuild=true`, but `OutputRid` is fine)
@ghost ghost locked as resolved and limited conversation to collaborators Feb 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[mono] Build native osx-arm64 versions of the cross compilers
6 participants