-
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
Change cxx standard from 11 to 14 in CMake #6429
Conversation
Thanks for using LightGBM. We are going to need a lot more information than this before accepting this patch to change the default C++ standard for the entire project.
LightGBM is built with multiple different versions of clang (including 16, 17, and 18) across two different versions of Ubuntu, and for multiple configurations of LightGBM build options. It's also tested on multiple versions of macOS and AppleClang. See #6178 (comment) Almost all of those leave the project's C++ standard at its default, C++11. The issue you're experiencing cannot simply be "LightGBM can't be compiled with |
@jameslamb Hi, my environment info: when I compile with no modifications, there are some errors:
In https://en.cppreference.com/w/cpp/types/enable_if, it saided that enable_if_t is since c++14: Helper typestemplate< bool B, class T = void >using enable_if_t = typename enable_if::type; | | (since C++14) |
Thanks for the details. I'm not able to replicate that. I just compiled the latest version of LightGBM on an M2 macOS laptop (very similar to your setup). git clone \
--recursive \
https://github.com/microsoft/LightGBM.git \
/tmp/LightGBM
cd /tmp/LightGBM
cmake -B build -S .
cmake --build build Compilation of LightGBM succeeded, using a very similar version of AppleClang to the one you're using. configure logs (click me)-- The C compiler identification is AppleClang 15.0.0.15000309
-- The CXX compiler identification is AppleClang 15.0.0.15000309
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- 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)
-- Found OpenMP_C: -Xpreprocessor -fopenmp -I/opt/homebrew/opt/libomp/include (found version "5.0")
-- Found OpenMP_CXX: -Xpreprocessor -fopenmp -I/opt/homebrew/opt/libomp/include (found version "5.0")
-- Found OpenMP: TRUE (found version "5.0")
-- Performing Test MM_PREFETCH
-- Performing Test MM_PREFETCH - Failed
-- Performing Test MM_MALLOC
-- Performing Test MM_MALLOC - Success
-- Using _mm_malloc
-- Configuring done (0.9s)
-- Generating done (0.0s)
-- Build files have been written to: /tmp/LightGBM/build Build logs (click me)
More information about my setup: cmake --version
# cmake version 3.26.4
clang++ --version
# Apple clang version 15.0.0 (clang-1500.3.9.4)
# Target: arm64-apple-darwin23.4.0
# Thread model: posix
# InstalledDir: /Library/Developer/CommandLineTools/usr/bin I do not see any uses of git grep enable_if_t I strongly suspect that the issue you're facing lies in some difference between your setup and mine. If you want to see LightGBM drop C++11 support by default, we'll have to identify that difference. So, to start... what do you observe if you run the exact same commands I shared above? Please share all the logs as I did. |
@jameslamb Hi, I find that I use wrong submodule version:
Sorry for my mistake. I will close the PR. |
ah interesting! Ok then yeah I guess maybe you got a different version of No problem, thanks for using LightGBM. |
compile in macos with clang15 failed when cxx11 in cmake because enable_if_t is available since c++14