Skip to content

Commit 30809c6

Browse files
authored
GH-45885: [C++] Require C++20 (#48414)
### Rationale for this change We decided to migrate Arrow C++ to C++20 in this discussion: https://lists.apache.org/thread/48zlj0dn2y0f53y2k37qsr90y781wfnj ### What changes are included in this PR? 1. Build configuration updates (CMake files etc.) to build with C++20 instead of C++17 2. C++-level fixes to ensure compilation succeeds: * Workarounds for deprecation of atomic access on `std::shared_ptr<T>` (the replacement `std::atomic<std::shared_ptr<T>>` is unfortunately not supported in all standard library implementations) * Workaround for [Abseil ABI issues](abseil/abseil-cpp#1624) * Trivial update to `arrow/util/string.h` to call a C++20 API (to validate that C++20 is actually enabled) 3. CI configuration updates to get enough C++20 support on the various platforms: * Bump default clang and LLVM versions to 18 * Use AlmaLinux 10 for release verification (AlmaLinux 8 is still tested on other CI builds) ### Are these changes tested? Yes. ### Are there any user-facing changes? Yes, Arrow C++ will now require a C++20-compliant compiler. * GitHub Issue: #45885 Authored-by: Antoine Pitrou <[email protected]> Signed-off-by: Antoine Pitrou <[email protected]>
1 parent d6cc592 commit 30809c6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+295
-178
lines changed

.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ FEDORA=42
5757
UBUNTU=22.04
5858

5959
# Default versions for various dependencies
60-
CLANG_TOOLS=14
60+
CLANG_TOOLS=18
6161
CMAKE=3.26.0
6262
CUDA=11.7.1
6363
DASK=latest

.github/workflows/cpp.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,24 +81,24 @@ jobs:
8181
matrix:
8282
include:
8383
- arch: amd64
84-
clang-tools: 14
84+
clang-tools: 18
8585
image: conda-cpp
86-
llvm: 14
86+
llvm: 18
8787
runs-on: ubuntu-latest
8888
simd-level: AVX2
8989
title: AMD64 Conda C++ AVX2
9090
ubuntu: 22.04
9191
- arch: amd64
92-
clang-tools: 14
92+
clang-tools: 18
9393
image: ubuntu-cpp-sanitizer
94-
llvm: 14
94+
llvm: 18
9595
runs-on: ubuntu-latest
9696
title: AMD64 Ubuntu 24.04 C++ ASAN UBSAN
9797
ubuntu: 24.04
9898
- arch: arm64v8
99-
clang-tools: 14
99+
clang-tools: 18
100100
image: ubuntu-cpp
101-
llvm: 14
101+
llvm: 18
102102
runs-on: ubuntu-24.04-arm
103103
title: ARM64 Ubuntu 22.04 C++
104104
ubuntu: 22.04

.github/workflows/cpp_extra.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,6 @@ jobs:
347347
ARROW_DEPENDENCY_SOURCE: VCPKG
348348
ARROW_FLIGHT_SQL_ODBC: ON
349349
ARROW_SIMD_LEVEL: AVX2
350-
CMAKE_CXX_STANDARD: "17"
351350
CMAKE_GENERATOR: Ninja
352351
CMAKE_INSTALL_PREFIX: /usr
353352
VCPKG_BINARY_SOURCES: 'clear;nuget,GitHub,readwrite'

.github/workflows/cpp_windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
ARROW_WITH_ZLIB: ON
6464
ARROW_WITH_ZSTD: ON
6565
BOOST_SOURCE: BUNDLED
66-
CMAKE_CXX_STANDARD: "17"
66+
CMAKE_CXX_STANDARD: "20"
6767
CMAKE_GENERATOR: Ninja
6868
CMAKE_INSTALL_PREFIX: /usr
6969
CMAKE_UNITY_BUILD: ON

.github/workflows/r.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,13 @@ jobs:
229229
# static library. The R is not used here but R 4.1 was the last R to use
230230
# Rtools40.
231231
r-version: "4.1"
232-
rtools-version: 40
232+
rtools-version: ${{ matrix.config.rtools }}
233233
Ncpus: 2
234234
- name: Build Arrow C++
235235
shell: bash
236236
env:
237237
MINGW_ARCH: ${{ matrix.config.arch }}
238+
RTOOLS_VERSION: ${{ matrix.config.rtools }}
238239
run: ci/scripts/r_windows_build.sh
239240
- name: Rename libarrow.zip
240241
# So that they're unique when multiple are downloaded in the next step

.github/workflows/ruby.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ jobs:
349349
ARROW_WITH_SNAPPY: ON
350350
ARROW_WITH_ZLIB: ON
351351
ARROW_WITH_ZSTD: ON
352-
CMAKE_CXX_STANDARD: "17"
352+
CMAKE_CXX_STANDARD: "20"
353353
CMAKE_GENERATOR: Ninja
354354
CMAKE_INSTALL_PREFIX: "${{ github.workspace }}/dist"
355355
VCPKG_BINARY_SOURCES: 'clear;nuget,GitHub,readwrite'

c_glib/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ project(
2121
'arrow-glib',
2222
'c',
2323
'cpp',
24-
default_options: ['c_std=c99', 'cpp_std=c++17'],
24+
default_options: ['c_std=c99', 'cpp_std=c++20'],
2525
license: 'Apache-2.0',
2626
# Debian:
2727
# https://packages.debian.org/search?keywords=meson
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
ARG arch=amd64
19+
FROM ${arch}/almalinux:10
20+
21+
COPY dev/release/setup-rhel-rebuilds.sh /
22+
RUN /setup-rhel-rebuilds.sh && \
23+
rm /setup-rhel-rebuilds.sh && \
24+
dnf -y clean all

ci/docker/debian-experimental-cpp.dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ RUN if [ -n "${gcc}" ]; then \
5959
libldap-dev \
6060
liblz4-dev \
6161
libnghttp2-dev \
62+
libopentelemetry-proto-dev \
6263
libprotobuf-dev \
6364
libprotoc-dev \
6465
libpsl-dev \
@@ -88,6 +89,7 @@ RUN if [ -n "${gcc}" ]; then \
8889
rapidjson-dev \
8990
rsync \
9091
tzdata \
92+
tzdata-legacy \
9193
zlib1g-dev && \
9294
apt-get install -y -q --no-install-recommends -t experimental \
9395
clang${llvm_package_suffix} \

ci/scripts/cpp_build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ elif [ "${ARROW_EMSCRIPTEN:-OFF}" = "ON" ]; then
168168
-DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE:-OFF} \
169169
-DCMAKE_C_FLAGS="${CFLAGS:-}" \
170170
-DCMAKE_CXX_FLAGS="${CXXFLAGS:-}" \
171-
-DCMAKE_CXX_STANDARD="${CMAKE_CXX_STANDARD:-17}" \
171+
-DCMAKE_CXX_STANDARD="${CMAKE_CXX_STANDARD:-20}" \
172172
-DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR:-lib} \
173173
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX:-${ARROW_HOME}} \
174174
-DCMAKE_UNITY_BUILD=${CMAKE_UNITY_BUILD:-OFF} \
@@ -260,7 +260,7 @@ else
260260
-DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE:-OFF} \
261261
-DCMAKE_C_FLAGS="${CFLAGS:-}" \
262262
-DCMAKE_CXX_FLAGS="${CXXFLAGS:-}" \
263-
-DCMAKE_CXX_STANDARD="${CMAKE_CXX_STANDARD:-17}" \
263+
-DCMAKE_CXX_STANDARD="${CMAKE_CXX_STANDARD:-20}" \
264264
-DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR:-lib} \
265265
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX:-${ARROW_HOME}} \
266266
-DCMAKE_UNITY_BUILD=${CMAKE_UNITY_BUILD:-OFF} \

0 commit comments

Comments
 (0)