Skip to content

Commit 985621d

Browse files
jonkeaneraulcd
authored andcommitted
GH-48817 [R][C++] Bump C++20 in R build infrastructure (#48819)
Resolves: #48817 ### Rationale for this change Keep R build infrastructure inline with our C++ version ### What changes are included in this PR? Mostly `s/CXX17/CXX20/g` ### Are these changes tested? Yes, lots of CI ### Are there any user-facing changes? **This PR includes breaking changes to public APIs.** (If there are any breaking changes to public APIs, please explain which changes are breaking. If not, you can remove this.) **This PR contains a "Critical Fix".** (If the changes fix either (a) a security vulnerability, (b) a bug that caused incorrect or invalid data to be produced, or (c) a bug that causes a crash (even when the API contract is upheld), please provide explanation. If not, you can remove this.) * GitHub Issue: #48817 Authored-by: Jonathan Keane <jkeane@gmail.com> Signed-off-by: Jonathan Keane <jkeane@gmail.com>
1 parent 1bea06a commit 985621d

File tree

10 files changed

+28
-40
lines changed

10 files changed

+28
-40
lines changed

compose.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1719,9 +1719,9 @@ services:
17191719
cache_from:
17201720
- ${REPO}:amd64-ubuntu-r-valgrind
17211721
args:
1722-
base: wch1/r-debug:latest
1722+
base: rhub/valgrind:latest
17231723
cmake: ${CMAKE}
1724-
r_bin: RDvalgrind
1724+
r_bin: R
17251725
tz: ${TZ}
17261726
environment:
17271727
<<: [*common, *ccache, *sccache]

r/DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ URL: https://github.com/apache/arrow/, https://arrow.apache.org/docs/r/
2828
BugReports: https://github.com/apache/arrow/issues
2929
Encoding: UTF-8
3030
Language: en-US
31-
SystemRequirements: C++17; for AWS S3 support on Linux, libcurl and openssl (optional);
31+
SystemRequirements: C++20; for AWS S3 support on Linux, libcurl and openssl (optional);
3232
cmake >= 3.26 (build-time only, and only for full source build)
3333
Biarch: true
3434
Imports:

r/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ There are some special cases to note:
4444

4545
- On Linux the installation process can sometimes be more involved because CRAN does not host binaries for Linux. For more information please see the [installation guide](https://arrow.apache.org/docs/r/articles/install.html).
4646

47-
- If you are compiling arrow from source, please note that as of version 10.0.0, arrow requires C++17 to build. This has implications on Windows and CentOS 7. For Windows users it means you need to be running an R version of 4.0 or later. On CentOS 7, it means you need to install a newer compiler than the default system compiler gcc. See the [installation details article](https://arrow.apache.org/docs/r/articles/developers/install_details.html) for guidance.
47+
- If you are compiling arrow from source, please note that as of version 23.0.0, arrow requires C++20 to build. This has implications on Windows and CentOS 7. For Windows users it means you need to be running an R version of 4.3 or later (though R 4.2 has incomplete support and might work with special configuration). See the [installation details article](https://arrow.apache.org/docs/r/articles/developers/install_details.html) for guidance.
4848

4949
- Development versions of arrow are released nightly. For information on how to install nightly builds please see the [installing nightly builds](https://arrow.apache.org/docs/r/articles/install_nightly.html) article.
5050

r/configure

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@ if [ "$ARROW_R_DEV" = "true" ] && [ -f "data-raw/codegen.R" ]; then
8686
${R_HOME}/bin/Rscript data-raw/codegen.R
8787
fi
8888

89-
# Arrow requires C++17, so check for it
90-
if [ ! "`${R_HOME}/bin/R CMD config CXX17`" ]; then
89+
# Arrow requires C++20, so check for it
90+
if [ ! "`${R_HOME}/bin/R CMD config CXX20`" ]; then
9191
echo "------------------------- NOTE ---------------------------"
92-
echo "Cannot install arrow: a C++17 compiler is required."
92+
echo "Cannot install arrow: a C++20 compiler is required."
9393
echo "See https://arrow.apache.org/docs/r/articles/install.html"
9494
echo "---------------------------------------------------------"
9595
exit 1
@@ -260,14 +260,6 @@ set_pkg_vars () {
260260
if [ "$ARROW_R_CXXFLAGS" ]; then
261261
PKG_CFLAGS="$PKG_CFLAGS $ARROW_R_CXXFLAGS"
262262
fi
263-
264-
# We use expr because the product version returns more than just 10.13 and we want to
265-
# match the substring. However, expr always outputs the number of matched characters
266-
# to stdout, to avoid noise in the log we redirect the output to /dev/null
267-
if [ "$UNAME" = "Darwin" ] && expr $(sw_vers -productVersion) : '10\.13' >/dev/null 2>&1; then
268-
# avoid C++17 availability warnings on macOS < 11
269-
PKG_CFLAGS="$PKG_CFLAGS -D_LIBCPP_DISABLE_AVAILABILITY"
270-
fi
271263
}
272264

273265
# If we have pkg-config, it will tell us what libarrow needs
@@ -408,11 +400,11 @@ else
408400
fi
409401

410402
# Test that we can compile something with those flags
411-
CXX17="`${R_HOME}/bin/R CMD config CXX17` -E"
412-
CXX17FLAGS=`"${R_HOME}"/bin/R CMD config CXX17FLAGS`
413-
CXX17STD=`"${R_HOME}"/bin/R CMD config CXX17STD`
403+
CXX20="`${R_HOME}/bin/R CMD config CXX20` -E"
404+
CXX20FLAGS=`"${R_HOME}"/bin/R CMD config CXX20FLAGS`
405+
CXX20STD=`"${R_HOME}"/bin/R CMD config CXX20STD`
414406
CPPFLAGS=`"${R_HOME}"/bin/R CMD config CPPFLAGS`
415-
TEST_CMD="${CXX17} ${CPPFLAGS} ${PKG_CFLAGS} ${CXX17FLAGS} ${CXX17STD} -xc++ -"
407+
TEST_CMD="${CXX20} ${CPPFLAGS} ${PKG_CFLAGS} ${CXX20FLAGS} ${CXX20STD} -xc++ -"
416408
TEST_ERROR=$(echo "#include $PKG_TEST_HEADER" | ${TEST_CMD} -o /dev/null 2>&1)
417409

418410
if [ $? -eq 0 ]; then

r/configure.win

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,6 @@ set_pkg_vars () {
117117
if [ "$ARROW_R_CXXFLAGS" ]; then
118118
PKG_CFLAGS="$PKG_CFLAGS $ARROW_R_CXXFLAGS"
119119
fi
120-
121-
# We use expr because the product version returns more than just 10.13 and we want to
122-
# match the substring. However, expr always outputs the number of matched characters
123-
# to stdout, to avoid noise in the log we redirect the output to /dev/null
124-
if [ "$UNAME" = "Darwin" ] && expr $(sw_vers -productVersion) : '10\.13' >/dev/null 2>&1; then
125-
# avoid C++17 availability warnings on macOS < 11
126-
PKG_CFLAGS="$PKG_CFLAGS -D_LIBCPP_DISABLE_AVAILABILITY"
127-
fi
128120
}
129121

130122
# If we have pkg-config, it will tell us what libarrow needs

r/src/Makevars.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ PKG_CPPFLAGS=@cflags@
2525
# https://bugs.llvm.org/show_bug.cgi?id=39191
2626
# https://www.mail-archive.com/gcc-bugs@gcc.gnu.org/msg534862.html
2727
# PKG_CXXFLAGS=$(CXX_VISIBILITY)
28-
CXX_STD=CXX17
28+
CXX_STD=CXX20
2929
PKG_LIBS=@libs@
3030

3131
all: $(SHLIB) purify

r/src/Makevars.ucrt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ CRT=-ucrt
1919
include Makevars.win
2020

2121
# XXX for some reason, this variable doesn't seem propagated from Makevars.win
22-
CXX_STD=CXX17
22+
CXX_STD=CXX20

r/src/compute.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,13 @@ std::shared_ptr<arrow::compute::FunctionOptions> make_compute_options(
162162
// false means descending, true means ascending
163163
// cpp11 does not support bool here so use int
164164
auto orders = cpp11::as_cpp<std::vector<int>>(options["orders"]);
165-
std::vector<Key> keys;
165+
// Use resize + assignment to avoid vector growth operations that trigger
166+
// false positive -Wmaybe-uninitialized warnings in GCC 14 with std::variant
167+
std::vector<Key> keys(names.size(), Key("", Order::Ascending));
166168
for (size_t i = 0; i < names.size(); i++) {
167-
keys.push_back(
168-
Key(names[i], (orders[i] > 0) ? Order::Descending : Order::Ascending));
169+
keys[i] = Key(names[i], (orders[i] > 0) ? Order::Descending : Order::Ascending);
169170
}
170-
auto out = std::make_shared<Options>(Options(keys));
171+
auto out = std::make_shared<Options>(std::move(keys));
171172
return out;
172173
}
173174

r/tools/nixlibs.R

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -310,11 +310,11 @@ compile_test_program <- function(code) {
310310
openssl_dir <- paste0("-I", openssl_root_dir, "/include")
311311
}
312312
runner <- paste(
313-
R_CMD_config("CXX17"),
313+
R_CMD_config("CXX20"),
314314
openssl_dir,
315315
R_CMD_config("CPPFLAGS"),
316-
R_CMD_config("CXX17FLAGS"),
317-
R_CMD_config("CXX17STD"),
316+
R_CMD_config("CXX20FLAGS"),
317+
R_CMD_config("CXX20STD"),
318318
"-E",
319319
"-xc++"
320320
)
@@ -565,8 +565,11 @@ build_libarrow <- function(src_dir, dst_dir) {
565565
# is found, it will be used by the libarrow build, and this does
566566
# not affect how R compiles the arrow bindings.
567567
CC = sub("^.*ccache", "", R_CMD_config("CC")),
568-
CXX = paste(sub("^.*ccache", "", R_CMD_config("CXX17")), R_CMD_config("CXX17STD")),
569-
# CXXFLAGS = R_CMD_config("CXX17FLAGS"), # We don't want the same debug symbols
568+
CXX = paste(
569+
sub("^.*ccache", "", R_CMD_config("CXX20")),
570+
R_CMD_config("CXX20STD")
571+
),
572+
# CXXFLAGS = R_CMD_config("CXX20FLAGS"), # We don't want the same debug symbols
570573
LDFLAGS = R_CMD_config("LDFLAGS"),
571574
N_JOBS = ncores
572575
)

r/vignettes/install.Rmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ but there are a few things to note.
2323

2424
### Compilers
2525

26-
As of version 10.0.0, arrow requires a C++17 compiler to build.
27-
For `gcc`, this generally means version 7 or newer. Most contemporary Linux
26+
As of version 22.0.0, arrow requires a C++20 compiler to build.
27+
For `gcc`, this generally means version 10 or newer. Most contemporary Linux
2828
distributions have a new enough compiler; however, CentOS 7 is a notable
2929
exception, as it ships with gcc 4.8.
3030

0 commit comments

Comments
 (0)