Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xnnpack: fix cross-compiling for Android/armv7 #22951

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion recipes/xnnpack/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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)
Expand Down Expand Up @@ -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()
Expand Down
Loading