-
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
build cpp test fails with GCC at v4.2.0 #6252
Comments
Thanks very much for the excellent report, and sorry for the inconvenience. This is making me realize we don't actually run the c++ tests with
Lines 126 to 128 in 4588d64
AppleClang (unsure of the version) on macOS 11 Lines 235 to 238 in 4588d64
MSVC 2019 on Windows Lines 275 to 276 in 4588d64
|
@borchero is this something you could help with? I think the fix would be:
At the current low level of activity in this project, I think we can afford one more |
I'll have a look at this! |
I can't replicate the issue locally, unfortunately, let's see if #6315 helps. |
I ran into this today investigating #4331. On my M2 mac, latest brew install gcc-13
cmake \
-B build \
-S . \
-DBUILD_CPP_TEST=ON \
-DCMAKE_C_COMPILER='gcc-13' \
-DCMAKE_CXX_COMPILER='g++-13'
cmake \
--build build \
--target testlightgbm \
-j4 Configure logs.
End of the build logs.
A patch like this fixed it for me: diff --git a/tests/cpp_tests/test_arrow.cpp b/tests/cpp_tests/test_arrow.cpp
index c2dbd6ce..29bff7dc 100644
--- a/tests/cpp_tests/test_arrow.cpp
+++ b/tests/cpp_tests/test_arrow.cpp
@@ -151,13 +151,7 @@ class ArrowChunkedArrayTest : public testing::Test {
/* ------------------------------------- SCHEMA CREATION ------------------------------------- */
- template <typename T>
- ArrowSchema create_primitive_schema() {
- std::logic_error("not implemented");
- }
-
- template <>
- ArrowSchema create_primitive_schema<float>() {
+ ArrowSchema create_primitive_schema_float() {
ArrowSchema schema;
schema.format = "f";
schema.name = nullptr;
@@ -171,8 +165,7 @@ class ArrowChunkedArrayTest : public testing::Test {
return schema;
}
- template <>
- ArrowSchema create_primitive_schema<bool>() {
+ ArrowSchema create_primitive_schema_bool() {
ArrowSchema schema;
schema.format = "b";
schema.name = nullptr;
@@ -213,7 +206,7 @@ class ArrowChunkedArrayTest : public testing::Test {
/* --------------------------------------------------------------------------------------------- */
TEST_F(ArrowChunkedArrayTest, GetLength) {
- auto schema = create_primitive_schema<float>();
+ auto schema = create_primitive_schema_float();
std::vector<float> dat1 = {1, 2};
auto arr1 = create_primitive_array(dat1);
@@ -241,8 +234,8 @@ TEST_F(ArrowChunkedArrayTest, GetColumns) {
std::vector<ArrowArray*> arrs = {&arr1, &arr2};
auto arr = created_nested_array(arrs);
- auto schema1 = create_primitive_schema<float>();
- auto schema2 = create_primitive_schema<float>();
+ auto schema1 = create_primitive_schema_float();
+ auto schema2 = create_primitive_schema_float();
std::vector<ArrowSchema*> schemas = {&schema1, &schema2};
auto schema = create_nested_schema(schemas);
@@ -266,7 +259,7 @@ TEST_F(ArrowChunkedArrayTest, IteratorArithmetic) {
auto arr2 = create_primitive_array(dat2);
std::vector<float> dat3 = {7};
auto arr3 = create_primitive_array(dat3);
- auto schema = create_primitive_schema<float>();
+ auto schema = create_primitive_schema_float();
ArrowArray arrs[3] = {arr1, arr2, arr3};
ArrowChunkedArray ca(3, arrs, &schema);
@@ -302,7 +295,7 @@ TEST_F(ArrowChunkedArrayTest, BooleanIterator) {
auto arr1 = create_primitive_array(dat1, 0, {2});
std::vector<bool> dat2 = {false, false, false, false, true, true, true, true, false, true};
auto arr2 = create_primitive_array(dat2, 1);
- auto schema = create_primitive_schema<bool>();
+ auto schema = create_primitive_schema_bool();
ArrowArray arrs[2] = {arr1, arr2};
ArrowChunkedArray ca(2, arrs, &schema);
@@ -328,7 +321,7 @@ TEST_F(ArrowChunkedArrayTest, BooleanIterator) {
TEST_F(ArrowChunkedArrayTest, OffsetAndValidity) {
std::vector<float> dat = {0, 1, 2, 3, 4, 5, 6};
auto arr = create_primitive_array(dat, 2, {2, 3});
- auto schema = create_primitive_schema<float>();
+ auto schema = create_primitive_schema_float();
ArrowChunkedArray ca(1, &arr, &schema);
auto it = ca.begin<double>(); |
Just faced this issue with MinGW (gcc-14) on Windows. Upstream bug in gcc: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85282 Another possible workaround: https://cplusplus.com/forum/beginner/188847/ |
Description
When I tried to build cpp_test with gcc, I got the following error.
error: explicit specialization in non-namespace scope ‘class ArrowChunkedArrayTest’
error: template-id ‘create_primitive_schema<float>’ in declaration of primary template
I'm not familiar with cpp and don't know how to handle it, but it seems that the following template needs to be defined outside of the class.
LightGBM/tests/cpp_tests/test_arrow.cpp
Lines 95 to 96 in 4588d64
Reproducible example
docker build . -f Dockerfile
with the following Dockerfile
Environment info
LightGBM version or commit hash: 3405ee8 or later
Command(s) you used to install LightGBM
Additional Comments
The text was updated successfully, but these errors were encountered: