Skip to content

Commit 9d65981

Browse files
authored
ARROW-17545: [C++][CI] Mandate C++17 instead of C++11 (#13991)
This PR switches our build system to require C++17 instead of C++11. Because the conda packaging jobs are out of sync with the conda-forge files, the Windows conda packaging jobs are broken with this change. The related task (sync conda packaging files with conda-forge) is tracked in ARROW-17635. Authored-by: Antoine Pitrou <[email protected]> Signed-off-by: Antoine Pitrou <[email protected]>
1 parent c9844f0 commit 9d65981

File tree

73 files changed

+284
-189
lines changed

Some content is hidden

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

73 files changed

+284
-189
lines changed

.env

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ ARROW_R_DEV=TRUE
8686
R_PRUNE_DEPS=FALSE
8787
TZ=UTC
8888

89-
# -1 does not attempt to install a devtoolset version, any positive integer will install devtoolset-n
90-
DEVTOOLSET_VERSION=-1
89+
# Any non-empty string will install devtoolset-${DEVTOOLSET_VERSION}
90+
DEVTOOLSET_VERSION=
9191

9292
# Used through docker-compose.yml and serves as the default version for the
9393
# ci/scripts/install_vcpkg.sh script. Prefer to use short SHAs to keep the

.github/workflows/r.yml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,13 @@ jobs:
119119
fail-fast: false
120120
matrix:
121121
config:
122-
- { org: "rstudio", image: "r-base", tag: "4.0-centos7" }
123-
- { org: "rhub", image: "debian-gcc-devel", tag: "latest" }
122+
- { org: "rstudio", image: "r-base", tag: "4.0-centos7", devtoolset: "8" }
123+
- { org: "rhub", image: "debian-gcc-devel", tag: "latest", devtoolset: "" }
124124
env:
125125
R_ORG: ${{ matrix.config.org }}
126126
R_IMAGE: ${{ matrix.config.image }}
127127
R_TAG: ${{ matrix.config.tag }}
128+
DEVTOOLSET_VERSION: ${{ matrix.config.devtoolset }}
128129
steps:
129130
- name: Checkout Arrow
130131
uses: actions/checkout@v3
@@ -184,11 +185,6 @@ jobs:
184185
run: |
185186
ci/scripts/ccache_setup.sh
186187
echo "CCACHE_DIR=$(cygpath --absolute --windows ccache)" >> $GITHUB_ENV
187-
# We must enable actions/cache before r-lib/actions/setup-r to ensure
188-
# using system tar instead of tar provided by Rtools.
189-
# We can use tar provided by Rtools when we drop support for Rtools 3.5.
190-
# Because Rtools 4.0 or later has zstd. actions/cache requires zstd
191-
# when tar is GNU tar.
192188
- name: Cache ccache
193189
uses: actions/cache@v2
194190
with:
@@ -268,8 +264,6 @@ jobs:
268264
with:
269265
r-version: ${{ matrix.config.rversion }}
270266
rtools-version: ${{ matrix.config.rtools }}
271-
# RSPM keeps install times short for 3.6
272-
use-public-rspm: true
273267
Ncpus: 2
274268
- uses: r-lib/actions/setup-r-dependencies@v2
275269
env:

c_glib/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ project('arrow-glib', 'c', 'cpp',
2121
license: 'Apache-2.0',
2222
default_options: [
2323
'c_std=c99',
24-
'cpp_std=c++11',
24+
'cpp_std=c++17',
2525
])
2626

2727
version = '10.0.0-SNAPSHOT'

ci/conan/all/test_package/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ find_package(Arrow REQUIRED)
3030

3131
add_executable(${PROJECT_NAME} test_package.cpp)
3232
target_link_libraries(${PROJECT_NAME} arrow::arrow)
33-
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)
33+
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)
3434
target_compile_definitions(${PROJECT_NAME} PRIVATE WITH_JEMALLOC)

ci/docker/linux-r.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ ENV R_BIN=${r_bin}
2727
ARG r_dev=FALSE
2828
ENV ARROW_R_DEV=${r_dev}
2929

30-
ARG devtoolset_version=-1
30+
ARG devtoolset_version=
3131
ENV DEVTOOLSET_VERSION=${devtoolset_version}
3232

3333
ARG r_prune_deps=FALSE

ci/scripts/cpp_build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ cmake \
142142
-DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE:-OFF} \
143143
-DCMAKE_C_FLAGS="${CFLAGS:-}" \
144144
-DCMAKE_CXX_FLAGS="${CXXFLAGS:-}" \
145-
-DCMAKE_CXX_STANDARD="${CMAKE_CXX_STANDARD:-11}" \
145+
-DCMAKE_CXX_STANDARD="${CMAKE_CXX_STANDARD:-17}" \
146146
-DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR:-lib} \
147147
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX:-${ARROW_HOME}} \
148148
-DCMAKE_UNITY_BUILD=${CMAKE_UNITY_BUILD:-OFF} \

ci/scripts/r_docker_configure.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ if [ ${R_CUSTOM_CCACHE} = "true" ]; then
5757
CCACHE=ccache
5858
CC=\$(CCACHE) gcc\$(VER)
5959
CXX=\$(CCACHE) g++\$(VER)
60-
CXX11=\$(CCACHE) g++\$(VER)" >> ~/.R/Makevars
60+
CXX17=\$(CCACHE) g++\$(VER)" >> ~/.R/Makevars
6161

6262
mkdir -p ~/.ccache/
6363
echo "max_size = 5.0G
@@ -69,7 +69,7 @@ fi
6969

7070
# Special hacking to try to reproduce quirks on centos using non-default build
7171
# tooling.
72-
if [[ "$DEVTOOLSET_VERSION" -gt 0 ]]; then
72+
if [[ -n "$DEVTOOLSET_VERSION" ]]; then
7373
$PACKAGE_MANAGER install -y centos-release-scl
7474
$PACKAGE_MANAGER install -y "devtoolset-$DEVTOOLSET_VERSION"
7575
fi

ci/scripts/r_test.sh

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,21 @@ pushd ${source_dir}
2626

2727
printenv
2828

29+
if [[ -n "$DEVTOOLSET_VERSION" ]]; then
30+
# enable the devtoolset version to use it
31+
source /opt/rh/devtoolset-$DEVTOOLSET_VERSION/enable
32+
33+
# Build images which require the devtoolset don't have CXX17 variables
34+
# set as the system compiler doesn't support C++17
35+
mkdir -p ~/.R
36+
echo "CC = $(which gcc) -fPIC" >> ~/.R/Makevars
37+
echo "CXX17 = $(which g++) -fPIC" >> ~/.R/Makevars
38+
echo "CXX17STD = -std=c++17" >> ~/.R/Makevars
39+
echo "CXX17FLAGS = ${CXX11FLAGS}" >> ~/.R/Makevars
40+
fi
41+
2942
# Run the nixlibs.R test suite, which is not included in the installed package
30-
${R_BIN} -e 'setwd("tools"); testthat::test_dir(".")'
43+
${R_BIN} -e 'setwd("tools"); testthat::test_dir(".")'
3144

3245
# Before release, we always copy the relevant parts of the cpp source into the
3346
# package. In some CI checks, we will use this version of the source:
@@ -77,11 +90,6 @@ export ARROW_DEBUG_MEMORY_POOL=trap
7790
export TEXMFCONFIG=/tmp/texmf-config
7891
export TEXMFVAR=/tmp/texmf-var
7992

80-
if [[ "$DEVTOOLSET_VERSION" -gt 0 ]]; then
81-
# enable the devtoolset version to use it
82-
source /opt/rh/devtoolset-$DEVTOOLSET_VERSION/enable
83-
fi
84-
8593
# Make sure we aren't writing to the home dir (CRAN _hates_ this but there is no official check)
8694
BEFORE=$(ls -alh ~/)
8795

cpp/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -561,10 +561,10 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARROW_CXXFLAGS}")
561561
# C++ specific flags.
562562
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CXX_COMMON_FLAGS} ${ARROW_CXXFLAGS}")
563563

564-
# Remove --std=c++11 to avoid errors from C compilers
565-
string(REPLACE "-std=c++11" "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
564+
# Remove --std=c++17 to avoid errors from C compilers
565+
string(REPLACE "-std=c++17" "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
566566

567-
# Add C++-only flags, like -std=c++11
567+
# Add C++-only flags, like -std=c++17
568568
set(CMAKE_CXX_FLAGS "${CXX_ONLY_FLAGS} ${CMAKE_CXX_FLAGS}")
569569

570570
# ASAN / TSAN / UBSAN

cpp/build-support/update-flatbuffers.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ OUT_DIR="$SOURCE_DIR/generated"
3333
FILES=($(find $FORMAT_DIR -name '*.fbs'))
3434
FILES+=("$SOURCE_DIR/arrow/ipc/feather.fbs")
3535

36-
# add compute ir files
37-
FILES+=($(find "$TOP/experimental/computeir" -name '*.fbs'))
38-
3936
$FLATC --cpp --cpp-std c++11 \
4037
--scoped-enums \
4138
-o "$OUT_DIR" \

0 commit comments

Comments
 (0)