xiph / opus

Modern audio compression for the internet.
https://opus-codec.org/
Other
2.25k stars 601 forks source link

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

Open andrewgrant opened 4 years ago

andrewgrant commented 4 years ago

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

danra commented 3 years ago

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.

xnorpx commented 3 years ago

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

But pull requests is appreciated.

bear101 commented 2 years ago

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