diff --git a/src/meson.build b/src/meson.build index 8eb8f05b..9b63c8e8 100644 --- a/src/meson.build +++ b/src/meson.build @@ -55,7 +55,21 @@ if (pipelines.contains('virtual') or get_option('android').allowed()) and \ '-Wno-unused-parameter') libyuv_vars.append_link_args('-ljpeg') libyuv = cmake.subproject('libyuv', options : libyuv_vars) - libyuv_dep = libyuv.dependency('yuv') + + # Meson fails to apply the -fPIC flag to static libraries produced by CMake + # that wraps other static libraries without adding any source file, despite + # setting CMAKE_POSITION_INDEPENDENT_CODE to ON. See + # https://github.com/mesonbuild/meson/issues/10764. + # + # Work around the issue by wrapping the libyuv static library into another + # static library with 'pic' set to true. + libyuv_static = static_library('libyuv-static', + dependencies : libyuv.dependency('yuv'), + pic : true, + install : false) + libyuv_include = libyuv.include_directories('yuv') + libyuv_dep = declare_dependency(link_with : libyuv_static, + include_directories : libyuv_include) endif # libcamera must be built first as a dependency to the other components. diff --git a/subprojects/libyuv.wrap b/subprojects/libyuv.wrap index 3417e73f..e892d8a3 100644 --- a/subprojects/libyuv.wrap +++ b/subprojects/libyuv.wrap @@ -3,4 +3,5 @@ [wrap-git] directory = libyuv url = https://chromium.googlesource.com/libyuv/libyuv.git -revision = 93b1b332cd60b56ab90aea14182755e379c28a80 +revision = 500f45652c459cfccd20f83f297eb66cb7b015cb +diff_files = libyuv/0004-CMakeLists.txt-Do-not-enable-NEON-for-armel-armhf.patch diff --git a/subprojects/packagefiles/libyuv/0004-CMakeLists.txt-Do-not-enable-NEON-for-armel-armhf.patch b/subprojects/packagefiles/libyuv/0004-CMakeLists.txt-Do-not-enable-NEON-for-armel-armhf.patch new file mode 100644 index 00000000..70cbc2c7 --- /dev/null +++ b/subprojects/packagefiles/libyuv/0004-CMakeLists.txt-Do-not-enable-NEON-for-armel-armhf.patch @@ -0,0 +1,42 @@ +From: Boyuan Yang +Date: Fri, 8 Nov 2024 08:07:01 -0500 +Subject: CMakeLists.txt: Do not enable NEON for armel armhf + +According to https://wiki.debian.org/ArchitectureSpecificsMemo#armel +the armhf architecture does not guarantee NEON. Do not enable NEON +on armhf. Also disable NEON for armel to prevent FTBFS +--- + CMakeLists.txt | 19 ++++++++++--------- + 1 file changed, 10 insertions(+), 9 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index bf8be36..783c3d4 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -95,16 +95,17 @@ endif() + if(NOT MSVC) + string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" arch_lowercase) + ++# Debian-specific: Do not enable Arm Neon kernels on non-arm64 architectures. + if(arch_lowercase MATCHES "^arm" AND NOT arch_lowercase STREQUAL "arm64") +- # Enable Arm Neon kernels. +- add_definitions(-DLIBYUV_NEON=1) +- add_library(${ly_lib_name}_neon OBJECT +- ${ly_src_dir}/compare_neon.cc +- ${ly_src_dir}/rotate_neon.cc +- ${ly_src_dir}/row_neon.cc +- ${ly_src_dir}/scale_neon.cc) +- target_compile_options(${ly_lib_name}_neon PRIVATE -mfpu=neon) +- list(APPEND ly_lib_parts $) ++ message("Debian-specific: Not enabling NEON on ${arch_lowercase}.") ++# add_definitions(-DLIBYUV_NEON=1) ++# add_library(${ly_lib_name}_neon OBJECT ++# ${ly_src_dir}/compare_neon.cc ++# ${ly_src_dir}/rotate_neon.cc ++# ${ly_src_dir}/row_neon.cc ++# ${ly_src_dir}/scale_neon.cc) ++# target_compile_options(${ly_lib_name}_neon PRIVATE -mfpu=neon) ++# list(APPEND ly_lib_parts $) + endif() + + if(arch_lowercase STREQUAL "aarch64" OR arch_lowercase STREQUAL "arm64")