Skip to content

Commit 1cc9c72

Browse files
xuhdevfacebook-github-bot
authored andcommitted
Compile with C++20 instead of C++17 (facebook#953)
Summary: Pull Request resolved: facebook#953 Differential Revision: D79466725
1 parent 1c6594b commit 1cc9c72

File tree

7 files changed

+20
-15
lines changed

7 files changed

+20
-15
lines changed

.github/actions/setup-build-and-test-w-make-impl/action.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ runs:
2929
- name: Cache build
3030
uses: actions/cache@v4
3131
with:
32-
key: v2-build-cache-${{ inputs.job_name }}.${{ inputs.setup_toolchain_extra }}.${{ inputs.configure_extra }}-${{ runner.arch }}-${{ github.ref_name }}-${{ github.sha }}
32+
key: v3-build-cache-${{ inputs.job_name }}.${{ inputs.setup_toolchain_extra }}.${{ inputs.configure_extra }}-${{ runner.arch }}-${{ github.ref_name }}-${{ github.sha }}
3333
path: build.tar.zstd
3434
restore-keys: |
35-
v2-build-cache-${{ inputs.job_name }}.${{ inputs.setup_toolchain_extra }}.${{ inputs.configure_extra }}-${{ runner.arch }}-${{ github.ref_name }}-
36-
v2-build-cache-${{ inputs.job_name }}.${{ inputs.setup_toolchain_extra }}.${{ inputs.configure_extra }}-${{ runner.arch }}-${{ github.base_ref }}-
35+
v3-build-cache-${{ inputs.job_name }}.${{ inputs.setup_toolchain_extra }}.${{ inputs.configure_extra }}-${{ runner.arch }}-${{ github.ref_name }}-
36+
v3-build-cache-${{ inputs.job_name }}.${{ inputs.setup_toolchain_extra }}.${{ inputs.configure_extra }}-${{ runner.arch }}-${{ github.base_ref }}-
3737
# Would be nice to use the cache action output, but we want to unpack even on
3838
# restore_keys hit.
3939
- name: Unpack build cache

Makefile.am

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ DISABLED_WARNINGS_HARD = \
1818
-Wno-unknown-warning-option
1919

2020
# TODO: Minimize this list.
21+
# TODO(T233149341): Narrow -Wno-volatile to problematic early verisons of
22+
# jsoncpp < 1.9.5 (https://github.com/open-source-parsers/jsoncpp/issues/1193).
23+
# This is currently only a problem on Debian 11.
2124
DISABLED_WARNINGS = \
2225
$(DISABLED_WARNINGS_HARD) \
2326
-Wno-array-bounds \
@@ -46,9 +49,10 @@ DISABLED_WARNINGS = \
4649
-Wno-unused-private-field \
4750
-Wno-unused-result \
4851
-Wno-unused-value \
49-
-Wno-unused-variable
52+
-Wno-unused-variable \
53+
-Wno-volatile
5054

51-
AM_CXXFLAGS = --std=gnu++17 -O3 -Wall -Werror -Wextra $(DISABLED_WARNINGS) -g1
55+
AM_CXXFLAGS = --std=gnu++20 -O3 -Wall -Werror -Wextra $(DISABLED_WARNINGS) -g1
5256

5357
include $(top_srcdir)/Makefile.inc
5458

cmake_modules/Commons.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ function(print_dirs var name)
1010
endfunction()
1111

1212
macro(set_common_cxx_flags_for_redex)
13-
message(STATUS "Using C++17")
14-
set(CMAKE_CXX_STANDARD 17)
13+
message(STATUS "Using C++20")
14+
set(CMAKE_CXX_STANDARD 20)
1515
set(CMAKE_CXX_STANDARD_REQUIRED ON)
1616
set(CMAKE_CXX_EXTENSIONS OFF)
1717
if (MSVC)

configure.ac

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ AM_INIT_AUTOMAKE([subdir-objects])
77
# clear out default cxx flags (was "-O2 -g") so that they don't override
88
# the flags defined in AM_CXXFLAGS. add "-std" to work around gtest issue
99
# on macos.
10-
: ${CXXFLAGS="-std=gnu++17"}
10+
: ${CXXFLAGS="-std=gnu++20"}
1111

1212
# Checks for programs.
1313
AC_PROG_CXX
@@ -97,7 +97,7 @@ AS_IF([test "x$enable_protobuf" = "xyes"], [
9797
CXXFLAGS_ORIG=$CXXFLAGS
9898
9999
# test protobuf header
100-
CXXFLAGS="-std=gnu++17 ${CXXFLAGS_ORIG} -I${withval}"
100+
CXXFLAGS="-std=gnu++20 ${CXXFLAGS_ORIG} -I${withval}"
101101
AC_LANG_PUSH([C++])
102102
AC_CHECK_HEADER([google/protobuf/io/coded_stream.h], [
103103
# library found

setup_oss_toolchain.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,13 @@ function install_googletest_from_source {
6666
mkdir -p toolchain_install/gtest
6767
pushd toolchain_install/gtest
6868
tar xf "../../dl_cache/gtest/googletest-${GOOGLETEST_MIN_VERSION}.tar.gz" --no-same-owner --strip-components=1
69-
# GoogleTest's string_view matcher requires compiler to support C++17. Older
70-
# GCC versions need to be told to use C++17 with -std=gnu++17.
69+
# GoogleTest's string_view matcher requires compiler to support C++17 or
70+
# later. Older GCC versions need to be explicitly told to use a later C++
71+
# standard.
7172
if [ "$BITNESS" = "32" ] ; then
72-
CFLAGS=-m32 CXXFLAGS="-m32 -std=gnu++17" LDFLAGS=-m32 cmake .
73+
CFLAGS=-m32 CXXFLAGS="-m32 -std=gnu++20" LDFLAGS=-m32 cmake .
7374
else
74-
CXXFLAGS="-std=gnu++17" cmake .
75+
CXXFLAGS="-std=gnu++20" cmake .
7576
fi
7677
cmake --build . --target install
7778
popd

test/integ/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ DX = @DX@
66
ANDROID_SDK = @ANDROID_SDK@
77
ANDROID_PLATFORM_VERSION = @ANDROID_PLATFORM_VERSION@
88

9-
AM_CXXFLAGS = --std=gnu++17
9+
AM_CXXFLAGS = --std=gnu++20
1010
AM_CPPFLAGS = $(COMMON_INCLUDES) $(COMMON_TEST_INCLUDES)
1111

1212
# Boost.

test/unit/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ include $(top_srcdir)/test/Makefile.inc
44
ANDROID_SDK = @ANDROID_SDK@
55
ANDROID_PLATFORM_VERSION = @ANDROID_PLATFORM_VERSION@
66

7-
AM_CXXFLAGS = --std=gnu++17
7+
AM_CXXFLAGS = --std=gnu++20
88
AM_CPPFLAGS = $(COMMON_INCLUDES) $(COMMON_TEST_INCLUDES)
99

1010
# Boost.

0 commit comments

Comments
 (0)