Implement arm64 compiling for apple silicon

Issue #578 new
Shen Y created an issue

Hi all, I was trying to get x265 to compile on the new Xcode toolchain (12.2 RC) which just supported compiling the program to the universal binary that will be supported by the new apple silicon macs. I was able to configure few settings in the CMakeLists.txt file to get it to compile correctly without the assembly but I was unfortunately not able to get assembly compiling working on my mac(Is a very outdated one, 3rd gen i7, missing a lot of modern instruction). Since those new macs will be shipping soon, is there any plan to support compiling them officially?

To configure the CMakeLists to support compiling to arm64, add those lines to line 137(On commit5163c32)

if(APPLE)
add_definitions(-DX265_ARCH_ARM=1 -DX265_ARCH_ARM64=1 -DHAVE_ARMV6=0)
add_definitions(-DMACOS=1)
endif()

Also on a side note, for some reason that settings CMAKE_XCODE_ARCHS` to $(CURRENT_ARCH)` does not work which leads to Xcode not knowing where to find the compiled object during the linking stage. You can get around with that by directly editing the Xcode project XML and swap all /x86_64/ to `$(CURRENT_ARCH)`.

Comments (3)

  1. Log in to comment