-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Allow building with Clang and OpenMP #6178
Conversation
Signed-off-by: Uilian Ries <[email protected]>
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 your interest in LightGBM and for submitting a patch.
Please let us know if you need help addressing the errors seen in CI jobs... this change appears to break the use of OpenMP with AppleClang
on macOS.
-- The C compiler identification is AppleClang 11.0.3.11030032
-- The CXX compiler identification is AppleClang 11.0.3.11030032
...
-- Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS OpenMP_C_LIB_NAMES)
-- Could NOT find OpenMP_CXX (missing: OpenMP_CXX_FLAGS OpenMP_CXX_LIB_NAMES)
-- Could NOT find OpenMP (missing: OpenMP_C_FOUND OpenMP_CXX_FOUND)
...
[100%] Linking CXX shared library /Users/runner/work/1/s/lib_lightgbm.so
Undefined symbols for architecture x86_64:
"___kmpc_barrier", referenced from:
_.omp_outlined..22 in linear_tree_learner.cpp.o
_.omp_outlined..94 in linear_tree_learner.cpp.o
...
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I'll re-visit it during this week. Sorry my delay. |
Just a suggestion. I don't think STREQUAL works in the way you're trying to use it here, you should probably change it to something like |
I've updated this branch to latest I still don't understand the need for this PR though. LightGBM has 10+ CI jobs running on Ubuntu which compile the library with Lines 82 to 85 in 7435cd8
For example, see the logs from a recent one on
It sure looks to me like:
@uilianries can you give us some more information about your setup? I'd like to try to understand exactly why this PR's patch is required for your situation, so we can maybe modify LightGBM's CI to catch such situations in the future. |
@jameslamb If it works with Ubuntu and Clang 17, so I'm totally fine with it. It was just try to unblock in case building with Clang in Linux. |
Thanks but this is what I'm asking about. I haven't yet been able to reproduce the error you faced in conan-io/conan-center-index#18759. Are you sure it was this change and not, say, that you needed to install OpenMP? |
@jameslamb To install no, to link OpenMP with LightGBM. It's a patch applied until the version 4.1.0. The version 4.2.0 is fine and does not need it. When trying to build with Clang + Linux + OpenMP + 4.1.0 it fails because that condition does not match, so, there is no target link |
hmmmmm that's even more confusing If you look in the git blame view (link), you'll see that this particular condition has been in LightGBM's v4.1.0 came out just 5 months ago (link) and v4.2.0 just 2 months ago (link) It should be the case that this is enough to build LightGBM with OpenMP: Lines 156 to 176 in 0a9a6bb
And I believe it's what is making all of those different builds (across multiple compilers, compiler versions, and operating systems) in this project succeed. Reading through https://cmake.org/cmake/help/latest/command/target_link_libraries.html, I'm concerned that maybe the change in this PR will conflict with that code block I linked to above. I'll restart the failing CI jobs so we can get a more complete picture. Maybe your v4.1.0 build had OpenMP installed in a non-standard place? Or maybe it was using a very old version of CMake? |
I'm closing this due to lack of response. If you have time and interest in the future in describing the problem specifically and working with us to fix it, we'd be happy to consider this proposal again. |
Hello,
This PR brings the option to build LightGBM with OpenMP, when using Clang, not only Apple Clang.
I can build locally with Linux (Ubuntu 16.04) and Clang 13.0: