From 698317ef28ca01b4d1b0e4a817971923c93edcbe Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Tue, 3 Oct 2023 12:14:59 +0300 Subject: [PATCH] nmslib: add -fno-finite-math-only to fix issues with glibc >= 2.31 --- recipes/nmslib/all/conanfile.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/recipes/nmslib/all/conanfile.py b/recipes/nmslib/all/conanfile.py index 91ad2d35e900e..cc8984e2be798 100644 --- a/recipes/nmslib/all/conanfile.py +++ b/recipes/nmslib/all/conanfile.py @@ -3,7 +3,7 @@ from conan import ConanFile from conan.errors import ConanInvalidConfiguration from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout -from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file from conan.tools.microsoft import is_msvc, check_min_vs required_conan_version = ">=1.53.0" @@ -62,8 +62,15 @@ def generate(self): tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW" tc.generate() - def build(self): + def _patch_sources(self): apply_conandata_patches(self) + # The finite-math-only optimization has no effect and can cause linking errors + # when linked against glibc >= 2.31 + replace_in_file(self, os.path.join(self.source_folder, "similarity_search", "CMakeLists.txt"), + "-Ofast", "-Ofast -fno-finite-math-only") + + def build(self): + self._patch_sources() cmake = CMake(self) cmake.configure(build_script_folder=os.path.join(self.source_folder, "similarity_search")) cmake.build()