Skip to content

Fix OpenMP build failure on macOS#2

Merged
JMorado merged 1 commit into
michellab:masterfrom
JMorado:add-mac-support
May 22, 2026
Merged

Fix OpenMP build failure on macOS#2
JMorado merged 1 commit into
michellab:masterfrom
JMorado:add-mac-support

Conversation

@JMorado
Copy link
Copy Markdown
Collaborator

@JMorado JMorado commented May 22, 2026

This PR fixes the following issue that occurred on macOS when trying to install PyXDM via pip install -e:

      clang++ -fno-strict-overflow -Wsign-compare -Wunreachable-code -DNDEBUG -O2 -Wall -fPIC -O2 -isystem /Users/joaomorado/.local/share/mamba/envs/pyxdm/include -arch arm64 -fPIC -O2 -isystem /Users/joaomorado/.local/share/mamba/envs/pyxdm/include -arch arm64 -I/private/var/folders/pk/bm5cw1295zz3n_228g98rz740000gn/T/pip-build-env-4a8mudzl/overlay/lib/python3.12/site-packages/pybind11/include -I/Users/joaomorado/.local/share/mamba/envs/pyxdm/include/python3.12 -c pyxdm/cpp/exchange_hole.cpp -o /var/folders/pk/bm5cw1295zz3n_228g98rz740000gn/T/tmpmktk64mk.build-temp/pyxdm/cpp/exchange_hole.o -O3 -fopenmp
      clang++: error: unsupported option '-fopenmp'
      error: command '/usr/bin/clang++' failed with exit code 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building editable for pyxdm
Failed to build pyxdm
error: failed-wheel-build-for-install

× Failed to build installable wheels for some pyproject.toml based projects
╰─> pyxdm

Apple's bundled clang does not support -fopenmp directly. As a result, building the exchange_hole_cpp C++ extension fails on macOS systems. This PR updates setup.py to detect macOS at build time and apply the appropriate compiler and linker flags using the OpenMP runtime provided by the active conda environment. It also adds llvm-openmp to the conda environment dependencies.

@JMorado JMorado merged commit e241d9d into michellab:master May 22, 2026
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.

1 participant