opus icon indicating copy to clipboard operation
opus copied to clipboard

Can't cross-compile on Mac to create universal binaries

Open andrewgrant opened this issue 4 years ago • 3 comments

It isn't currently possible with Opus to cross compile on Mac in order to create universal libraries that are capable of supporting both Intel and Apple silicon Mac's

andrewgrant avatar Jul 07 '20 00:07 andrewgrant

I found this out the hard way, by realizing the libopus fat binary produced by CMake using the XCode generator was missing vector optimizations not just for the arm64 slice (which indeed doesn't support SSE, AVX) but also for the x86_64 slice :(

Perhaps prior to CMake 3.19 building UBs just completely didn't work; With CMake 3.19 it does work, but it doesn't produce the expected optimizations.

It may be beneficial to add a warning when trying to do universal builds until this is fixed.

danra avatar Feb 21 '21 17:02 danra

I don't have a M1 Mac so can't test it.

But pull requests is appreciated.

xnorpx avatar Feb 21 '21 18:02 xnorpx

With Xcode 13 you can build "multi-arch" binaries (universal binaries), i.e. you can compile with "-arch arm64 -arch x86_64".

Here's how I use CMake ExternalProject to build an OPUS universal binary: https://github.com/BearWare/TeamTalk5/blob/apple_m1/Library/TeamTalkLib/build/opus/CMakeLists.txt#L42

Here's a long thread were we discuss OPUS on Apple M1 using Rosetta emulator: https://github.com/BearWare/TeamTalk5/issues/1067

bear101 avatar Nov 07 '21 14:11 bear101