Skip to content

Commit

Permalink
(#24627) libx265: Disable assembly when building for Android
Browse files Browse the repository at this point in the history
* Disable assembly when building Android

Signed-off-by: Uilian Ries <[email protected]>

* Raise invalid configuration for mac m1

* update error message.

* Add missing option

---------

Signed-off-by: Uilian Ries <[email protected]>
  • Loading branch information
uilianries authored Jul 17, 2024
1 parent 1f93300 commit b81e7e3
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions recipes/libx265/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ def config_options(self):
del self.options.with_numa
# FIXME: Disable assembly by default if host is arm and compiler apple-clang for the moment.
# Indeed, apple-clang is not able to understand some asm instructions of libx265
if self.settings.compiler == "apple-clang" and "arm" in self.settings.arch:
# FIXME: Disable assembly by default if host is Android for the moment. It fails to build
if (self.settings.compiler == "apple-clang" and "arm" in self.settings.arch) or self.settings.os == "Android":
self.options.assembly = False

def configure(self):
Expand All @@ -63,10 +64,27 @@ def requirements(self):
if self.options.get_safe("with_numa", False):
self.requires("libnuma/2.0.14")

def validate_build(self):
if cross_building(self) and self.settings.os == "Android" and self.options.assembly:
# FIXME: x265 uses custom command to invoke clang to compile assembly files.
# clang++ -fPIC -c src/source/common/aarch64/mc-a.S -o mc-a.S.o
# FAILED: mc-a.S.o libx2f309356bd8526/b/build/Release/mc-a.S.o
# clang++ -fPIC -c src/source/common/aarch64/mc-a.S -o mc-a.S.o
# <instantiation>:11:9: error: unknown directive
# .func x265_pixel_avg_pp_4x4_neon
raise ConanInvalidConfiguration(f"{self.ref} fails to build with '&:assembly=True' for Android. Contributions are welcome.")

def validate(self):
if self.options.shared and is_msvc(self) and is_msvc_static_runtime(self):
raise ConanInvalidConfiguration("shared not supported with static runtime")

if self.settings.compiler == "apple-clang" and "arm" in self.settings.arch and self.options.assembly:
# Undefined symbols for architecture arm64:
# "x265::setupAssemblyPrimitives(x265::EncoderPrimitives&, int)", referenced from:
# x265::x265_setup_primitives(x265_param*) in libx265.a[20](primitives.cpp.o)
# ld: symbol(s) not found for architecture arm64
raise ConanInvalidConfiguration(f"{self.ref} fails to build for Mac M1. Contributions are welcome.")

def build_requirements(self):
if self.options.assembly:
if self.settings.arch in ["x86", "x86_64"]:
Expand Down Expand Up @@ -154,7 +172,10 @@ def package_info(self):
if not self.options.shared:
self.cpp_info.sharedlinkflags = ["-Wl,-Bsymbolic,-znoexecstack"]
elif self.settings.os == "Android":
self.cpp_info.libs.extend(["dl", "m"])
libcxx = stdcpp_library(self)
if libcxx:
self.cpp_info.system_libs.append(libcxx)
self.cpp_info.system_libs.extend(["dl", "m"])
if not self.options.shared:
libcxx = stdcpp_library(self)
if libcxx:
if self.settings.os == "Android" and self.settings.compiler.libcxx == "c++_static":
self.cpp_info.system_libs.append("c++abi")
self.cpp_info.system_libs.append(libcxx)

0 comments on commit b81e7e3

Please sign in to comment.