-
Notifications
You must be signed in to change notification settings - Fork 177
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
Support for arm64 simulator builds for iOS #588
Comments
I've no experience with IOS or Mac in general. But still have some questions:
|
We pull in quite a few projects but including OpenCV, Boost, protobuf, Jpeg. I could go on. Second question I don't know the answer to but I think the problem is not so much in the cmake packages but those like Boost which are built using other tools. |
@john-forrest This issue has nothing to do with Hunter, it's a polly/CMake/Xcode one. AFAIK you won't be able to build combined ios/sim binaries due to outstanding issues in CMake and Xcode. You can build a standalone sim binary with polly: You can also build various standalone binaries with another toolchain, like https://github.com/leetal/ios-cmake |
@drodin it might be wishful thinking on your part that this has nothing to do with hunter but note lines like:
where simulator is always x86. I found others. As said, the issue in hunter is where the projects are built via autotools or other non-cmake packages. However thanks for the tip in polly. I will try although given the Boost issue I raise, I am slightly sceptical:) |
@john-forrest : How do you make your iOS builds work? I keep getting the following error when experimenting with really simple projects (i.e. just Hunter, ZLIB and one cpp file). Do you use Polly's
@drodin : Are there any CMake upstream issues (perhaps at gitlab.kitware.com) which interested parties should be watching or helping with? |
@hjmallon If you want to build for device only, use polly's
|
@drodin thanks for getting back to me (I'm interested in getting iOS working for my project but I have little experience with it). I think I have fixed problem You should be able to test it with the following: HunterGate(
URL "https://github.com/hjmallon/hunter/archive/_hm_ios_install_fix.zip"
SHA1 "dce6d8a2f3f5eedf03116b6fbc90a34329f50d8c"
) |
It sounds like the wider issue about ARM64 Simulator Combined builds is not yet solved upstream. I personally do not use an Apple Silicon macOS machine, so do not hit the problem (yet...). My notes:
|
Sorry I am following this iOS journey myself for a project, so my thoughts might appear slightly scattered, but they are all hopefully relevant. Since we can no longer make successful fat binaries for arm64-device/x86_64-sim/arm64-sim then we need to work out a workaround.
I don't know which works better for others but I think option 1 seems the cheapest. As you say there are various places in the Hunter codebase which assume things about The easiest way to fix these is probably to try your builds with a toolchain based on ios-nocodesign-arm64.cmake, but with the following patch (to enable arm64/x86_64 simulator builds). diff --git a/ios-nocodesign-arm64.cmake b/ios-nocodesign-arm64.cmake
index c5a7216..5a2b4df 100644
--- a/ios-nocodesign-arm64.cmake
+++ b/ios-nocodesign-arm64.cmake
@@ -30,9 +30,12 @@ set(CMAKE_MACOSX_BUNDLE YES)
include("${CMAKE_CURRENT_LIST_DIR}/flags/ios_nocodesign.cmake")
-set(IPHONEOS_ARCHS arm64)
-set(IPHONESIMULATOR_ARCHS "")
+set(IPHONEOS_ARCHS "")
+set(IPHONESIMULATOR_ARCHS "arm64;x86_64")
include("${CMAKE_CURRENT_LIST_DIR}/compiler/xcode.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/os/iphone.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/flags/cxx14.cmake")
+
+set(CMAKE_OSX_SYSROOT "iphonesimulator" CACHE STRING "System root for iOS" FORCE)
+set(CMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH NO CACHE STRING "") I have found that there is a bug in the default hunter cmake setup with this, patch to follow. |
PR to fix fat-simulator-only builds for Hunter cmake schemes is here #610. More work will be needed to fix non-CMake projects. |
I raised this on gitter.im but not sure anyone reads that much now, so excuse the double request. The request is quite simple: has anyone managed to build arm64 binaries for ios simulators, preferable combined ones with x64?
Some of our mobile engineers now have Macs with M1 processors and can't handle the x64 binaries we traditionally send them. From what I can see, I need to build a fat binary where the arm64 binary is built for iphonesimulator, iphoneos. Even creating a polly toolchain where the IPHONEOS_ARCHS is empty does not seem to be supported, but inside hunter there is logic which seems to assume arm architectures mean device and x86 architectures mean simulator. I support a forked hunter anyway, but it feels like I am having to do a lot of change to support this. I am wondering if I have missed a trick or (it feels) nobody has so far tried to do this.
Going forward it seems we need to have two build jobs for iOS: one for device (currently just arm64) and one for simulator (will be both x86 and arm64). (The two arm64 builds are different.) This will be fed into the new xcframework model, where there will be two .a files and not a single one as at present.
The text was updated successfully, but these errors were encountered: