buildroot/package/x265/x265.mk
Thomas Petazzoni 1fbd26f831 package/x265: fix runtime issue on ARMv6, ensure correctness on ARMv7
The build logic in source/cmake/FindNeon.cmake caused the x265 build
system to always think that the CPU supports neon: it was looking in
/proc/cpuinfo, which of course is wrong when cross-compilation, but
then the sequence of grep was interacting badly with CMake, causing
the build system to always conclude that the CPU supports NEON.

This causes runtime issues on ARMv6.

Setting -DCROSS_COMPILE_ARM=1 fixes this, as it tells the x265 build
system we are cross-compiling and it skips its bogus NEON check. So
for ARMv6, we pass -DCROSS_COMPILE_ARM=1.

But then, we still want NEON for ARMv7 processors with NEON, so this
commit adds a patch that allows to explicitly specify whether the CPU
supports NEON, in the -DCROSS_COMPILE_ARM=1 case, and we use this
option when BR2_ARM_CPU_HAS_NEON.

For those wondering why -DCROSS_COMPILE_ARM=1 is not passed for all
ARM platforms: it's because from the perspective of x265, only ARM >=
v6 is ARM: it has assembly code that needs at least ARMv6. Earlier ARM
platforms are not detected as ARM by the x265 build logic, and
therefore fallback on generic code.

This has been build-tested on:
- ARMv5: generic code is used, no assembly
- ARMv6: assembly code is used, but not with NEON support
- ARMv7 with NEON: assembly code is used, with NEON support

Reported-by: David Barbion <davidb@230ruedubac.fr>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2024-07-13 10:36:29 +02:00

53 lines
1.4 KiB
Makefile

################################################################################
#
# x265
#
################################################################################
X265_VERSION = 3.5
X265_SOURCE = x265_$(X265_VERSION).tar.gz
X265_SITE = https://bitbucket.org/multicoreware/x265_git/downloads
X265_LICENSE = GPL-2.0+
X265_LICENSE_FILES = COPYING
X265_CPE_ID_VENDOR = multicorewareinc
X265_SUBDIR = source
X265_INSTALL_STAGING = YES
# For CPUs before ARMv6, x265 does not consider them "ARM" but generic
# CPUs for which no optimized assembly is provided, hence we don't
# pass -DCROSS_COMPILE_ARM=1.
ifeq ($(BR2_ARM_CPU_ARMV6),y)
X265_CONF_OPTS += -DCROSS_COMPILE_ARM=1
endif
ifeq ($(BR2_ARM_CPU_ARMV7A),y)
X265_CONF_OPTS += -DCROSS_COMPILE_ARM=1
ifeq ($(BR2_ARM_CPU_HAS_NEON),y)
X265_CONF_OPTS += -DCPU_HAS_NEON=1
endif
endif
ifeq ($(BR2_i386)$(BR2_x86_64),y)
X265_DEPENDENCIES += host-nasm
endif
# disable altivec, it has build issues
# https://bitbucket.org/multicoreware/x265/issues/320/
ifeq ($(BR2_powerpc64)$(BR2_powerpc64le),y)
X265_CONF_OPTS += -DENABLE_ALTIVEC=OFF
endif
ifeq ($(BR2_SHARED_LIBS)$(BR2_SHARED_STATIC_LIBS),y)
X265_CONF_OPTS += -DENABLE_SHARED=ON -DENABLE_PIC=ON
else
X265_CONF_OPTS += -DENABLE_SHARED=OFF
endif
ifeq ($(BR2_PACKAGE_X265_CLI),y)
X265_CONF_OPTS += -DENABLE_CLI=ON
else
X265_CONF_OPTS += -DENABLE_CLI=OFF
endif
$(eval $(cmake-package))