opus
opus copied to clipboard
Can't cross-compile on Mac to create universal binaries
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
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.
I don't have a M1 Mac so can't test it.
But pull requests is appreciated.
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