Skip to content
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

Compilation error for cpp tests on macOS with gcc and thread sanitizer #4331

Open
Tracked by #5153
StrikerRUS opened this issue May 29, 2021 · 5 comments
Open
Tracked by #5153

Comments

@StrikerRUS
Copy link
Collaborator

/Users/runner/work/1/s/include/LightGBM/utils/common.h:57:26: error: 'void* malloc(size_t)' was declared 'extern' and later 'static' [-fpermissive]
   57 | #define _mm_malloc(a, b) malloc(a)
      |                          ^~~~~~

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 <min> value or use a ...<max> suffix to tell
2021-05-29T18:39:08.1552990Z   CMake that the project does not need compatibility with older versions.
2021-05-29T18:39:08.1553350Z 
2021-05-29T18:39:08.1553610Z 
2021-05-29T18:39:08.1631240Z CMake Deprecation Warning at build/_deps/googletest-src/googlemock/CMakeLists.txt:45 (cmake_minimum_required):
2021-05-29T18:39:08.1632860Z   Compatibility with CMake < 2.8.12 will be removed from a future version of
2021-05-29T18:39:08.1633950Z   CMake.
2021-05-29T18:39:08.1634690Z 
2021-05-29T18:39:08.1635680Z   Update the VERSION argument <min> value or use a ...<max> suffix to tell
2021-05-29T18:39:08.1637480Z   CMake that the project does not need compatibility with older versions.
2021-05-29T18:39:08.1638340Z 
2021-05-29T18:39:08.1639670Z 
2021-05-29T18:39:08.1641320Z CMake Deprecation Warning at build/_deps/googletest-src/googletest/CMakeLists.txt:56 (cmake_minimum_required):
2021-05-29T18:39:08.1642580Z   Compatibility with CMake < 2.8.12 will be removed from a future version of
2021-05-29T18:39:08.1643570Z   CMake.
2021-05-29T18:39:08.1644280Z 
2021-05-29T18:39:08.1645310Z   Update the VERSION argument <min> value or use a ...<max> suffix to tell
2021-05-29T18:39:08.1646410Z   CMake that the project does not need compatibility with older versions.
2021-05-29T18:39:08.1646900Z 
2021-05-29T18:39:08.1647460Z 
2021-05-29T18:39:08.1901010Z -- Found PythonInterp: /Users/runner/runners/2.187.1/miniconda/bin/python (found version "3.8.5") 
2021-05-29T18:39:08.1970460Z -- Looking for pthread.h
2021-05-29T18:39:08.5137880Z -- Looking for pthread.h - not found
2021-05-29T18:39:08.5169550Z -- Could NOT find Threads (missing: Threads_FOUND) 
2021-05-29T18:39:08.5307370Z -- Could NOT find Threads (missing: Threads_FOUND) 
2021-05-29T18:39:08.5359810Z -- Configuring done
2021-05-29T18:39:08.7928170Z -- Generating done
2021-05-29T18:39:08.8303560Z -- Build files have been written to: /Users/runner/work/1/s/build
2021-05-29T18:39:08.9265520Z [  2%] Building CXX object _deps/googletest-build/googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.o
2021-05-29T18:39:15.6612650Z [  5%] Linking CXX static library ../../../lib/libgtest.a
2021-05-29T18:39:17.0241600Z [  5%] Built target gtest
2021-05-29T18:39:17.0793700Z [ 11%] Building CXX object CMakeFiles/testlightgbm.dir/tests/cpp_tests/test_common.cpp.o
2021-05-29T18:39:17.0910810Z [ 11%] Building CXX object CMakeFiles/testlightgbm.dir/tests/cpp_tests/test_chunked_array.cpp.o
2021-05-29T18:39:17.1030100Z [ 14%] Building CXX object CMakeFiles/testlightgbm.dir/tests/cpp_tests/test_main.cpp.o
2021-05-29T18:39:17.1183830Z [ 17%] Building CXX object CMakeFiles/testlightgbm.dir/src/boosting/boosting.cpp.o
2021-05-29T18:39:20.4011940Z [ 17%] Building CXX object CMakeFiles/testlightgbm.dir/src/boosting/gbdt.cpp.o
2021-05-29T18:39:20.4714620Z In file included from /Users/runner/work/1/s/include/LightGBM/config.h:16,
2021-05-29T18:39:20.4780450Z                  from /Users/runner/work/1/s/include/LightGBM/boosting.h:8,
2021-05-29T18:39:20.4882380Z                  from /Users/runner/work/1/s/src/boosting/boosting.cpp:5:
2021-05-29T18:39:20.4985170Z /Users/runner/work/1/s/include/LightGBM/utils/common.h:57:26: error: 'void* malloc(size_t)' was declared 'extern' and later 'static' [-fpermissive]
2021-05-29T18:39:20.5069060Z    57 | #define _mm_malloc(a, b) malloc(a)
2021-05-29T18:39:20.5170460Z       |                          ^~~~~~
2021-05-29T18:39:20.5171480Z In file included from /Applications/Xcode_11.3.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdlib.h:128,
2021-05-29T18:39:20.5273200Z                  from /usr/local/Cellar/gcc/10.2.0_4/include/c++/10.2.0/cstdlib:75,
2021-05-29T18:39:20.5331850Z                  from /Users/runner/work/1/s/include/LightGBM/utils/log.h:11,
2021-05-29T18:39:20.5433840Z                  from /Users/runner/work/1/s/include/LightGBM/utils/common.h:11,
2021-05-29T18:39:20.5535920Z                  from /Users/runner/work/1/s/include/LightGBM/config.h:16,
2021-05-29T18:39:20.5638900Z                  from /Users/runner/work/1/s/include/LightGBM/boosting.h:8,
2021-05-29T18:39:20.5740780Z                  from /Users/runner/work/1/s/src/boosting/boosting.cpp:5:
2021-05-29T18:39:20.5843850Z /Applications/Xcode_11.3.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/malloc/_malloc.h:40:7: note: previous declaration of 'void* malloc(size_t)'
2021-05-29T18:39:20.5946190Z    40 | void *malloc(size_t __size) __result_use_check __alloc_size(1);
2021-05-29T18:39:20.6048020Z       |       ^~~~~~
2021-05-29T18:39:20.6150630Z In file included from /usr/local/Cellar/gcc/10.2.0_4/lib/gcc/10/gcc/x86_64-apple-darwin18/10.2.0/include/xmmintrin.h:34,
2021-05-29T18:39:20.6253830Z                  from /usr/local/Cellar/gcc/10.2.0_4/lib/gcc/10/gcc/x86_64-apple-darwin18/10.2.0/include/emmintrin.h:31,
2021-05-29T18:39:20.6356340Z                  from /usr/local/Cellar/gcc/10.2.0_4/lib/gcc/10/gcc/x86_64-apple-darwin18/10.2.0/include/pmmintrin.h:31,
2021-05-29T18:39:20.6459010Z                  from /usr/local/Cellar/gcc/10.2.0_4/include/c++/10.2.0/x86_64-apple-darwin18/bits/opt_random.h:34,
2021-05-29T18:39:20.6561060Z                  from /usr/local/Cellar/gcc/10.2.0_4/include/c++/10.2.0/random:50,
2021-05-29T18:39:20.6663270Z                  from /Users/runner/work/1/s/include/LightGBM/utils/random.h:9,
2021-05-29T18:39:20.6765340Z                  from /Users/runner/work/1/s/include/LightGBM/feature_group.h:11,
2021-05-29T18:39:20.6867390Z                  from /Users/runner/work/1/s/include/LightGBM/dataset.h:9,
2021-05-29T18:39:20.6969560Z                  from /Users/runner/work/1/s/include/LightGBM/objective_function.h:9,
2021-05-29T18:39:20.7071520Z                  from /Users/runner/work/1/s/src/boosting/gbdt.h:9,
2021-05-29T18:39:20.7173540Z                  from /Users/runner/work/1/s/src/boosting/dart.hpp:16,
2021-05-29T18:39:20.7275930Z                  from /Users/runner/work/1/s/src/boosting/boosting.cpp:7:
2021-05-29T18:39:20.7378780Z /usr/local/Cellar/gcc/10.2.0_4/lib/gcc/10/gcc/x86_64-apple-darwin18/10.2.0/include/mm_malloc.h: In function 'void* malloc(size_t)':
2021-05-29T18:39:20.7481820Z /usr/local/Cellar/gcc/10.2.0_4/lib/gcc/10/gcc/x86_64-apple-darwin18/10.2.0/include/mm_malloc.h:39:7: error: '__align' was not declared in this scope
2021-05-29T18:39:20.7483520Z    39 |   if (__align & (__align - 1))
2021-05-29T18:39:20.7584650Z       |       ^~~~~~~
2021-05-29T18:39:20.7687220Z /usr/local/Cellar/gcc/10.2.0_4/lib/gcc/10/gcc/x86_64-apple-darwin18/10.2.0/include/mm_malloc.h:54:9: error: '__align' was not declared in this scope
2021-05-29T18:39:20.7789180Z    54 |     if (__align < 2 * sizeof (void *))
2021-05-29T18:39:20.7845820Z       |         ^~~~~~~
2021-05-29T18:39:20.7948370Z /usr/local/Cellar/gcc/10.2.0_4/lib/gcc/10/gcc/x86_64-apple-darwin18/10.2.0/include/mm_malloc.h:57:35: error: '__align' was not declared in this scope
2021-05-29T18:39:20.8002040Z    57 |   __malloc_ptr = malloc (__size + __align);
2021-05-29T18:39:20.8103600Z       |                                   ^~~~~~~
2021-05-29T18:39:20.8205230Z In file included from /Users/runner/work/1/s/include/LightGBM/config.h:16,
2021-05-29T18:39:20.8306970Z                  from /Users/runner/work/1/s/include/LightGBM/boosting.h:8,
2021-05-29T18:39:20.8408740Z                  from /Users/runner/work/1/s/src/boosting/boosting.cpp:5:
2021-05-29T18:39:20.8511770Z /usr/local/Cellar/gcc/10.2.0_4/lib/gcc/10/gcc/x86_64-apple-darwin18/10.2.0/include/mm_malloc.h: At global scope:
2021-05-29T18:39:20.8614520Z /Users/runner/work/1/s/include/LightGBM/utils/common.h:58:21: error: 'void free(void*)' was declared 'extern' and later 'static' [-fpermissive]
2021-05-29T18:39:20.8718330Z    58 | #define _mm_free(a) free(a)
2021-05-29T18:39:20.8820040Z       |                     ^~~~
2021-05-29T18:39:20.8922030Z In file included from /Applications/Xcode_11.3.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdlib.h:128,
2021-05-29T18:39:20.9024000Z                  from /usr/local/Cellar/gcc/10.2.0_4/include/c++/10.2.0/cstdlib:75,
2021-05-29T18:39:20.9125990Z                  from /Users/runner/work/1/s/include/LightGBM/utils/log.h:11,
2021-05-29T18:39:20.9218000Z                  from /Users/runner/work/1/s/include/LightGBM/utils/common.h:11,
2021-05-29T18:39:20.9309600Z                  from /Users/runner/work/1/s/include/LightGBM/config.h:16,
2021-05-29T18:39:20.9411680Z                  from /Users/runner/work/1/s/include/LightGBM/boosting.h:8,
2021-05-29T18:39:20.9513580Z                  from /Users/runner/work/1/s/src/boosting/boosting.cpp:5:
2021-05-29T18:39:20.9616980Z /Applications/Xcode_11.3.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/malloc/_malloc.h:42:7: note: previous declaration of 'void free(void*)'
2021-05-29T18:39:20.9718880Z    42 | void  free(void *);
2021-05-29T18:39:20.9733860Z       |       ^~~~
2021-05-29T18:39:22.0795870Z [ 20%] Building CXX object CMakeFiles/testlightgbm.dir/src/boosting/gbdt_model_text.cpp.o
2021-05-29T18:39:23.1624000Z [ 22%] Building CXX object CMakeFiles/testlightgbm.dir/src/boosting/gbdt_prediction.cpp.o
2021-05-29T18:39:23.4555490Z In file included from /Users/runner/work/1/s/include/LightGBM/config.h:16,
2021-05-29T18:39:23.4657560Z                  from /Users/runner/work/1/s/include/LightGBM/boosting.h:8,
2021-05-29T18:39:23.4757780Z                  from /Users/runner/work/1/s/src/boosting/gbdt.h:8,
2021-05-29T18:39:23.4859620Z                  from /Users/runner/work/1/s/src/boosting/gbdt.cpp:5:
2021-05-29T18:39:23.4960630Z /Users/runner/work/1/s/include/LightGBM/utils/common.h:57:26: error: 'void* malloc(size_t)' was declared 'extern' and later 'static' [-fpermissive]
2021-05-29T18:39:23.5061370Z    57 | #define _mm_malloc(a, b) malloc(a)
2021-05-29T18:39:23.5162810Z       |                          ^~~~~~
2021-05-29T18:39:23.5263240Z In file included from /Applications/Xcode_11.3.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdlib.h:128,
2021-05-29T18:39:23.5365110Z                  from /usr/local/Cellar/gcc/10.2.0_4/include/c++/10.2.0/cstdlib:75,
2021-05-29T18:39:23.5465720Z                  from /Users/runner/work/1/s/include/LightGBM/utils/log.h:11,
2021-05-29T18:39:23.5567470Z                  from /Users/runner/work/1/s/include/LightGBM/utils/common.h:11,
2021-05-29T18:39:23.5667780Z                  from /Users/runner/work/1/s/include/LightGBM/config.h:16,
2021-05-29T18:39:23.5768260Z                  from /Users/runner/work/1/s/include/LightGBM/boosting.h:8,
2021-05-29T18:39:23.5869850Z                  from /Users/runner/work/1/s/src/boosting/gbdt.h:8,
2021-05-29T18:39:23.5969980Z                  from /Users/runner/work/1/s/src/boosting/gbdt.cpp:5:
2021-05-29T18:39:23.6071730Z /Applications/Xcode_11.3.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/malloc/_malloc.h:40:7: note: previous declaration of 'void* malloc(size_t)'
2021-05-29T18:39:23.6171920Z    40 | void *malloc(size_t __size) __result_use_check __alloc_size(1);
2021-05-29T18:39:23.6273360Z       |       ^~~~~~
2021-05-29T18:39:23.6275310Z In file included from /usr/local/Cellar/gcc/10.2.0_4/lib/gcc/10/gcc/x86_64-apple-darwin18/10.2.0/include/xmmintrin.h:34,
2021-05-29T18:39:23.6377650Z                  from /usr/local/Cellar/gcc/10.2.0_4/lib/gcc/10/gcc/x86_64-apple-darwin18/10.2.0/include/emmintrin.h:31,
2021-05-29T18:39:23.6480190Z                  from /usr/local/Cellar/gcc/10.2.0_4/lib/gcc/10/gcc/x86_64-apple-darwin18/10.2.0/include/pmmintrin.h:31,
2021-05-29T18:39:23.6582900Z                  from /usr/local/Cellar/gcc/10.2.0_4/include/c++/10.2.0/x86_64-apple-darwin18/bits/opt_random.h:34,
2021-05-29T18:39:23.6684700Z                  from /usr/local/Cellar/gcc/10.2.0_4/include/c++/10.2.0/random:50,
2021-05-29T18:39:23.6786320Z                  from /Users/runner/work/1/s/include/LightGBM/utils/random.h:9,
2021-05-29T18:39:23.6888090Z                  from /Users/runner/work/1/s/include/LightGBM/feature_group.h:11,
2021-05-29T18:39:23.6989900Z                  from /Users/runner/work/1/s/include/LightGBM/dataset.h:9,
2021-05-29T18:39:23.7091890Z                  from /Users/runner/work/1/s/include/LightGBM/objective_function.h:9,
2021-05-29T18:39:23.7193720Z                  from /Users/runner/work/1/s/src/boosting/gbdt.h:9,
2021-05-29T18:39:23.7295350Z                  from /Users/runner/work/1/s/src/boosting/gbdt.cpp:5:
2021-05-29T18:39:23.7397850Z /usr/local/Cellar/gcc/10.2.0_4/lib/gcc/10/gcc/x86_64-apple-darwin18/10.2.0/include/mm_malloc.h: In function 'void* malloc(size_t)':
2021-05-29T18:39:23.7500480Z /usr/local/Cellar/gcc/10.2.0_4/lib/gcc/10/gcc/x86_64-apple-darwin18/10.2.0/include/mm_malloc.h:39:7: error: '__align' was not declared in this scope
2021-05-29T18:39:23.7603450Z    39 |   if (__align & (__align - 1))
2021-05-29T18:39:23.7704870Z       |       ^~~~~~~
2021-05-29T18:39:23.7807420Z /usr/local/Cellar/gcc/10.2.0_4/lib/gcc/10/gcc/x86_64-apple-darwin18/10.2.0/include/mm_malloc.h:54:9: error: '__align' was not declared in this scope
2021-05-29T18:39:23.7909160Z    54 |     if (__align < 2 * sizeof (void *))
2021-05-29T18:39:23.8010870Z       |         ^~~~~~~
2021-05-29T18:39:23.8113410Z /usr/local/Cellar/gcc/10.2.0_4/lib/gcc/10/gcc/x86_64-apple-darwin18/10.2.0/include/mm_malloc.h:57:35: error: '__align' was not declared in this scope
2021-05-29T18:39:23.8215370Z    57 |   __malloc_ptr = malloc (__size + __align);
2021-05-29T18:39:23.8317100Z       |                                   ^~~~~~~
2021-05-29T18:39:23.8418670Z In file included from /Users/runner/work/1/s/include/LightGBM/config.h:16,
2021-05-29T18:39:23.8520460Z                  from /Users/runner/work/1/s/include/LightGBM/boosting.h:8,
2021-05-29T18:39:23.8622380Z                  from /Users/runner/work/1/s/src/boosting/gbdt.h:8,
2021-05-29T18:39:23.8724500Z                  from /Users/runner/work/1/s/src/boosting/gbdt.cpp:5:
2021-05-29T18:39:23.8827620Z /usr/local/Cellar/gcc/10.2.0_4/lib/gcc/10/gcc/x86_64-apple-darwin18/10.2.0/include/mm_malloc.h: At global scope:
2021-05-29T18:39:23.8930100Z /Users/runner/work/1/s/include/LightGBM/utils/common.h:58:21: error: 'void free(void*)' was declared 'extern' and later 'static' [-fpermissive]
2021-05-29T18:39:23.9031970Z    58 | #define _mm_free(a) free(a)
2021-05-29T18:39:23.9133460Z       |                     ^~~~
2021-05-29T18:39:23.9235270Z In file included from /Applications/Xcode_11.3.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdlib.h:128,
2021-05-29T18:39:23.9337170Z                  from /usr/local/Cellar/gcc/10.2.0_4/include/c++/10.2.0/cstdlib:75,
2021-05-29T18:39:23.9438930Z                  from /Users/runner/work/1/s/include/LightGBM/utils/log.h:11,
2021-05-29T18:39:23.9540730Z                  from /Users/runner/work/1/s/include/LightGBM/utils/common.h:11,
2021-05-29T18:39:23.9642380Z                  from /Users/runner/work/1/s/include/LightGBM/config.h:16,
2021-05-29T18:39:23.9744060Z                  from /Users/runner/work/1/s/include/LightGBM/boosting.h:8,
2021-05-29T18:39:23.9832800Z                  from /Users/runner/work/1/s/src/boosting/gbdt.h:8,
2021-05-29T18:39:23.9934390Z                  from /Users/runner/work/1/s/src/boosting/gbdt.cpp:5:
2021-05-29T18:39:24.0036960Z /Applications/Xcode_11.3.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/malloc/_malloc.h:42:7: note: previous declaration of 'void free(void*)'
2021-05-29T18:39:24.0139030Z    42 | void  free(void *);
2021-05-29T18:39:24.0240850Z       |       ^~~~
2021-05-29T18:39:24.4860710Z cc1plus: note: unrecognized command-line option '-Wno-unused-private-field' may have been intended to silence earlier diagnostics
2021-05-29T18:39:24.4961070Z make[3]: *** [CMakeFiles/testlightgbm.dir/src/boosting/boosting.cpp.o] Error 1
2021-05-29T18:39:24.5062950Z make[3]: *** Waiting for unfinished jobs....
2021-05-29T18:39:24.9223130Z In file included from /Users/runner/work/1/s/include/LightGBM/config.h:16,
2021-05-29T18:39:24.9261310Z                  from /Users/runner/work/1/s/src/boosting/gbdt_model_text.cpp:5:
2021-05-29T18:39:24.9364110Z /Users/runner/work/1/s/include/LightGBM/utils/common.h:57:26: error: 'void* malloc(size_t)' was declared 'extern' and later 'static' [-fpermissive]
2021-05-29T18:39:24.9419860Z    57 | #define _mm_malloc(a, b) malloc(a)
2021-05-29T18:39:24.9521600Z       |                          ^~~~~~
2021-05-29T18:39:24.9622460Z In file included from /Applications/Xcode_11.3.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdlib.h:128,
2021-05-29T18:39:24.9723660Z                  from /usr/local/Cellar/gcc/10.2.0_4/include/c++/10.2.0/cstdlib:75,
2021-05-29T18:39:24.9824640Z                  from /Users/runner/work/1/s/include/LightGBM/utils/log.h:11,
2021-05-29T18:39:24.9926210Z                  from /Users/runner/work/1/s/include/LightGBM/utils/common.h:11,
2021-05-29T18:39:25.0027730Z                  from /Users/runner/work/1/s/include/LightGBM/config.h:16,
2021-05-29T18:39:25.0128220Z                  from /Users/runner/work/1/s/src/boosting/gbdt_model_text.cpp:5:
2021-05-29T18:39:25.0191840Z /Applications/Xcode_11.3.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/malloc/_malloc.h:40:7: note: previous declaration of 'void* malloc(size_t)'
2021-05-29T18:39:25.0294020Z    40 | void *malloc(size_t __size) __result_use_check __alloc_size(1);
2021-05-29T18:39:25.0295240Z       |       ^~~~~~
2021-05-29T18:39:25.0347810Z In file included from /usr/local/Cellar/gcc/10.2.0_4/lib/gcc/10/gcc/x86_64-apple-darwin18/10.2.0/include/xmmintrin.h:34,
2021-05-29T18:39:25.0448640Z                  from /usr/local/Cellar/gcc/10.2.0_4/lib/gcc/10/gcc/x86_64-apple-darwin18/10.2.0/include/emmintrin.h:31,
2021-05-29T18:39:25.0501160Z                  from /usr/local/Cellar/gcc/10.2.0_4/lib/gcc/10/gcc/x86_64-apple-darwin18/10.2.0/include/pmmintrin.h:31,
2021-05-29T18:39:25.0603380Z                  from /usr/local/Cellar/gcc/10.2.0_4/include/c++/10.2.0/x86_64-apple-darwin18/bits/opt_random.h:34,
2021-05-29T18:39:25.0704830Z                  from /usr/local/Cellar/gcc/10.2.0_4/include/c++/10.2.0/random:50,
2021-05-29T18:39:25.0805590Z                  from /Users/runner/work/1/s/include/LightGBM/utils/random.h:9,
2021-05-29T18:39:25.0906940Z                  from /Users/runner/work/1/s/include/LightGBM/feature_group.h:11,
2021-05-29T18:39:25.0996460Z                  from /Users/runner/work/1/s/include/LightGBM/dataset.h:9,
2021-05-29T18:39:25.1083990Z                  from /Users/runner/work/1/s/include/LightGBM/metric.h:9,
2021-05-29T18:39:25.1162590Z                  from /Users/runner/work/1/s/src/boosting/gbdt_model_text.cpp:6:
2021-05-29T18:39:25.1263950Z /usr/local/Cellar/gcc/10.2.0_4/lib/gcc/10/gcc/x86_64-apple-darwin18/10.2.0/include/mm_malloc.h: In function 'void* malloc(size_t)':
2021-05-29T18:39:25.1331630Z /usr/local/Cellar/gcc/10.2.0_4/lib/gcc/10/gcc/x86_64-apple-darwin18/10.2.0/include/mm_malloc.h:39:7: error: '__align' was not declared in this scope
2021-05-29T18:39:25.1434620Z    39 |   if (__align & (__align - 1))
2021-05-29T18:39:25.1534770Z       |       ^~~~~~~
2021-05-29T18:39:25.1594640Z /usr/local/Cellar/gcc/10.2.0_4/lib/gcc/10/gcc/x86_64-apple-darwin18/10.2.0/include/mm_malloc.h:54:9: error: '__align' was not declared in this scope
2021-05-29T18:39:25.1696840Z    54 |     if (__align < 2 * sizeof (void *))
2021-05-29T18:39:25.1752820Z       |         ^~~~~~~
2021-05-29T18:39:25.1855670Z /usr/local/Cellar/gcc/10.2.0_4/lib/gcc/10/gcc/x86_64-apple-darwin18/10.2.0/include/mm_malloc.h:57:35: error: '__align' was not declared in this scope
2021-05-29T18:39:25.1928630Z    57 |   __malloc_ptr = malloc (__size + __align);
2021-05-29T18:39:25.2024280Z       |                                   ^~~~~~~
2021-05-29T18:39:25.2097610Z In file included from /Users/runner/work/1/s/include/LightGBM/config.h:16,
2021-05-29T18:39:25.2199400Z                  from /Users/runner/work/1/s/src/boosting/gbdt_model_text.cpp:5:
2021-05-29T18:39:25.2266490Z /usr/local/Cellar/gcc/10.2.0_4/lib/gcc/10/gcc/x86_64-apple-darwin18/10.2.0/include/mm_malloc.h: At global scope:
2021-05-29T18:39:25.2362740Z /Users/runner/work/1/s/include/LightGBM/utils/common.h:58:21: error: 'void free(void*)' was declared 'extern' and later 'static' [-fpermissive]
2021-05-29T18:39:25.2464820Z    58 | #define _mm_free(a) free(a)
2021-05-29T18:39:25.2554190Z       |                     ^~~~
2021-05-29T18:39:25.2656200Z In file included from /Applications/Xcode_11.3.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdlib.h:128,
2021-05-29T18:39:25.2756890Z                  from /usr/local/Cellar/gcc/10.2.0_4/include/c++/10.2.0/cstdlib:75,
2021-05-29T18:39:25.2758600Z                  from /Users/runner/work/1/s/include/LightGBM/utils/log.h:11,
2021-05-29T18:39:25.2837050Z                  from /Users/runner/work/1/s/include/LightGBM/utils/common.h:11,
2021-05-29T18:39:25.2938860Z                  from /Users/runner/work/1/s/include/LightGBM/config.h:16,
2021-05-29T18:39:25.3037580Z                  from /Users/runner/work/1/s/src/boosting/gbdt_model_text.cpp:5:
2021-05-29T18:39:25.3139050Z /Applications/Xcode_11.3.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/malloc/_malloc.h:42:7: note: previous declaration of 'void free(void*)'
2021-05-29T18:39:25.3240880Z    42 | void  free(void *);
2021-05-29T18:39:25.3342540Z       |       ^~~~
2021-05-29T18:39:25.7728410Z In file included from /Users/runner/work/1/s/include/LightGBM/config.h:16,
2021-05-29T18:39:25.7829000Z                  from /Users/runner/work/1/s/include/LightGBM/objective_function.h:8,
2021-05-29T18:39:25.7929690Z                  from /Users/runner/work/1/s/src/boosting/gbdt_prediction.cpp:5:
2021-05-29T18:39:25.8031970Z /Users/runner/work/1/s/include/LightGBM/utils/common.h:57:26: error: 'void* malloc(size_t)' was declared 'extern' and later 'static' [-fpermissive]
2021-05-29T18:39:25.8090540Z    57 | #define _mm_malloc(a, b) malloc(a)
2021-05-29T18:39:25.8192140Z       |                          ^~~~~~
2021-05-29T18:39:25.8230100Z In file included from /Applications/Xcode_11.3.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdlib.h:128,
2021-05-29T18:39:25.8332020Z                  from /usr/local/Cellar/gcc/10.2.0_4/include/c++/10.2.0/cstdlib:75,
2021-05-29T18:39:25.8434230Z                  from /Users/runner/work/1/s/include/LightGBM/utils/log.h:11,
2021-05-29T18:39:25.8536150Z                  from /Users/runner/work/1/s/include/LightGBM/utils/common.h:11,
2021-05-29T18:39:25.8637900Z                  from /Users/runner/work/1/s/include/LightGBM/config.h:16,
2021-05-29T18:39:25.8705850Z                  from /Users/runner/work/1/s/include/LightGBM/objective_function.h:8,
2021-05-29T18:39:25.8802020Z                  from /Users/runner/work/1/s/src/boosting/gbdt_prediction.cpp:5:
2021-05-29T18:39:25.8872090Z /Applications/Xcode_11.3.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/malloc/_malloc.h:40:7: note: previous declaration of 'void* malloc(size_t)'
2021-05-29T18:39:25.8948990Z    40 | void *malloc(size_t __size) __result_use_check __alloc_size(1);
2021-05-29T18:39:25.9047330Z       |       ^~~~~~
2021-05-29T18:39:25.9150080Z In file included from /usr/local/Cellar/gcc/10.2.0_4/lib/gcc/10/gcc/x86_64-apple-darwin18/10.2.0/include/xmmintrin.h:34,
2021-05-29T18:39:25.9252700Z                  from /usr/local/Cellar/gcc/10.2.0_4/lib/gcc/10/gcc/x86_64-apple-darwin18/10.2.0/include/emmintrin.h:31,
2021-05-29T18:39:25.9334010Z                  from /usr/local/Cellar/gcc/10.2.0_4/lib/gcc/10/gcc/x86_64-apple-darwin18/10.2.0/include/pmmintrin.h:31,
2021-05-29T18:39:25.9436900Z                  from /usr/local/Cellar/gcc/10.2.0_4/include/c++/10.2.0/x86_64-apple-darwin18/bits/opt_random.h:34,
2021-05-29T18:39:25.9498370Z                  from /usr/local/Cellar/gcc/10.2.0_4/include/c++/10.2.0/random:50,
2021-05-29T18:39:25.9580640Z                  from /Users/runner/work/1/s/include/LightGBM/utils/random.h:9,
2021-05-29T18:39:25.9655240Z                  from /Users/runner/work/1/s/include/LightGBM/feature_group.h:11,
2021-05-29T18:39:25.9757020Z                  from /Users/runner/work/1/s/include/LightGBM/dataset.h:9,
2021-05-29T18:39:25.9856110Z                  from /Users/runner/work/1/s/include/LightGBM/objective_function.h:9,
2021-05-29T18:39:25.9970280Z                  from /Users/runner/work/1/s/src/boosting/gbdt_prediction.cpp:5:
2021-05-29T18:39:26.0030460Z /usr/local/Cellar/gcc/10.2.0_4/lib/gcc/10/gcc/x86_64-apple-darwin18/10.2.0/include/mm_malloc.h: In function 'void* malloc(size_t)':
2021-05-29T18:39:26.0135830Z /usr/local/Cellar/gcc/10.2.0_4/lib/gcc/10/gcc/x86_64-apple-darwin18/10.2.0/include/mm_malloc.h:39:7: error: '__align' was not declared in this scope
2021-05-29T18:39:26.0248500Z    39 |   if (__align & (__align - 1))
2021-05-29T18:39:26.0307170Z       |       ^~~~~~~
2021-05-29T18:39:26.0405210Z /usr/local/Cellar/gcc/10.2.0_4/lib/gcc/10/gcc/x86_64-apple-darwin18/10.2.0/include/mm_malloc.h:54:9: error: '__align' was not declared in this scope
2021-05-29T18:39:26.0467260Z    54 |     if (__align < 2 * sizeof (void *))
2021-05-29T18:39:26.0569960Z       |         ^~~~~~~
2021-05-29T18:39:26.0689200Z /usr/local/Cellar/gcc/10.2.0_4/lib/gcc/10/gcc/x86_64-apple-darwin18/10.2.0/include/mm_malloc.h:57:35: error: '__align' was not declared in this scope
2021-05-29T18:39:26.0690590Z    57 |   __malloc_ptr = malloc (__size + __align);
2021-05-29T18:39:26.0759330Z       |                                   ^~~~~~~
2021-05-29T18:39:26.0838750Z In file included from /Users/runner/work/1/s/include/LightGBM/config.h:16,
2021-05-29T18:39:26.0933390Z                  from /Users/runner/work/1/s/include/LightGBM/objective_function.h:8,
2021-05-29T18:39:26.1041030Z                  from /Users/runner/work/1/s/src/boosting/gbdt_prediction.cpp:5:
2021-05-29T18:39:26.1102160Z /usr/local/Cellar/gcc/10.2.0_4/lib/gcc/10/gcc/x86_64-apple-darwin18/10.2.0/include/mm_malloc.h: At global scope:
2021-05-29T18:39:26.1180760Z /Users/runner/work/1/s/include/LightGBM/utils/common.h:58:21: error: 'void free(void*)' was declared 'extern' and later 'static' [-fpermissive]
2021-05-29T18:39:26.1264090Z    58 | #define _mm_free(a) free(a)
2021-05-29T18:39:26.1360340Z       |                     ^~~~
2021-05-29T18:39:26.1424810Z In file included from /Applications/Xcode_11.3.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdlib.h:128,
2021-05-29T18:39:26.1526490Z                  from /usr/local/Cellar/gcc/10.2.0_4/include/c++/10.2.0/cstdlib:75,
2021-05-29T18:39:26.1625000Z                  from /Users/runner/work/1/s/include/LightGBM/utils/log.h:11,
2021-05-29T18:39:26.1726840Z                  from /Users/runner/work/1/s/include/LightGBM/utils/common.h:11,
2021-05-29T18:39:26.1773570Z                  from /Users/runner/work/1/s/include/LightGBM/config.h:16,
2021-05-29T18:39:26.1876180Z                  from /Users/runner/work/1/s/include/LightGBM/objective_function.h:8,
2021-05-29T18:39:26.1939010Z                  from /Users/runner/work/1/s/src/boosting/gbdt_prediction.cpp:5:
2021-05-29T18:39:26.2031870Z /Applications/Xcode_11.3.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/malloc/_malloc.h:42:7: note: previous declaration of 'void free(void*)'
2021-05-29T18:39:26.2133960Z    42 | void  free(void *);
2021-05-29T18:39:26.2175010Z       |       ^~~~
2021-05-29T18:39:27.2086690Z cc1plus: note: unrecognized command-line option '-Wno-unused-private-field' may have been intended to silence earlier diagnostics
2021-05-29T18:39:27.2289360Z make[3]: *** [CMakeFiles/testlightgbm.dir/src/boosting/gbdt.cpp.o] Error 1
2021-05-29T18:39:27.7881930Z cc1plus: note: unrecognized command-line option '-Wno-unused-private-field' may have been intended to silence earlier diagnostics
2021-05-29T18:39:27.7908800Z make[3]: *** [CMakeFiles/testlightgbm.dir/src/boosting/gbdt_model_text.cpp.o] Error 1
2021-05-29T18:39:27.8775980Z cc1plus: note: unrecognized command-line option '-Wno-unused-private-field' may have been intended to silence earlier diagnostics
2021-05-29T18:39:27.8874510Z make[3]: *** [CMakeFiles/testlightgbm.dir/src/boosting/gbdt_prediction.cpp.o] Error 1
2021-05-29T18:39:27.8877080Z make[2]: *** [CMakeFiles/testlightgbm.dir/all] Error 2
2021-05-29T18:39:27.8879230Z make[1]: *** [CMakeFiles/testlightgbm.dir/rule] Error 2
2021-05-29T18:39:27.8881210Z make: *** [testlightgbm] Error 2
2021-05-29T18:39:27.8965200Z ##[error]Bash exited with code '255'.
2021-05-29T18:39:27.8983120Z ##[section]Finishing: Test
@jameslamb
Copy link
Collaborator

jameslamb commented Feb 1, 2023

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);
      |          ^~~~~~

@tusharverma200

This comment was marked as spam.

@jameslamb
Copy link
Collaborator

@tusharverma200 sure, we'd welcome a contribution! Please put up a pull request if you believe you've found a fix for this issue.

@gxkevin
Copy link

gxkevin commented Jul 31, 2023

I am using the 3.0.0 version,compiled with gcc 10.5, how to fix the error with this lightgbm version?

@hgminh95
Copy link
Contributor

hgminh95 commented Jul 2, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants