From 1e3e7290c8247d6eb1307c38e0cfb7ad28708dee Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Fri, 17 Nov 2023 23:06:27 +0200 Subject: [PATCH] lightgbm: restore patches for the Clang OpenMP support fix --- recipes/lightgbm/all/conandata.yml | 13 +++++++++++++ recipes/lightgbm/all/conanfile.py | 8 +++++--- .../all/patches/3.3.2-0001-fix-openmp-clang.patch | 13 +++++++++++++ .../all/patches/3.3.5-0001-fix-openmp-clang.patch | 13 +++++++++++++ .../all/patches/4.1.0-0001-fix-openmp-clang.patch | 11 +++++++++++ 5 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 recipes/lightgbm/all/patches/3.3.2-0001-fix-openmp-clang.patch create mode 100644 recipes/lightgbm/all/patches/3.3.5-0001-fix-openmp-clang.patch create mode 100644 recipes/lightgbm/all/patches/4.1.0-0001-fix-openmp-clang.patch diff --git a/recipes/lightgbm/all/conandata.yml b/recipes/lightgbm/all/conandata.yml index 880839ac61786..5c29f9403b5ce 100644 --- a/recipes/lightgbm/all/conandata.yml +++ b/recipes/lightgbm/all/conandata.yml @@ -8,3 +8,16 @@ sources: "3.3.2": url: "https://github.com/microsoft/LightGBM/archive/refs/tags/v3.3.2.tar.gz" sha256: "d7c0f842e94165578d5a0c046ca942838d1574149f98c84400ce511239d17b9f" +patches: + "4.1.0": + - patch_file: "patches/4.1.0-0001-fix-openmp-clang.patch" + patch_type: "portability" + patch_description: "Fix OpenMP support for Clang" + "3.3.5": + - patch_file: "patches/3.3.5-0001-fix-openmp-clang.patch" + patch_type: "portability" + patch_description: "Fix OpenMP support for Clang" + "3.3.2": + - patch_file: "patches/3.3.2-0001-fix-openmp-clang.patch" + patch_type: "portability" + patch_description: "Fix OpenMP support for Clang" diff --git a/recipes/lightgbm/all/conanfile.py b/recipes/lightgbm/all/conanfile.py index 9cf4e25a553b9..4074480e30736 100644 --- a/recipes/lightgbm/all/conanfile.py +++ b/recipes/lightgbm/all/conanfile.py @@ -4,7 +4,7 @@ from conan.tools.apple import is_apple_os from conan.tools.build import check_min_cppstd from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout -from conan.tools.files import copy, get, replace_in_file, save +from conan.tools.files import copy, get, replace_in_file, save, export_conandata_patches, apply_conandata_patches from conan.tools.microsoft import is_msvc from conan.tools.scm import Version @@ -36,6 +36,9 @@ class LightGBMConan(ConanFile): "with_openmp": True, } + def export_sources(self): + export_conandata_patches(self) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -74,9 +77,8 @@ def generate(self): tc.generate() def _patch_sources(self): + apply_conandata_patches(self) cmakelists_path = os.path.join(self.source_folder, "CMakeLists.txt") - # Fix OpenMP detection for Clang - replace_in_file(self, cmakelists_path, "AppleClang", "Clang|AppleClang") # Fix vendored dependency includes common_h = os.path.join(self.source_folder, "include", "LightGBM", "utils", "common.h") for lib in ["fmt", "fast_double_parser"]: diff --git a/recipes/lightgbm/all/patches/3.3.2-0001-fix-openmp-clang.patch b/recipes/lightgbm/all/patches/3.3.2-0001-fix-openmp-clang.patch new file mode 100644 index 0000000000000..092e8d05ac946 --- /dev/null +++ b/recipes/lightgbm/all/patches/3.3.2-0001-fix-openmp-clang.patch @@ -0,0 +1,13 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 109a252d..e5d46bce 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -415,7 +415,7 @@ if(USE_MPI) + endif(USE_MPI) + + if(USE_OPENMP) +- if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") ++ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|AppleClang") + TARGET_LINK_LIBRARIES(lightgbm OpenMP::OpenMP_CXX) + TARGET_LINK_LIBRARIES(_lightgbm OpenMP::OpenMP_CXX) + endif() diff --git a/recipes/lightgbm/all/patches/3.3.5-0001-fix-openmp-clang.patch b/recipes/lightgbm/all/patches/3.3.5-0001-fix-openmp-clang.patch new file mode 100644 index 0000000000000..0fbe29eced0c4 --- /dev/null +++ b/recipes/lightgbm/all/patches/3.3.5-0001-fix-openmp-clang.patch @@ -0,0 +1,13 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 95610d55..2b48507d 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -444,7 +444,7 @@ if(USE_MPI) + endif(USE_MPI) + + if(USE_OPENMP) +- if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") ++ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|AppleClang") + TARGET_LINK_LIBRARIES(lightgbm OpenMP::OpenMP_CXX) + TARGET_LINK_LIBRARIES(_lightgbm OpenMP::OpenMP_CXX) + endif() diff --git a/recipes/lightgbm/all/patches/4.1.0-0001-fix-openmp-clang.patch b/recipes/lightgbm/all/patches/4.1.0-0001-fix-openmp-clang.patch new file mode 100644 index 0000000000000..4de5b0a2d1c8e --- /dev/null +++ b/recipes/lightgbm/all/patches/4.1.0-0001-fix-openmp-clang.patch @@ -0,0 +1,11 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -526,7 +526,7 @@ + endif() + + if(USE_OPENMP) +- if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") ++ if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang|AppleClang") + target_link_libraries(lightgbm_objs PUBLIC OpenMP::OpenMP_CXX) + # c_api headers also includes OpenMP headers, thus compiling + # lightgbm_capi_objs needs include directory for OpenMP.