flipper: Apple M1 chip: ARM64 simulator build fails / CocoaLibEvent

🐛 Bug Report

The PR #1735 fixes part of the issue with building Flipper for the Arm64 iOS simulator used on M1 Macs.

Even though the fix above is not yet released, I was able to test it via the mechanism described in this post: https://github.com/facebook/react-native/pull/30543#issuecomment-743753611

However, linking now fails with this error:

in .../ios/Pods/CocoaLibEvent/lib/libevent.a(buffer.o), building for iOS Simulator, but linking in object file built for iOS, file '.../ios/Pods/CocoaLibEvent/lib/libevent.a' for architecture arm64

See:

https://github.com/facebook/flipper/blob/031cec299b527975cd1e252177372bb33cb0ae18/iOS/Podspecs/Flipper-Folly.podspec#L20 https://github.com/e314521/CocoaLibEvent

That library seems pretty obscure and doesn’t seem maintained at all.

To Reproduce

Use an M1 mac, replace use_flipper! with use_flipper!('Flipper-Folly' => { :podspec => 'https://raw.githubusercontent.com/facebook/flipper/master/iOS/Podspecs/Flipper-Folly.podspec' } ). Run build in XCode, see above error.

Environment

MacOS Big Sur 11.0.1 Mac Mini with M1 chip

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 21 (10 by maintainers)

Most upvoted comments

Small update: we are currently looking into it. So hopefully we will be able to address it this week or next week. It might be the case that we can address it only in the next RN release, not sure about that yet.

Check, thanks for the update, I’ll check if I can find someone for this tomorrow. We will probably need help with testing 😊

On Thu, 28 Jan 2021, 18:43 Andrei Alecu, notifications@github.com wrote:

With Flipper being enabled by default and part of the official RN documentation, it seems like RN isn’t going to advertise Apple Silicon support until Flipper works.

So RN is blocked on this issue itself.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/facebook/flipper/issues/1758#issuecomment-769293729, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAN4NBFPREZIPIM5RT577FTS4GV4PANCNFSM4UYFFQAQ .

With Flipper being enabled by default and part of the official RN documentation, it seems like RN isn’t going to advertise Apple Silicon support until Flipper works.

So RN is blocked on this issue itself.

yes it does work out of the box, but flipper does not. I’ve kept the issue open because flipper does not work

Doesn’t seem likely that the base library will ever be updated by the looks of it.

I posted steps on how to fix it above, someone needs to step up. I’d do it but I’m not familiar enough with the native mac development intricacies.

I spent some time looking into what it would take to update the binaries to be compatible and here are my findings:

I worked on an updated script that will build libevent correctly for all targets, including arm64 iPhoneSimulator: https://gist.github.com/andreialecu/2cc00a5e7212bf3b935afd015d693877

However, lipo cannot be used to merge both the iOS and simulator arm64 slice into the same output file:

fatal error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo: /Users/andreialecu/Work/contrib/libevent-builder/build/built/iPhoneSimulator-arm64.sdk/lib/libevent.a and /Users/andreialecu/Work/contrib/libevent-builder/build/built/iPhoneOS-arm64.sdk/lib/libevent.a have the same architectures (arm64) and can't be in the same fat output file

What this means is that they need to be converted into an xcframework with separate outputs similar to what OpenSSL-Universal does:

https://github.com/krzyzanowskim/OpenSSL/blob/5fe27f6accc02fb666175f65b83c1552030f3669/scripts/create-frameworks.sh https://github.com/krzyzanowskim/OpenSSL/tree/5fe27f6accc02fb666175f65b83c1552030f3669/Frameworks

Hopefully someone can take over this work. It was a fun experiment. In the mean time I’ll resort to disabling Flipper until this is resolved.

I was able to find this script: https://github.com/e314521/ios-lib/blob/fa1246cbaa0ea664ee285690aedf551ff7753f85/build-libevent.sh

It seems to be what builds libevent.a and the other artefacts.

Forking the library and updating the build script to also build for the iPhoneSimulator-arm64 target might be an option.