opus
opus copied to clipboard
Add support for cross-compiling on Mac #186
Adds support for cross-compiling to different targets when building on Mac.
E.g the following builds Opus for an arm64 Mac target (Apple silicon)
./configure --host=aarch64-apple-macos make && make install
This allows building Opus for both architectures and using lipo to create a universal binary.
@mark4o && @rillian for review?
Should neon be presumed for apple silicone? Add config to .travis ci for coverage?
NEON has been in all Apple silicon since 3GS, so it would be reasonable.
Good point RE Neon. I'll add that and resubmit in the next day or so.
Can you please also document your rationale in the commit message, or a comment. I assume this is to work around autoconf's built-in cross-compiler detection not supporting Apple's new configuration, but it seems like there are several ways to do that. Why the separate clang_arch
variables, for example, and why not set the flags directly in configure. That's the sort of thing someone having to maintain the changes later would need to know.
It's not part of this PR, but I found that the CMake build system is also doing dubious stuff here that pessimizes x64 builds on arm64: https://github.com/xiph/opus/blob/ccaaffa9a3ee427e9401c4dcf6462e378d9a4694/cmake/OpusConfig.cmake#L42
From my understanding, CMAKE_SYSTEM_PROCESSOR
matches arm64 here, causing the build system to check for NEON availability rather than SSE availability:
-- Looking for arm_neon.h
-- Looking for arm_neon.h - not found
The resulting binary is still compiled for x64, but without SIMD optimiations.
Edit: I think that's being tracked in this issue: https://github.com/xiph/opus/issues/198
@j-schultz so the issue is cross compiling to x64 on a m1/m2 mac for cmake?
https://stackoverflow.com/questions/69803659/what-is-the-proper-way-to-build-for-macos-x86-64-using-cmake-on-apple-m1-arm
will try to test this
so the issue is cross compiling to x64 on a m1/m2 mac for cmake?
Correct. And probably the other way around, too (missing NEON optimizations when cross-compiling for arm64)
@j-schultz m1 stuff seems pretty hairy, unlikely I will get fixes in this release.
Is cross-compiling now supposed to work on Mac M1 ? I tried to cross-compile for Mac Intel (x86_64) from a Mac M1 using this cmd ./configure --host=x86_64-apple-macos and got the following error : configure: error: no supported Get CPU Info method, please disable run-time CPU capabilities detection or intrinsics
Any advice ? Thanks