Skip to content

Fix macOS wheel OpenMP dependency resolution#12108

Merged
RAMitchell merged 7 commits intodmlc:masterfrom
RAMitchell:pr-12107-macos-only
Mar 19, 2026
Merged

Fix macOS wheel OpenMP dependency resolution#12108
RAMitchell merged 7 commits intodmlc:masterfrom
RAMitchell:pr-12107-macos-only

Conversation

@RAMitchell
Copy link
Copy Markdown
Member

Summary

This PR fixes the macOS x86_64 wheel CI failure.

The failing job was:

  • Build macOS wheel (macosx_x86_64)

delocate failed while repairing the wheel because libxgboost.dylib picked up Homebrew LLVM's libunwind.1.0.dylib, and that dependency requires macOS 14.0 even though the wheel target is macOS 10.15.

Root Cause

On the macOS Intel runner, the wheel build was resolving OpenMP through Homebrew. That introduced a dependency on Homebrew LLVM's libunwind, which caused wheel repair to fail with:

delocate.libsana.DelocationError: Library dependencies do not satisfy target MacOS version 10.15:
.../libunwind.1.0.dylib has a minimum target of 14.0

@RAMitchell RAMitchell requested a review from Copilot March 19, 2026 11:37
@trivialfis
Copy link
Copy Markdown
Member

Note that the wheel is used by pypi.

#11983 (comment)

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes macOS x86_64 wheel repair failures by ensuring the build links against a Conda-provided OpenMP runtime (avoiding Homebrew LLVM’s libunwind and its higher minimum macOS target).

Changes:

  • Install llvm-openmp in the macOS wheel build pipeline and prefer the active Conda prefix in CMAKE_PREFIX_PATH.
  • Update the macOS OpenMP CMake logic to prefer libomp.dylib from CONDA_PREFIX when present, with Homebrew fallback.
  • Extend the OpenMP RPATH patching to prioritize $CONDA_PREFIX/lib during builds in a Conda environment.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
ops/pipeline/build-python-wheels-macos.sh Installs Conda OpenMP runtime and adjusts prefix search order for wheel builds.
cmake/FindOpenMPMacOS.cmake Prefers Conda libomp and adjusts RPATH ordering to resolve OpenMP from Conda first.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

# Prefer Conda's OpenMP runtime for wheel builds on macOS. Homebrew's libomp can
# pull in Homebrew LLVM's libunwind, which raises the effective deployment target
# of the repaired wheel.
conda install -y llvm-openmp
Comment on lines 124 to 127
# - $CONDA_PREFIX/lib (when building inside a Conda environment)
# - /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)
#
@RAMitchell
Copy link
Copy Markdown
Member Author

I really don't have much experience here so feel free to take over.

@trivialfis
Copy link
Copy Markdown
Member

trivialfis commented Mar 19, 2026

I really don't have much experience here so feel free to take over.

No one does. ;-(

I borrowed a macbook and used another mac pro from aws at the time to see how it works ...

Basically, I gave up after wasting a lot of time trying to work around it. To handle it properly, we will either:

  • Remove parallel for CPU entirely on macos.
  • Use the existing thread pool in XGBoost to replace the OpenMP runtime, inject it into the common::ParallelFor.

@RAMitchell RAMitchell merged commit dd2bd66 into dmlc:master Mar 19, 2026
78 checks passed
@trivialfis
Copy link
Copy Markdown
Member

cc @hcho3

@RAMitchell RAMitchell deleted the pr-12107-macos-only branch March 23, 2026 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants