Open StrikerRUS opened 3 years ago
Tested on my mac tonight and this is still an issue.
Providing a reproducible example here, to help anyone wanting to work on this in the future.
mkdir build
cd ./build
cmake \
-DBUILD_CPP_TEST=ON \
-DCMAKE_C_COMPILER='gcc-11' \
-DCMAKE_CXX_COMPILER='g++-11' \
-DUSE_OPENMP=OFF \
-DUSE_SANITIZER=ON \
-DUSE_DEBUG=ON \
-DENABLED_SANITIZERS="thread" \
..
logs:
-- Sanitizers: thread
-- Sanitizers compile flags: -fsanitize=thread
-- Performing Test MM_PREFETCH
-- Performing Test MM_PREFETCH - Failed
-- Performing Test MM_MALLOC
-- Performing Test MM_MALLOC - Failed
-- Could NOT find GTest (missing: GTest_DIR)
-- Did not find Google Test in the system root. Fetching Google Test now...
-- Found Python: /usr/local/Frameworks/Python.framework/Versions/3.11/bin/python3.11 (found version "3.11.1") found components: Interpreter
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - not found
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - no
-- Could NOT find Threads (missing: Threads_FOUND)
-- Could NOT find Threads (missing: Threads_FOUND)
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/jlamb/repos/LightGBM/build
(notice MM_MALLOC - Failed
)
And then built and tested
make testlightgbm -j3
./../testlightgbm
Logs:
[ 1%] Building CXX object CMakeFiles/lightgbm_capi_objs.dir/src/c_api.cpp.o
[ 3%] Building CXX object _deps/googletest-build/googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.o
[ 5%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/boosting/boosting.cpp.o
In file included from /Users/jlamb/repos/LightGBM/include/LightGBM/config.h:16,
from /Users/jlamb/repos/LightGBM/include/LightGBM/boosting.h:8,
from /Users/jlamb/repos/LightGBM/src/c_api.cpp:7:
/Users/jlamb/repos/LightGBM/include/LightGBM/utils/common.h:53:26: error: 'void* malloc(size_t)' was declared 'extern' and later 'static' [-fpermissive]
53 | #define _mm_malloc(a, b) malloc(a)
| ^~~~~~
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/usr/include/stdlib.h:128,
from /usr/local/Cellar/gcc/11.2.0_3/include/c++/11/cstdlib:75,
from /usr/local/Cellar/gcc/11.2.0_3/include/c++/11/ext/string_conversions.h:41,
from /usr/local/Cellar/gcc/11.2.0_3/include/c++/11/bits/basic_string.h:6607,
from /usr/local/Cellar/gcc/11.2.0_3/include/c++/11/string:55,
from /Users/jlamb/repos/LightGBM/include/LightGBM/utils/json11.h:59,
from /Users/jlamb/repos/LightGBM/include/LightGBM/utils/common.h:8,
from /Users/jlamb/repos/LightGBM/include/LightGBM/config.h:16,
from /Users/jlamb/repos/LightGBM/include/LightGBM/boosting.h:8,
from /Users/jlamb/repos/LightGBM/src/c_api.cpp:7:
/Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/usr/include/malloc/_malloc.h:40:10: note: previous declaration of 'void* malloc(size_t)'
40 | void *malloc(size_t __size) __result_use_check __alloc_size(1);
| ^~~~~~
I found this issue on https://ovio.org/projects and would love to contribute! [add other relevant info about you]
@tusharverma200 sure, we'd welcome a contribution! Please put up a pull request if you believe you've found a fix for this issue.
I am using the 3.0.0 version,compiled with gcc 10.5, how to fix the error with this lightgbm version?
I am able to compile by removing all these __mm_malloc to malloc macros.
Personally, I don't think we should have a macro that change a global API like malloc in public header.
Full log
``` 2021-05-29T18:39:02.3137310Z -- The C compiler identification is GNU 10.2.0 2021-05-29T18:39:02.9219720Z -- The CXX compiler identification is GNU 10.2.0 2021-05-29T18:39:02.9595090Z -- Checking whether C compiler has -isysroot 2021-05-29T18:39:03.0275960Z -- Checking whether C compiler has -isysroot - yes 2021-05-29T18:39:03.0301610Z -- Checking whether C compiler supports OSX deployment target flag 2021-05-29T18:39:03.0757480Z -- Checking whether C compiler supports OSX deployment target flag - yes 2021-05-29T18:39:03.0885560Z -- Detecting C compiler ABI info 2021-05-29T18:39:04.1723340Z -- Detecting C compiler ABI info - done 2021-05-29T18:39:04.1880470Z -- Check for working C compiler: /usr/local/bin/gcc-10 - skipped 2021-05-29T18:39:04.1893690Z -- Detecting C compile features 2021-05-29T18:39:04.1911360Z -- Detecting C compile features - done 2021-05-29T18:39:04.1995340Z -- Checking whether CXX compiler has -isysroot 2021-05-29T18:39:04.2428190Z -- Checking whether CXX compiler has -isysroot - yes 2021-05-29T18:39:04.2430300Z -- Checking whether CXX compiler supports OSX deployment target flag 2021-05-29T18:39:04.2836060Z -- Checking whether CXX compiler supports OSX deployment target flag - yes 2021-05-29T18:39:04.2880870Z -- Detecting CXX compiler ABI info 2021-05-29T18:39:04.5925030Z -- Detecting CXX compiler ABI info - done 2021-05-29T18:39:04.6093710Z -- Check for working CXX compiler: /usr/local/bin/g++-10 - skipped 2021-05-29T18:39:04.6098040Z -- Detecting CXX compile features 2021-05-29T18:39:04.6106720Z -- Detecting CXX compile features - done 2021-05-29T18:39:04.6128590Z -- Sanitizers: thread 2021-05-29T18:39:04.6129980Z -- Sanitizers compile flags: -fsanitize=thread 2021-05-29T18:39:04.6156710Z -- Performing Test MM_PREFETCH 2021-05-29T18:39:05.1854760Z -- Performing Test MM_PREFETCH - Failed 2021-05-29T18:39:05.1955100Z -- Performing Test MM_MALLOC 2021-05-29T18:39:05.5547250Z -- Performing Test MM_MALLOC - Failed 2021-05-29T18:39:05.6130890Z -- Could NOT find GTest (missing: GTest_DIR) 2021-05-29T18:39:05.6179760Z -- Did not find Google Test in the system root. Fetching Google Test now... 2021-05-29T18:39:08.1549630Z CMake Deprecation Warning at build/_deps/googletest-src/CMakeLists.txt:4 (cmake_minimum_required): 2021-05-29T18:39:08.1550850Z Compatibility with CMake < 2.8.12 will be removed from a future version of 2021-05-29T18:39:08.1551500Z CMake. 2021-05-29T18:39:08.1551740Z 2021-05-29T18:39:08.1552300Z Update the VERSION argument