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

GH-45144: [C++] use std::atomic<std::shared_ptr> instead of std::atomic_load()/std::atomic_store() #45145

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jonkeane
Copy link
Member

@jonkeane jonkeane commented Jan 1, 2025

Rationale for this change

Replace deprecated calls to quite warnings (turned into errors) on GCC15

What changes are included in this PR?

s/atomic_(load|store)/atomic/g not actually this simple.

Are these changes tested?

Yes

Are there any user-facing changes?

There should be none.

@jonkeane
Copy link
Member Author

jonkeane commented Jan 1, 2025

@github-actions crossbow submit test-debian-experimental-cpp-gcc-15

Copy link

github-actions bot commented Jan 1, 2025

Revision: 8b11038

Submitted crossbow builds: ursacomputing/crossbow @ actions-c4407390b8

Task Status
test-debian-experimental-cpp-gcc-15 GitHub Actions

@jonkeane
Copy link
Member Author

jonkeane commented Jan 1, 2025

This isn't working yet — the change(s) needed aren't just substituting. Looking at some examples and https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2869r0.pdf I need to change the type of result to be wrapped by std::atomic<>

https://github.com/jonkeane/arrow/blob/8b110388819afc433bd9bdbe62c6d1c5a93dc3f8/cpp/src/arrow/array/array_nested.cc#L1080-L1081

But haven't quite found the right place for that yet.

Separately + on the CRAN front, I actually think we might be ok to submit something not compatible with C++20 (but would love a double check of my understanding here 🙏 @kou ): from the log output I see at the end:

Failing compile command: g++-15 -E -I/usr/local/include  -g -O2 -Wall -pedantic -mtune=native -Wno-ignored-attributes -Wno-parentheses -Wp,-D_FORTIFY_SOURCE=3 -fexceptions -fstack-protector-strong -fstack-clash-protection -fcf-protection -std=gnu++17 -xc++ -

Am I reading the -std=gnu++17 part correctly that it's using the C++17 standard (with GNU extensions) and not C++20? I also tried building locally with GCC15 + CMAKE_CXX_STANDARD=17 to see if that built ok. I ended up making a PR to run this on crossbow #45150 and it did get past the atomic issue, but there is a slightly different deprecation treated as an error in google test (Though for CRAN purposes, those aren't built, so that might be ok)

FAILED: src/arrow/CMakeFiles/arrow_testing_objlib.dir/io/test_common.cc.o 
/usr/local/bin/sccache /usr/lib/ccache/g++-15 -DARROW_HAVE_RUNTIME_AVX2 -DARROW_HAVE_RUNTIME_AVX512 -DARROW_HAVE_RUNTIME_BMI2 -DARROW_HAVE_RUNTIME_SSE4_2 -DARROW_HAVE_SSE4_2 -DARROW_TESTING_EXPORTING -DARROW_WITH_TIMING_TESTS -DBOOST_ATOMIC_DYN_LINK -DBOOST_ATOMIC_NO_LIB -DBOOST_FILESYSTEM_DYN_LINK -DBOOST_FILESYSTEM_NO_LIB -DBOOST_PROCESS_HAVE_V2 -DBOOST_PROCESS_NEED_SOURCE -DBOOST_SYSTEM_DYN_LINK -DBOOST_SYSTEM_NO_LIB -I/build/cpp/src -I/arrow/cpp/src -I/arrow/cpp/src/generated -isystem /arrow/cpp/thirdparty/flatbuffers/include -Wredundant-move -Wno-noexcept-type -Wno-self-move  -fdiagnostics-color=always  -Wall -Wno-conversion -Wno-sign-conversion -Wdate-time -Wimplicit-fallthrough -Wunused-result -fno-semantic-interposition -msse4.2  -g -Werror -O0 -ggdb -g1 -std=c++17 -fPIC -DGTEST_HAS_PTHREAD=1 -MD -MT src/arrow/CMakeFiles/arrow_testing_objlib.dir/io/test_common.cc.o -MF src/arrow/CMakeFiles/arrow_testing_objlib.dir/io/test_common.cc.o.d -o src/arrow/CMakeFiles/arrow_testing_objlib.dir/io/test_common.cc
In file included from /usr/include/gtest/internal/gtest-port.h:295,
                 from /usr/include/gtest/gtest-message.h:57,
                 from /usr/include/gtest/gtest-assertion-result.h:46,
                 from /usr/include/gtest/gtest.h:63,
                 from /arrow/cpp/src/arrow/testing/gtest_util.h:33,
                 from /arrow/cpp/src/arrow/io/test_common.cc:33:
/usr/include/c++/15/ciso646:46:4: error: #warning "<ciso646> is deprecated in C++17, use <version> to detect implementation-specific macros" [-Werror=cpp]
   46 | #  warning "<ciso646> is deprecated in C++17, use <version> to detect implementation-specific macros"
      |    ^~~~~~~
cc1plus: all warnings being treated as errors
[560/1252] Building CXX object src/arrow/CMakeFiles/arrow_testing_objlib.dir/ipc/test_common.cc.o
FAILED: src/arrow/CMakeFiles/arrow_testing_objlib.dir/ipc/test_common.cc.o 
/usr/local/bin/sccache /usr/lib/ccache/g++-15 -DARROW_HAVE_RUNTIME_AVX2 -DARROW_HAVE_RUNTIME_AVX512 -DARROW_HAVE_RUNTIME_BMI2 -DARROW_HAVE_RUNTIME_SSE4_2 -DARROW_HAVE_SSE4_2 -DARROW_TESTING_EXPORTING -DARROW_WITH_TIMING_TESTS -DBOOST_ATOMIC_DYN_LINK -DBOOST_ATOMIC_NO_LIB -DBOOST_FILESYSTEM_DYN_LINK -DBOOST_FILESYSTEM_NO_LIB -DBOOST_PROCESS_HAVE_V2 -DBOOST_PROCESS_NEED_SOURCE -DBOOST_SYSTEM_DYN_LINK -DBOOST_SYSTEM_NO_LIB -I/build/cpp/src -I/arrow/cpp/src -I/arrow/cpp/src/generated -isystem /arrow/cpp/thirdparty/flatbuffers/include -Wredundant-move -Wno-noexcept-type -Wno-self-move  -fdiagnostics-color=always  -Wall -Wno-conversion -Wno-sign-conversion -Wdate-time -Wimplicit-fallthrough -Wunused-result -fno-semantic-interposition -msse4.2  -g -Werror -O0 -ggdb -g1 -std=c++17 -fPIC -DGTEST_HAS_PTHREAD=1 -MD -MT src/arrow/CMakeFiles/arrow_testing_objlib.dir/ipc/test_common.cc.o -MF src/arrow/CMakeFiles/arrow_testing_objlib.dir/ipc/test_common.cc.o.d -o src/arrow/CMakeFiles/arrow_testing_objlib.dir/ipc/test_common
In file included from /usr/include/gtest/internal/gtest-port.h:295,
                 from /usr/include/gtest/gtest-message.h:57,
                 from /usr/include/gtest/gtest-assertion-result.h:46,
                 from /usr/include/gtest/gtest.h:63,
                 from /arrow/cpp/src/arrow/testing/gtest_util.h:33,
                 from /arrow/cpp/src/arrow/testing/builder.h:30,
                 from /arrow/cpp/src/arrow/ipc/test_common.cc:38:
/usr/include/c++/15/ciso646:46:4: error: #warning "<ciso646> is deprecated in C++17, use <version> to detect implementation-specific macros" [-Werror=cpp]
   46 | #  warning "<ciso646> is deprecated in C++17, use <version> to detect implementation-specific macros"
      |    ^~~~~~~
cc1plus: all warnings being treated as errors
[561/1252] Building CXX object src/arrow/CMakeFiles/arrow_objlib.dir/scalar.cc.o
[562/1252] Building CXX object src/arrow/CMakeFiles/arrow_objlib.dir/c/bridge.cc.o
[563/1252] Building CXX object src/arrow/CMakeFiles/arrow_objlib.dir/type.cc.o

@kou
Copy link
Member

kou commented Jan 2, 2025

Separately + on the CRAN front, I actually think we might be ok to submit something not compatible with C++20 (but would love a double check of my understanding here 🙏 @kou ):

Right.
The C++17 build reports only warnings not errors. We can ignore them by -DBUILD_WARNING_LEVEL=PRODUCTION.

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

Successfully merging this pull request may close these issues.

2 participants