From 9323962d9829bdc7f171aa7c75b735f5583806ca Mon Sep 17 00:00:00 2001 From: TeckHack76 Date: Fri, 16 May 2025 02:59:12 +0530 Subject: [PATCH] Update macOS Homebrew libomp instructions for Apple Silicon --- doc/developers/advanced_installation.rst | 30 +++++++++++++++++------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/doc/developers/advanced_installation.rst b/doc/developers/advanced_installation.rst index 1a0c58de77f4e..249cae2e22e00 100644 --- a/doc/developers/advanced_installation.rst +++ b/doc/developers/advanced_installation.rst @@ -280,16 +280,30 @@ Install the LLVM OpenMP library: brew install libomp -Set the following environment variables: +Note: `libomp` is marked as "keg-only" in Homebrew, meaning it is not symlinked into standard system paths. Therefore, you need to explicitly set environment variables to inform the compiler and linker where to find `libomp`. -.. prompt:: bash $ +The installation path of `libomp` depends on your Mac's architecture: + +- **Intel-based Macs**: Homebrew installs packages under `/usr/local/opt/` +- **Apple Silicon (M1/M2) Macs**: Homebrew installs packages under `/opt/homebrew/opt/` + +To determine the correct path, you can use the following command: + +.. prompt:: bash + + brew --prefix libomp + +Set the following environment variables accordingly: + +.. prompt:: bash - export CC=/usr/bin/clang - export CXX=/usr/bin/clang++ - export CPPFLAGS="$CPPFLAGS -Xpreprocessor -fopenmp" - export CFLAGS="$CFLAGS -I/usr/local/opt/libomp/include" - export CXXFLAGS="$CXXFLAGS -I/usr/local/opt/libomp/include" - export LDFLAGS="$LDFLAGS -Wl,-rpath,/usr/local/opt/libomp/lib -L/usr/local/opt/libomp/lib -lomp" + export CC=/usr/bin/clang + export CXX=/usr/bin/clang++ + export CPPFLAGS="$CPPFLAGS -Xpreprocessor -fopenmp" + export CFLAGS="$CFLAGS -I$(brew --prefix libomp)/include" + export CXXFLAGS="$CXXFLAGS -I$(brew --prefix libomp)/include" + export LDFLAGS="$LDFLAGS -L$(brew --prefix libomp)/lib -lomp" + export DYLD_LIBRARY_PATH=$(brew --prefix libomp)/lib Finally, build scikit-learn in verbose mode (to check for the presence of the ``-fopenmp`` flag in the compiler commands):