CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 137
Native Apple Silicon support (m1) #586
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
Conversation
This commit changes the way compilation is done using CMake. As its a mess in CMake under Apple target as its actively injects parameters Arch, SYSROOT parameters. That makes compilation for different arches for iOS/MacOS cross compilation problematic as we can't control these params (already present from CMake). The only way to make it do what expected is to tell CMake we are doing cross compilation by specifying `CMAKE_SYSTEM_NAME`. In this case it will try to provide SYSROOT but it can be controlled by overriding `CMAKE_OSX_SYSROOT`. Another problem that was solved -- is lack of `LC_BUILD_VERSION`(replaces `LC_VERSION_MIN_IPHONEOS`) mach-o command in generated object files. It provides extended information about target build and allows in particular to make difference between `aarch64` builds made for iPhone/Simulator/MacOSX: ``` struct build_version_command { uint32_t cmd; // LC_BUILD_VERSION uint32_t cmdsize; // sizeof(struct build_version_command) + // ntools * sizeof(struct build_tool_version) uint32_t platform; // platform uint32_t minos; // X.Y.Z is encoded in nibbles xxxx.yy.zz uint32_t sdk; // X.Y.Z is encoded in nibbles xxxx.yy.zz uint32_t ntools; // number of tool entries following this }; // Values for platform field in build_version_command. enum PlatformType { PLATFORM_MACOS = 1, PLATFORM_IOS = 2, PLATFORM_TVOS = 3, PLATFORM_WATCHOS = 4, PLATFORM_BRIDGEOS = 5, PLATFORM_MACCATALYST = 6, PLATFORM_IOSSIMULATOR = 7, PLATFORM_TVOSSIMULATOR = 8, PLATFORM_WATCHOSSIMULATOR = 9, PLATFORM_DRIVERKIT = 10, }; ``` `LC_BUILD_VERSION` is missing in `LLVM 3.6` we use for RoboVM. Required functionality was picked from `LLVM 12` and injected by patch provided in this commit.
This commit changes the way compilation is done using CMake. As its a mess in CMake under Apple target as its actively injects parameters Arch, SYSROOT parameters. That makes compilation for different arches for iOS/MacOS cross compilation problematic as we can't control these params (already present from CMake). The only way to make it do what expected is to tell CMake we are doing cross compilation by specifying `CMAKE_SYSTEM_NAME`. In this case it will try to provide SYSROOT but it can be controlled by overriding `CMAKE_OSX_SYSROOT`.
Sources for this lib was missing in project. Picked from https://github.com/robovm/hfscompressor, adapted to build using CMake and recent dependencies. Added option to compile for both `macosx-arm64` and `macosx-x86_64`. `HfsCompressor.java` update to load platform specific binary
This commit adds `Environment (Native/Simulator)` option that allows makes targets different when building for Arch. For example build for `arm64` now could be targeted to `ios-arm64`, `macosx-arm64`, `ios-arm64-simulator`. LLVM detects proper target from triple and it is being generated now with respect to `Environment` option. Also linker `-miphoneos-version-min=` parameter was replaced with `--target=` one that accepts the tripple. Changes were done to folder names: environment is being attached to every arch name where applicable. For example: ``` vm/lib/arm64/ vm/lib/arm64-simulator vm/lib/thumbv7 vm/lib/x86-simulator vm/lib/x86_64-simulator ```
CMake was adapted to workaround mess on Apple platform. Using cross compilation mode. Targets were extended to produce binaries for additional targets: `macosx-arm64`, `ios-arm64-simulator`
Logic addapted to following: - simulator considered to have `arm64` arch only on m1 host and if its ios version is 14+ - x86 simulator is not available on `arm64` m1 host
- console target now has arch option that allows to select x86_64/arm64 target on m1 silicon; - `auto` simulator arch is set to the on of the host. E.g. on m1 will be set to `arm64`
These issues were discovered during run against debug version of llvm lib and crashes happened on assertions: * llvm: changed Load/Store atomic access ordering from `unordered` to `monotonic` as it was crashing during AtomicExpandPass for x86 target. Line of code where it crashing `getStrongestFailureOrdering`. In release build with assertions removed it falls down into `Monotonic` case anyway. * bug fixed: wrong calculation of struct offset for Vectorized Structs. Root case is that vector was wrapped into single element struct like `{<2 x float>}` and any try to get offset for member 1+ returns garbage (or crash on assert in debug version of llvm). Workaround -- getting element storage size and multiply by index
while `macos-latest` is 10.15 its not able to build m1 `macosx-arm64` target. But `x86_64` can be build. these allows to build libhfs, libmobiledevice, libllvm natives. In case of success build new branch with artifacts is pushed. It can be then merged into master. Build are triggered manually and are parametrized: - "Arguments to build.sh" -- allows specify single target to build; - "Target branch to push artifacts" -- name of the branch were built artifacts will be pushed; - "Commit message" -- message to be used while committing changes
…target` with triple is used for this now
Just as feedback: I just got an M1 mac and could successfuly build my ios app with the I am using the same provisioning profile as on my other mac, and I verified that the certificates are installed and the ids are matching. Do you have any idea why this could be happening? Or is this not related to the changes for M1 support? Edit: |
Update 2: Nevermind, xcode did some wired things with my provisioning profile. It's all working now, thanks for your hard work! Is this build already ready for prime time or would you expect some issues to appear? |
I found an issue when trying to deploy to an ios simulator. I'm using a custom libgdx build with all native dependencies for M1 included and I can build M1 and ios device builds successfully. However when trying to run in an emulator I get: The full error and command executed are below. I can run the same build on a regular mac in the simulator.
any ideas? |
Any update on this? If you need any more details let me know. I really start to need M1 support since my old mac is EOL |
Anyone can accept this PR, we need to build on Mac M1 |
You need to fix the certificate, check in Keychain Access if your certificate is not trusted, you need to download new Apple Worldwide Developer Relations Certification Authority certificate. When your certificate is valid, you could build without any problem |
native binaries have been built using GitHub actions and merged into this branch |
This PR introduces changes that allows RoboVM compiler to run natively on
m1/arm64
MacOSX host.How fast is m1:
(compiling classes using 8 threads)
How to test
Binaries available for testing at robovm experimental fork;
Following was done:
libllvm
andlibimobiledevice
were cross compiled forarm64-apple-macosx
target;libhfscompressor
was introduces (as sources were missing) and also recompiled forarm64-apple-macosx
target;llvm3.6
was frankensteined with parts ofllvm12
source code to supportLC_BUILD_VERSION
mach-o command in object files;environment
entity was added to pair ofos
andarch
to allow make difference between different targets but same arch, e.g.:arm64-apple-ios
,arm64-apple-ios-simulator
andarm64-apple-macos
;arm64
arch can be used for iOS simulator and MacOS console targets;arm64
simulator and MacOS console corresponding VM native libraries variants are now built;arm64-simulator
,x86_64-simulator
;native libraries
UPDATE: Were built using Github Action using macos11 runner
libimobiledevice was not tested
Have no M1 at table and used one in cloud. Deployment to device was not tested