Skip to content

Commit

Permalink
[openblas] Add armv8 compatibility
Browse files Browse the repository at this point in the history
* Patch versions earlier than 0.3.24 to include hotfix of
  OpenMathLib/OpenBLAS#4142, which fixes detection of the armv8
  architecture to ARM64 from ARM.
* Refactor patches into a _patch_sources method
  • Loading branch information
samuel-emrys committed Jan 1, 2024
1 parent b429083 commit 0bd65ec
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions recipes/openblas/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,9 @@ def generate(self):
# This is a workaround to add the libm dependency on linux,
# which is required to successfully compile on older gcc versions.
tc.cache_variables["ANDROID"] = self.settings.os in ["Linux", "Android"]

if self.settings.arch == "armv8":
# OpenBLAS fails to detect the appropriate architecture for armv8, so help it out
tc.variables["TARGET"] = "ARMV8"
tc.generate()

def build(self):
def _patch_sources(self):
if Version(self.version) < "0.3.21":
if Version(self.version) >= "0.3.12":
search = """message(STATUS "No Fortran compiler found, can build only BLAS but not LAPACK")"""
Expand All @@ -142,6 +138,20 @@ def build(self):
search,
replace,
)

if Version(self.version) < "0.3.24":
# OpenBLAS fails to detect the appropriate target architecture for armv8, so help it out.
# This will ensure ARM64 is set, which will set TARGET=ARMV8 appropriately.
# This is a portability hotfix of https://github.com/OpenMathLib/OpenBLAS/pull/4142
replace_in_file(
self,
os.path.join(self.source_folder, "cmake", "system_check.cmake"),
'elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64.*|AARCH64.*|arm64.*|ARM64.*)")',
'elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64.*|AARCH64.*|arm64.*|ARM64.*|armv8.*)")'
)

def build(self):
self._patch_sources()
cmake = self._configure_cmake()
cmake.build()

Expand Down

0 comments on commit 0bd65ec

Please sign in to comment.