From ebfbdc4c00fd8a8e0d5c408b129fdd2ab265b120 Mon Sep 17 00:00:00 2001 From: Hyunsu Cho Date: Mon, 17 Jun 2024 15:46:11 -0700 Subject: [PATCH 01/11] [CMake] Move OpenMP logic for MacOS to a separate module --- CMakeLists.txt | 17 ++--------------- cmake/FindOpenMPMacOS.cmake | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 15 deletions(-) create mode 100644 cmake/FindOpenMPMacOS.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 5816a61e1640..ca3e92a6d1f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -236,21 +236,8 @@ find_package(Threads REQUIRED) if(USE_OPENMP) if(APPLE) - find_package(OpenMP) - if(NOT OpenMP_FOUND) - # Try again with extra path info; required for libomp 15+ from Homebrew - execute_process(COMMAND brew --prefix libomp - OUTPUT_VARIABLE HOMEBREW_LIBOMP_PREFIX - OUTPUT_STRIP_TRAILING_WHITESPACE) - set(OpenMP_C_FLAGS - "-Xpreprocessor -fopenmp -I${HOMEBREW_LIBOMP_PREFIX}/include") - set(OpenMP_CXX_FLAGS - "-Xpreprocessor -fopenmp -I${HOMEBREW_LIBOMP_PREFIX}/include") - set(OpenMP_C_LIB_NAMES omp) - set(OpenMP_CXX_LIB_NAMES omp) - set(OpenMP_omp_LIBRARY ${HOMEBREW_LIBOMP_PREFIX}/lib/libomp.dylib) - find_package(OpenMP REQUIRED) - endif() + include(cmake/FindOpenMPMacOS.cmake) + find_openmp_macos() else() find_package(OpenMP REQUIRED) endif() diff --git a/cmake/FindOpenMPMacOS.cmake b/cmake/FindOpenMPMacOS.cmake new file mode 100644 index 000000000000..50ca87ed4350 --- /dev/null +++ b/cmake/FindOpenMPMacOS.cmake @@ -0,0 +1,22 @@ +function(find_openmp_macos) + if(NOT APPLE) + message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION}() must only be used on MacOS") + endif() + find_package(OpenMP) + if(NOT OpenMP_FOUND) + # Try again with extra path info. This step is required for libomp 15+ from Homebrew, + # as libomp 15.0+ from brew is keg-only + # See https://github.com/Homebrew/homebrew-core/issues/112107#issuecomment-1278042927. + execute_process(COMMAND brew --prefix libomp + OUTPUT_VARIABLE HOMEBREW_LIBOMP_PREFIX + OUTPUT_STRIP_TRAILING_WHITESPACE) + set(OpenMP_C_FLAGS + "-Xpreprocessor -fopenmp -I${HOMEBREW_LIBOMP_PREFIX}/include") + set(OpenMP_CXX_FLAGS + "-Xpreprocessor -fopenmp -I${HOMEBREW_LIBOMP_PREFIX}/include") + set(OpenMP_C_LIB_NAMES omp) + set(OpenMP_CXX_LIB_NAMES omp) + set(OpenMP_omp_LIBRARY ${HOMEBREW_LIBOMP_PREFIX}/lib/libomp.dylib) + find_package(OpenMP REQUIRED) + endif() +endfunction() From 67a08d3e5f29523e2207761210cc52b20558f9e6 Mon Sep 17 00:00:00 2001 From: Hyunsu Cho Date: Mon, 17 Jun 2024 17:48:44 -0700 Subject: [PATCH 02/11] Patch libxgboost.dylib to use @rpath/libomp.dylib --- CMakeLists.txt | 7 +++ cmake/FindOpenMPMacOS.cmake | 90 +++++++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index ca3e92a6d1f8..072f2eb31495 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -367,6 +367,13 @@ if(JVM_BINDINGS) xgboost_target_defs(xgboost4j) endif() +if(USE_OPENMP AND APPLE) + patch_openmp_path_macos(xgboost libxgboost) + if(JVM_BINDINGS) + patch_openmp_path_macos(xgboost4j libxgboost4j) + endif() +endif() + if(KEEP_BUILD_ARTIFACTS_IN_BINARY_DIR) set_output_directory(xgboost ${xgboost_BINARY_DIR}/lib) else() diff --git a/cmake/FindOpenMPMacOS.cmake b/cmake/FindOpenMPMacOS.cmake index 50ca87ed4350..936d81110283 100644 --- a/cmake/FindOpenMPMacOS.cmake +++ b/cmake/FindOpenMPMacOS.cmake @@ -1,3 +1,5 @@ +# Find OpenMP library on MacOS +# Automatically handle locating libomp from the Homebrew package manager function(find_openmp_macos) if(NOT APPLE) message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION}() must only be used on MacOS") @@ -20,3 +22,91 @@ function(find_openmp_macos) find_package(OpenMP REQUIRED) endif() endfunction() + +# Patch libxgboost.dylib so that it depends on @rpath/libomp.dylib instead of +# /opt/homebrew/opt/libomp/lib/libomp.dylib or other hard-coded paths. +# Doing so enables XGBoost to interoperate with multiple kinds of OpenMP +# libraries. See https://github.com/microsoft/LightGBM/pull/6391 for detailed +# explanation. Adapted from https://github.com/microsoft/LightGBM/pull/6391 +# by James Lamb. +# MacOS only. +function(patch_openmp_path_macos target target_default_output_name) + if(NOT APPLE) + message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION}() must only be used on MacOS") + endif() + # Get path to libomp found at build time + get_target_property( + __OpenMP_LIBRARY_LOCATION + OpenMP::OpenMP_CXX + INTERFACE_LINK_LIBRARIES + ) + # Get the base name of the OpenMP lib + # Usually: libomp.dylib, libgomp.dylib, or libiomp.dylib + get_filename_component( + __OpenMP_LIBRARY_NAME + ${__OpenMP_LIBRARY_LOCATION} + NAME + ) + # Get the directory containing the OpenMP lib + get_filename_component( + __OpenMP_LIBRARY_DIR + ${__OpenMP_LIBRARY_LOCATION} + DIRECTORY + ) + # Get the name of the XGBoost lib, e.g. libxgboost + get_target_property( + __LIBXGBOOST_OUTPUT_NAME + ${target} + OUTPUT_NAME + ) + if(NOT __LIBXGBOOST_OUTPUT_NAME) + set(__LIBXGBOOST_OUTPUT_NAME "${target_default_output_name}") + endif() + + # Get the file name of the XGBoost lib, e.g. libxgboost.dylib + if(CMAKE_SHARED_LIBRARY_SUFFIX_CXX) + set( + __LIBXGBOOST_FILENAME_${target} "${__LIBXGBOOST_OUTPUT_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX_CXX}" + CACHE INTERNAL "Shared library filename ${target}" + ) + else() + set( + __LIBXGBOOST_FILENAME_${target} "${__LIBXGBOOST_OUTPUT_NAME}.dylib" + CACHE INTERNAL "Shared library filename ${target}" + ) + endif() + + message(STATUS "Creating shared lib ${__LIBXGBOOST_FILENAME_${target}}...") + + # Override the absolute path to OpenMP with a relative one using @rpath. + # + # This also ensures that if a libomp.dylib has already been loaded, it'll just use that. + add_custom_command( + TARGET ${target} + POST_BUILD + COMMAND + install_name_tool + -change + ${__OpenMP_LIBRARY_LOCATION} + "@rpath/${__OpenMP_LIBRARY_NAME}" + "${__LIBXGBOOST_FILENAME_${target}}" + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMENT + "${__LIBXGBOOST_FILENAME_${target}}: " + "Replacing hard-coded OpenMP install_name with '@rpath/${__OpenMP_LIBRARY_NAME}'..." + ) + # Add RPATH entries to ensure the loader looks in the following, in the following order: + # + # - /opt/homebrew/opt/libomp/lib (where 'brew install' / 'brew link' puts libomp.dylib) + # - ${__OpenMP_LIBRARY_DIR} (wherever find_package(OpenMP) found OpenMP at build time) + # + # Note: This list will only be used if libomp.dylib isn't already loaded into memory. + # So Conda users will likely use ${CONDA_PREFIX}/libomp.dylib + set_target_properties( + ${target} + PROPERTIES + BUILD_WITH_INSTALL_RPATH TRUE + INSTALL_RPATH "/opt/homebrew/opt/libomp/lib;${__OpenMP_LIBRARY_DIR}" + INSTALL_RPATH_USE_LINK_PATH FALSE + ) +endfunction() From a904253982a8b52b3893805734760768474dad08 Mon Sep 17 00:00:00 2001 From: Hyunsu Cho Date: Mon, 17 Jun 2024 17:57:29 -0700 Subject: [PATCH 03/11] find_openmp_macos should be a macro --- cmake/FindOpenMPMacOS.cmake | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cmake/FindOpenMPMacOS.cmake b/cmake/FindOpenMPMacOS.cmake index 936d81110283..236d2fa091d0 100644 --- a/cmake/FindOpenMPMacOS.cmake +++ b/cmake/FindOpenMPMacOS.cmake @@ -1,6 +1,6 @@ # Find OpenMP library on MacOS # Automatically handle locating libomp from the Homebrew package manager -function(find_openmp_macos) +macro(find_openmp_macos) if(NOT APPLE) message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION}() must only be used on MacOS") endif() @@ -21,7 +21,7 @@ function(find_openmp_macos) set(OpenMP_omp_LIBRARY ${HOMEBREW_LIBOMP_PREFIX}/lib/libomp.dylib) find_package(OpenMP REQUIRED) endif() -endfunction() +endmacro() # Patch libxgboost.dylib so that it depends on @rpath/libomp.dylib instead of # /opt/homebrew/opt/libomp/lib/libomp.dylib or other hard-coded paths. @@ -102,11 +102,14 @@ function(patch_openmp_path_macos target target_default_output_name) # # Note: This list will only be used if libomp.dylib isn't already loaded into memory. # So Conda users will likely use ${CONDA_PREFIX}/libomp.dylib + execute_process(COMMAND brew --prefix libomp + OUTPUT_VARIABLE HOMEBREW_LIBOMP_PREFIX + OUTPUT_STRIP_TRAILING_WHITESPACE) set_target_properties( ${target} PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE - INSTALL_RPATH "/opt/homebrew/opt/libomp/lib;${__OpenMP_LIBRARY_DIR}" + INSTALL_RPATH "${HOMEBREW_LIBOMP_PREFIX}/lib;${__OpenMP_LIBRARY_DIR}" INSTALL_RPATH_USE_LINK_PATH FALSE ) endfunction() From 4404578fc6138e044c6d0ef0edffb053009055f3 Mon Sep 17 00:00:00 2001 From: Hyunsu Cho Date: Mon, 17 Jun 2024 18:00:23 -0700 Subject: [PATCH 04/11] Fix working dir --- cmake/FindOpenMPMacOS.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/FindOpenMPMacOS.cmake b/cmake/FindOpenMPMacOS.cmake index 236d2fa091d0..d5d5b3089ac9 100644 --- a/cmake/FindOpenMPMacOS.cmake +++ b/cmake/FindOpenMPMacOS.cmake @@ -76,7 +76,7 @@ function(patch_openmp_path_macos target target_default_output_name) ) endif() - message(STATUS "Creating shared lib ${__LIBXGBOOST_FILENAME_${target}}...") + message(STATUS "Creating shared lib: ${__LIBXGBOOST_FILENAME_${target}}") # Override the absolute path to OpenMP with a relative one using @rpath. # @@ -90,7 +90,7 @@ function(patch_openmp_path_macos target target_default_output_name) ${__OpenMP_LIBRARY_LOCATION} "@rpath/${__OpenMP_LIBRARY_NAME}" "${__LIBXGBOOST_FILENAME_${target}}" - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "${__LIBXGBOOST_FILENAME_${target}}: " "Replacing hard-coded OpenMP install_name with '@rpath/${__OpenMP_LIBRARY_NAME}'..." From d3eb94793f95420117d450716abf89ae5db866b5 Mon Sep 17 00:00:00 2001 From: Hyunsu Cho Date: Mon, 17 Jun 2024 18:04:11 -0700 Subject: [PATCH 05/11] Fix working dir --- cmake/FindOpenMPMacOS.cmake | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmake/FindOpenMPMacOS.cmake b/cmake/FindOpenMPMacOS.cmake index d5d5b3089ac9..f7aee2f11c77 100644 --- a/cmake/FindOpenMPMacOS.cmake +++ b/cmake/FindOpenMPMacOS.cmake @@ -81,6 +81,11 @@ function(patch_openmp_path_macos target target_default_output_name) # Override the absolute path to OpenMP with a relative one using @rpath. # # This also ensures that if a libomp.dylib has already been loaded, it'll just use that. + if(KEEP_BUILD_ARTIFACTS_IN_BINARY_DIR) + set(__LIB_DIR ${xgboost_BINARY_DIR}/lib) + else() + set(__LIB_DIR ${xgboost_SOURCE_DIR}/lib) + endif() add_custom_command( TARGET ${target} POST_BUILD @@ -90,7 +95,7 @@ function(patch_openmp_path_macos target target_default_output_name) ${__OpenMP_LIBRARY_LOCATION} "@rpath/${__OpenMP_LIBRARY_NAME}" "${__LIBXGBOOST_FILENAME_${target}}" - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + WORKING_DIRECTORY ${__LIB_DIR} COMMENT "${__LIBXGBOOST_FILENAME_${target}}: " "Replacing hard-coded OpenMP install_name with '@rpath/${__OpenMP_LIBRARY_NAME}'..." From 3b179a2f3ec84c5e4aafe2781ccdb2b61056cbaa Mon Sep 17 00:00:00 2001 From: Hyunsu Cho Date: Mon, 17 Jun 2024 18:06:42 -0700 Subject: [PATCH 06/11] Improve message --- cmake/FindOpenMPMacOS.cmake | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cmake/FindOpenMPMacOS.cmake b/cmake/FindOpenMPMacOS.cmake index f7aee2f11c77..2b90907a69da 100644 --- a/cmake/FindOpenMPMacOS.cmake +++ b/cmake/FindOpenMPMacOS.cmake @@ -96,9 +96,10 @@ function(patch_openmp_path_macos target target_default_output_name) "@rpath/${__OpenMP_LIBRARY_NAME}" "${__LIBXGBOOST_FILENAME_${target}}" WORKING_DIRECTORY ${__LIB_DIR} - COMMENT - "${__LIBXGBOOST_FILENAME_${target}}: " - "Replacing hard-coded OpenMP install_name with '@rpath/${__OpenMP_LIBRARY_NAME}'..." + ) + message(STATUS + "${__LIBXGBOOST_FILENAME_${target}}: " + "Replacing hard-coded OpenMP install_name with '@rpath/${__OpenMP_LIBRARY_NAME}'..." ) # Add RPATH entries to ensure the loader looks in the following, in the following order: # From 8227f630390c018faa2f73cd61b88fc4f06f4b0f Mon Sep 17 00:00:00 2001 From: Hyunsu Cho Date: Mon, 17 Jun 2024 18:26:29 -0700 Subject: [PATCH 07/11] Patch libxgboost4j.dylib too --- CMakeLists.txt | 9 ++++----- cmake/FindOpenMPMacOS.cmake | 2 +- jvm-packages/CMakeLists.txt | 5 +++++ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 072f2eb31495..bb526ad02911 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -234,15 +234,17 @@ endif() find_package(Threads REQUIRED) +# -- OpenMP +include(cmake/FindOpenMPMacOS.cmake) if(USE_OPENMP) if(APPLE) - include(cmake/FindOpenMPMacOS.cmake) find_openmp_macos() else() find_package(OpenMP REQUIRED) endif() endif() -#Add for IBM i + +# Add for IBM i if(${CMAKE_SYSTEM_NAME} MATCHES "OS400") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") set(CMAKE_CXX_ARCHIVE_CREATE " -X64 qc ") @@ -369,9 +371,6 @@ endif() if(USE_OPENMP AND APPLE) patch_openmp_path_macos(xgboost libxgboost) - if(JVM_BINDINGS) - patch_openmp_path_macos(xgboost4j libxgboost4j) - endif() endif() if(KEEP_BUILD_ARTIFACTS_IN_BINARY_DIR) diff --git a/cmake/FindOpenMPMacOS.cmake b/cmake/FindOpenMPMacOS.cmake index 2b90907a69da..a09eb17c036e 100644 --- a/cmake/FindOpenMPMacOS.cmake +++ b/cmake/FindOpenMPMacOS.cmake @@ -76,7 +76,7 @@ function(patch_openmp_path_macos target target_default_output_name) ) endif() - message(STATUS "Creating shared lib: ${__LIBXGBOOST_FILENAME_${target}}") + message(STATUS "Creating shared lib for target ${target}: ${__LIBXGBOOST_FILENAME_${target}}") # Override the absolute path to OpenMP with a relative one using @rpath. # diff --git a/jvm-packages/CMakeLists.txt b/jvm-packages/CMakeLists.txt index c6353d4b7400..83f17f1a8ecf 100644 --- a/jvm-packages/CMakeLists.txt +++ b/jvm-packages/CMakeLists.txt @@ -24,3 +24,8 @@ target_include_directories(xgboost4j ${PROJECT_SOURCE_DIR}/dmlc-core/include) set_output_directory(xgboost4j ${PROJECT_SOURCE_DIR}/lib) + +# MacOS: Patch libxgboost4j.dylib to use @rpath/libomp.dylib +if(USE_OPENMP AND APPLE) + patch_openmp_path_macos(xgboost4j libxgboost4j) +endif() From 2b73c7c5a9d33ec7a5d259bc97d87a86a9561a68 Mon Sep 17 00:00:00 2001 From: Hyunsu Cho Date: Tue, 18 Jun 2024 16:45:01 -0700 Subject: [PATCH 08/11] Update build_python_wheels.sh --- tests/ci_build/build_python_wheels.sh | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/tests/ci_build/build_python_wheels.sh b/tests/ci_build/build_python_wheels.sh index 03a9bc1d6026..ffbe9d1f32cc 100644 --- a/tests/ci_build/build_python_wheels.sh +++ b/tests/ci_build/build_python_wheels.sh @@ -11,15 +11,10 @@ fi platform_id=$1 commit_id=$2 -# Bundle libomp 11.1.0 when targeting MacOS. -# This is a workaround in order to prevent segfaults when running inside a Conda environment. -# See https://github.com/dmlc/xgboost/issues/7039#issuecomment-1025125003 for more context. -# The workaround is also used by the scikit-learn project. if [[ "$platform_id" == macosx_* ]]; then # Make sure to use a libomp version binary compatible with the oldest # supported version of the macos SDK as libomp will be vendored into the # XGBoost wheels for MacOS. - if [[ "$platform_id" == macosx_arm64 ]]; then # MacOS, Apple Silicon # arm64 builds must cross compile because CI is on x64 @@ -28,16 +23,12 @@ if [[ "$platform_id" == macosx_* ]]; then cpython_ver=39 cibw_archs=arm64 export MACOSX_DEPLOYMENT_TARGET=12.0 - #OPENMP_URL="https://anaconda.org/conda-forge/llvm-openmp/11.1.0/download/osx-arm64/llvm-openmp-11.1.0-hf3c4609_1.tar.bz2" - OPENMP_URL="https://xgboost-ci-jenkins-artifacts.s3.us-west-2.amazonaws.com/llvm-openmp-11.1.0-hf3c4609_1-osx-arm64.tar.bz2" elif [[ "$platform_id" == macosx_x86_64 ]]; then # MacOS, Intel wheel_tag=macosx_10_15_x86_64.macosx_11_0_x86_64.macosx_12_0_x86_64 cpython_ver=39 cibw_archs=x86_64 export MACOSX_DEPLOYMENT_TARGET=10.15 - #OPENMP_URL="https://anaconda.org/conda-forge/llvm-openmp/11.1.0/download/osx-64/llvm-openmp-11.1.0-hda6cdc1_1.tar.bz2" - OPENMP_URL="https://xgboost-ci-jenkins-artifacts.s3.us-west-2.amazonaws.com/llvm-openmp-11.1.0-hda6cdc1_1-osx-64.tar.bz2" else echo "Platform not supported: $platform_id" exit 3 @@ -48,18 +39,6 @@ if [[ "$platform_id" == macosx_* ]]; then export CIBW_ENVIRONMENT=${setup_env_var} export CIBW_TEST_SKIP='*-macosx_arm64' export CIBW_BUILD_VERBOSITY=3 - - mamba create -n build $OPENMP_URL - PREFIX="$HOME/miniconda3/envs/build" - - # Set up build flags for cibuildwheel - # This is needed to bundle libomp lib we downloaded earlier - export CC=/usr/bin/clang - export CXX=/usr/bin/clang++ - export CPPFLAGS="$CPPFLAGS -Xpreprocessor -fopenmp" - export CFLAGS="$CFLAGS -I$PREFIX/include" - export CXXFLAGS="$CXXFLAGS -I$PREFIX/include" - export LDFLAGS="$LDFLAGS -Wl,-rpath,$PREFIX/lib -L$PREFIX/lib -lomp" else echo "Platform not supported: $platform_id" exit 2 From c64c30732f3eccd710654bfb07f25af30d948c44 Mon Sep 17 00:00:00 2001 From: Hyunsu Cho Date: Tue, 18 Jun 2024 17:33:05 -0700 Subject: [PATCH 09/11] Exclude libomp from vendoring --- tests/ci_build/build_python_wheels.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/ci_build/build_python_wheels.sh b/tests/ci_build/build_python_wheels.sh index ffbe9d1f32cc..8d18dfca51eb 100644 --- a/tests/ci_build/build_python_wheels.sh +++ b/tests/ci_build/build_python_wheels.sh @@ -12,13 +12,8 @@ platform_id=$1 commit_id=$2 if [[ "$platform_id" == macosx_* ]]; then - # Make sure to use a libomp version binary compatible with the oldest - # supported version of the macos SDK as libomp will be vendored into the - # XGBoost wheels for MacOS. if [[ "$platform_id" == macosx_arm64 ]]; then # MacOS, Apple Silicon - # arm64 builds must cross compile because CI is on x64 - # cibuildwheel will take care of cross-compilation. wheel_tag=macosx_12_0_arm64 cpython_ver=39 cibw_archs=arm64 @@ -44,9 +39,18 @@ else exit 2 fi +# Tell delocate-wheel to not vendor libomp.dylib into the wheel" +export CIBW_REPAIR_WHEEL_COMMAND_MACOS="delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel} --exclude libomp.dylib" + python -m pip install cibuildwheel python -m cibuildwheel python-package --output-dir wheelhouse python tests/ci_build/rename_whl.py \ --wheel-path wheelhouse/*.whl \ --commit-hash ${commit_id} \ --platform-tag ${wheel_tag} + +# List dependencies of libxgboost.dylib +mkdir tmp +unzip -j wheelhouse/xgboost-*.whl xgboost/lib/libxgboost.dylib -d tmp +otool -L tmp/libxgboost.dylib +rm -rf tmp From c31b74aa313ea3b1c0bf711dd3c4328f5526e0ad Mon Sep 17 00:00:00 2001 From: Hyunsu Cho Date: Tue, 18 Jun 2024 17:43:07 -0700 Subject: [PATCH 10/11] Install libomp from Homebrew --- .github/workflows/python_wheels.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/python_wheels.yml b/.github/workflows/python_wheels.yml index f3e7d5817479..4e05864a6dfd 100644 --- a/.github/workflows/python_wheels.yml +++ b/.github/workflows/python_wheels.yml @@ -28,6 +28,10 @@ jobs: - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 with: submodules: 'true' + - name: Set up homebrew + uses: Homebrew/actions/setup-homebrew@68fa6aeb1ccb0596d311f2b34ec74ec21ee68e54 + - name: Install libomp + run: brew install libomp - uses: conda-incubator/setup-miniconda@a4260408e20b96e80095f42ff7f1a15b27dd94ca # v3.0.4 with: miniforge-variant: Mambaforge From ea44cce3976b8a5c04f5b8b3effdcb91760fcfcb Mon Sep 17 00:00:00 2001 From: Hyunsu Cho Date: Tue, 18 Jun 2024 17:54:03 -0700 Subject: [PATCH 11/11] Fix CMake lint --- cmake/FindOpenMPMacOS.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmake/FindOpenMPMacOS.cmake b/cmake/FindOpenMPMacOS.cmake index a09eb17c036e..416a9b8cf1bc 100644 --- a/cmake/FindOpenMPMacOS.cmake +++ b/cmake/FindOpenMPMacOS.cmake @@ -1,5 +1,8 @@ # Find OpenMP library on MacOS # Automatically handle locating libomp from the Homebrew package manager + +# lint_cmake: -package/consistency + macro(find_openmp_macos) if(NOT APPLE) message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION}() must only be used on MacOS")