-
Notifications
You must be signed in to change notification settings - Fork 3.9k
[cmake] fixes static build for macos with OpenMP enabled (fixes #6601) #6600
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@microsoft-github-policy-service agree |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks very much for this, and sorry for breaking builds of the static library on macOS. We probably need to add some CI coverage of that.
Could you please instead skip this entire block, by adding a NOT BUILD_STATIC_LIB
into this condition?
Line 755 in 9a76aae
if(APPLE AND USE_OPENMP) |
All of this logic, like modifying RPATH entries, should be unnecessary for the static library.
Thanks James. Done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix!
I pulled your branch onto my M2 mac and tested like this:
git remote add mottl [email protected]:Mottl/LightGBM.git
git fetch mottl macos_openmp_cmake_fix
cmake \
-B build \
-S . \
-DBUILD_STATIC_LIB=ON \
-DUSE_OPENMP=ON
cmake --build build --target all -j4
Saw everything build successfully, with 0 warnings or errors.
[ 89%] Built target lightgbm_objs
[ 97%] Linking CXX static library /Users/jlamb/repos/LightGBM/lib_lightgbm.a
[ 97%] Building CXX object CMakeFiles/lightgbm.dir/src/application/application.cpp.o
[ 97%] Building CXX object CMakeFiles/lightgbm.dir/src/main.cpp.o
[ 97%] Built target _lightgbm
[100%] Linking CXX executable /Users/jlamb/repos/LightGBM/lightgbm
[100%] Built target lightgbm
Also inspected the library a bit and everything looked correct.
ar -t ./lib_lightgbm.a
nm ./lib_lightgbm.a
Fixes #6601 with
-DBUILD_STATIC_LIB=ON
on macos withUSE_OPENMP
enabled