Skip to content

Add support for cross-compiling on Mac #186#187

Closed
andrewgrant wants to merge 1 commit intoxiph:masterfrom
andrewgrant:pr-186
Closed

Add support for cross-compiling on Mac #186#187
andrewgrant wants to merge 1 commit intoxiph:masterfrom
andrewgrant:pr-186

Conversation

@andrewgrant
Copy link

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.

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
@xnorpx
Copy link
Contributor

xnorpx commented Jul 7, 2020

@mark4o && @rillian for review?

Should neon be presumed for apple silicone?
Add config to .travis ci for coverage?

@silverbacknet
Copy link
Contributor

NEON has been in all Apple silicon since 3GS, so it would be reasonable.

@andrewgrant
Copy link
Author

Good point RE Neon. I'll add that and resubmit in the next day or so.

@rillian
Copy link
Contributor

rillian commented Jul 9, 2020

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.

@j-schultz
Copy link

j-schultz commented Apr 8, 2022

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:

if(CMAKE_SYSTEM_PROCESSOR MATCHES "(i[0-9]86|x86|X86|amd64|AMD64|x86_64)")

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: #198

@xnorpx
Copy link
Contributor

xnorpx commented Jun 30, 2022

@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

@j-schultz
Copy link

j-schultz commented Jun 30, 2022

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)

@xnorpx
Copy link
Contributor

xnorpx commented Jul 8, 2022

@j-schultz m1 stuff seems pretty hairy, unlikely I will get fixes in this release.

@charlifiiiii
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants