From 3a2e78f4c3dfe248b8f8f5e4c15aefabac564a02 Mon Sep 17 00:00:00 2001 From: Oliver Kuckertz Date: Fri, 1 Mar 2024 17:07:20 +0100 Subject: [PATCH] xnnpack: fix building for Android --- recipes/xnnpack/all/conanfile.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/recipes/xnnpack/all/conanfile.py b/recipes/xnnpack/all/conanfile.py index 579c065b64636..81bd0455ccc87 100644 --- a/recipes/xnnpack/all/conanfile.py +++ b/recipes/xnnpack/all/conanfile.py @@ -64,7 +64,7 @@ def requirements(self): def validate(self): check_min_vs(self, 192) - compiler = self.info.settings.compiler + compiler = self.settings.compiler compiler_version = Version(compiler.version) if self.version < "cci.20230715": if (compiler == "gcc" and compiler_version < "6") or \ @@ -75,6 +75,10 @@ def validate(self): if (compiler == "gcc" and compiler_version < "11") or \ (compiler == "clang" and compiler_version < "8"): raise ConanInvalidConfiguration(f"{self.ref} doesn't support {compiler} {compiler.version}") + if self.options.assembly and compiler == "clang" and self.settings.arch == "armv6": + # clang assembly validator fails on XNNPACK's math.h for armv6: + # https://github.com/google/XNNPACK/issues/4348#issuecomment-1445437613 + raise ConanInvalidConfiguration(f"{self.ref} assembly option is incompatible with clang+armv6") def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True) @@ -120,6 +124,12 @@ def _patch_sources(self): replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), "LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}", "LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}") + if self.settings.compiler == "clang" and self.settings.arch == "armv7": + # https://github.com/google/XNNPACK/issues/4348 + # XNNPACK targets armv6, but clang fails to compile to due to a bug in the assembler (see linked issue). + # The user is targetting armv7, so adjust XNNPACK's -march accordingly to avoid the bug. + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), + "-march=armv6 -mfpu=vfp", "-march=armv7-a -mfpu=neon") def build(self): self._patch_sources()