Skip to content

Commit 2950e99

Browse files
pdillingerfacebook-github-bot
authored andcommitted
Require C++20 (#13904)
Summary: I am wanting to use std::counting_semaphore for something and the timing seems good to require C++20 support. The internets suggest: * GCC >= 10 is adequate, >= 11 preferred * Clang >= 10 is needed * Visual Studio >= 2019 is adquate And popular linux distributions look like this: * CentOS Stream 9 -> GCC 11.2 (CentOS 8 is EOL) * Ubuntu 22.04 LTS -> GCC 11.x (Ubuntu 20 just ended standard support) * Debian 12 (oldstable) -> GCC 12.2 * (Debian 11 has ended security updates, uses GCC 10.2) This required generating a new docker image based on Ubuntu 22 for CI using gcc. The existing Ubuntu 20 image works for covering appropriate clang versions (though we should maybe add a much later version as well, in the next increment of our Ubuntu 22 image; however the minimum available clang build from apt.llvm.org for Ubuntu 22 is clang 13). Update to SetDumpFilter is to quiet a mysterious gcc-13 warning-as-error. Removed --compile-no-warning-as-error from a cmake command line because cmake in the new docker image is too old for this option. Pull Request resolved: #13904 Test Plan: CI, one minor unit test added to verify std::counting_semaphor works Reviewed By: xingbowang Differential Revision: D81266435 Pulled By: pdillinger fbshipit-source-id: 26040eeccca7004416e29a6ff4f6ea93f2052684
1 parent 68efd6f commit 2950e99

File tree

20 files changed

+158
-119
lines changed

20 files changed

+158
-119
lines changed

.github/workflows/nightly.yml

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on:
1111
labels: 16-core-ubuntu
1212
container:
13-
image: zjay437/rocksdb:0.6
13+
image: ghcr.io/facebook/rocksdb_ubuntu:22.0
1414
options: --shm-size=16gb
1515
steps:
1616
- uses: actions/[email protected]
@@ -32,7 +32,7 @@ jobs:
3232
runs-on:
3333
labels: 16-core-ubuntu
3434
container:
35-
image: zjay437/rocksdb:0.6
35+
image: ghcr.io/facebook/rocksdb_ubuntu:22.0
3636
options: --shm-size=16gb
3737
env:
3838
TEST_TMPDIR: "/tmp/rocksdb_test_tmp"
@@ -63,7 +63,7 @@ jobs:
6363
runs-on:
6464
labels: 16-core-ubuntu
6565
container:
66-
image: zjay437/rocksdb:0.6
66+
image: ghcr.io/facebook/rocksdb_ubuntu:22.0
6767
options: --shm-size=16gb
6868
steps:
6969
- uses: actions/[email protected]
@@ -94,7 +94,7 @@ jobs:
9494
runs-on:
9595
labels: 4-core-ubuntu
9696
container:
97-
image: zjay437/rocksdb:0.6
97+
image: ghcr.io/facebook/rocksdb_ubuntu:22.0
9898
options: --shm-size=16gb
9999
steps:
100100
- uses: actions/[email protected]
@@ -117,28 +117,13 @@ jobs:
117117
- name: Build fuzzers
118118
run: cd fuzz && make sst_file_writer_fuzzer db_fuzzer db_map_fuzzer
119119
- uses: "./.github/actions/post-steps"
120-
build-linux-gcc-11-no_test_run:
121-
if: ${{ github.repository_owner == 'facebook' }}
122-
runs-on:
123-
labels: 16-core-ubuntu
124-
container:
125-
image: zjay437/rocksdb:0.6
126-
options: --shm-size=16gb
127-
steps:
128-
- uses: actions/[email protected]
129-
- uses: "./.github/actions/pre-steps"
130-
- run: LIB_MODE=static CC=gcc-11 CXX=g++-11 V=1 make -j32 all microbench
131-
- uses: "./.github/actions/post-steps"
132120
build-linux-cmake-with-folly-lite-no-test:
133121
if: ${{ github.repository_owner == 'facebook' }}
134122
runs-on:
135123
labels: 16-core-ubuntu
136124
container:
137-
image: zjay437/rocksdb:0.6
125+
image: ghcr.io/facebook/rocksdb_ubuntu:22.0
138126
options: --shm-size=16gb
139-
env:
140-
CC: gcc-10
141-
CXX: g++-10
142127
steps:
143128
- uses: actions/[email protected]
144129
- uses: "./.github/actions/pre-steps"

.github/workflows/pr-jobs.yml

Lines changed: 26 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
runs-on:
6767
labels: 16-core-ubuntu
6868
container:
69-
image: zjay437/rocksdb:0.6
69+
image: ghcr.io/facebook/rocksdb_ubuntu:22.0
7070
options: --shm-size=16gb
7171
steps:
7272
- uses: actions/[email protected]
@@ -78,7 +78,7 @@ jobs:
7878
runs-on:
7979
labels: 4-core-ubuntu
8080
container:
81-
image: zjay437/rocksdb:0.6
81+
image: ghcr.io/facebook/rocksdb_ubuntu:22.0
8282
options: --shm-size=16gb
8383
steps:
8484
- uses: actions/[email protected]
@@ -97,11 +97,8 @@ jobs:
9797
runs-on:
9898
labels: 16-core-ubuntu
9999
container:
100-
image: zjay437/rocksdb:0.6
100+
image: ghcr.io/facebook/rocksdb_ubuntu:22.0
101101
options: --shm-size=16gb
102-
env:
103-
CC: gcc-10
104-
CXX: g++-10
105102
steps:
106103
- uses: actions/[email protected]
107104
- uses: "./.github/actions/pre-steps"
@@ -114,11 +111,8 @@ jobs:
114111
runs-on:
115112
labels: 16-core-ubuntu
116113
container:
117-
image: zjay437/rocksdb:0.6
114+
image: ghcr.io/facebook/rocksdb_ubuntu:22.0
118115
options: --shm-size=16gb
119-
env:
120-
CC: gcc-10
121-
CXX: g++-10
122116
steps:
123117
- uses: actions/[email protected]
124118
- uses: "./.github/actions/pre-steps"
@@ -131,11 +125,8 @@ jobs:
131125
runs-on:
132126
labels: 16-core-ubuntu
133127
container:
134-
image: zjay437/rocksdb:0.6
128+
image: ghcr.io/facebook/rocksdb_ubuntu:22.0
135129
options: --shm-size=16gb
136-
env:
137-
CC: gcc-10
138-
CXX: g++-10
139130
steps:
140131
- uses: actions/[email protected]
141132
- uses: "./.github/actions/pre-steps"
@@ -147,11 +138,8 @@ jobs:
147138
runs-on:
148139
labels: 16-core-ubuntu
149140
container:
150-
image: zjay437/rocksdb:0.6
141+
image: ghcr.io/facebook/rocksdb_ubuntu:22.0
151142
options: --shm-size=16gb
152-
env:
153-
CC: gcc-10
154-
CXX: g++-10
155143
steps:
156144
- uses: actions/[email protected]
157145
- uses: "./.github/actions/pre-steps"
@@ -164,7 +152,7 @@ jobs:
164152
runs-on:
165153
labels: 16-core-ubuntu
166154
container:
167-
image: zjay437/rocksdb:0.6
155+
image: ghcr.io/facebook/rocksdb_ubuntu:22.0
168156
options: --shm-size=16gb
169157
steps:
170158
- uses: actions/[email protected]
@@ -176,7 +164,7 @@ jobs:
176164
runs-on:
177165
labels: 16-core-ubuntu
178166
container:
179-
image: zjay437/rocksdb:0.6
167+
image: ghcr.io/facebook/rocksdb_ubuntu:22.0
180168
options: --shm-size=16gb
181169
steps:
182170
- uses: actions/[email protected]
@@ -190,7 +178,7 @@ jobs:
190178
runs-on:
191179
labels: 16-core-ubuntu
192180
container:
193-
image: zjay437/rocksdb:0.6
181+
image: ghcr.io/facebook/rocksdb_ubuntu:22.0
194182
options: --shm-size=16gb
195183
steps:
196184
- uses: actions/[email protected]
@@ -236,29 +224,17 @@ jobs:
236224
- run: make clean
237225
- run: CC=clang-13 CXX=clang++-13 USE_CLANG=1 DEBUG_LEVEL=0 make -j32 release
238226
- uses: "./.github/actions/post-steps"
239-
build-linux-gcc-8-no_test_run:
227+
build-linux-gcc-13-no_test_run:
240228
if: ${{ github.repository_owner == 'facebook' }}
241229
runs-on:
242230
labels: 16-core-ubuntu
243231
container:
244-
image: zjay437/rocksdb:0.6
232+
image: ghcr.io/facebook/rocksdb_ubuntu:22.0
245233
options: --shm-size=16gb
246234
steps:
247235
- uses: actions/[email protected]
248236
- uses: "./.github/actions/pre-steps"
249-
- run: CC=gcc-8 CXX=g++-8 V=1 make -j32 all
250-
- uses: "./.github/actions/post-steps"
251-
build-linux-gcc-10-cxx20-no_test_run:
252-
if: ${{ github.repository_owner == 'facebook' }}
253-
runs-on:
254-
labels: 16-core-ubuntu
255-
container:
256-
image: zjay437/rocksdb:0.6
257-
options: --shm-size=16gb
258-
steps:
259-
- uses: actions/[email protected]
260-
- uses: "./.github/actions/pre-steps"
261-
- run: CC=gcc-10 CXX=g++-10 V=1 ROCKSDB_CXX_STANDARD=c++20 make -j32 all
237+
- run: CC=gcc-13 CXX=g++-13 V=1 make -j32 all microbench
262238
- uses: "./.github/actions/post-steps"
263239

264240
# ======================== Linux Other Checks ======================= #
@@ -300,7 +276,7 @@ jobs:
300276
runs-on:
301277
labels: 4-core-ubuntu
302278
container:
303-
image: zjay437/rocksdb:0.6
279+
image: ghcr.io/facebook/rocksdb_ubuntu:22.0
304280
options: --shm-size=16gb
305281
steps:
306282
- uses: actions/[email protected]
@@ -337,7 +313,7 @@ jobs:
337313
runs-on:
338314
labels: 16-core-ubuntu
339315
container:
340-
image: zjay437/rocksdb:0.6
316+
image: ghcr.io/facebook/rocksdb_ubuntu:22.0
341317
options: --shm-size=16gb
342318
steps:
343319
- uses: actions/[email protected]
@@ -404,11 +380,13 @@ jobs:
404380
runs-on:
405381
labels: 4-core-ubuntu
406382
container:
407-
image: evolvedbinary/rocksjava:centos7_x64-be
383+
image: ghcr.io/facebook/rocksdb_ubuntu:22.0
408384
options: --shm-size=16gb
409385
steps:
410386
# The docker image is intentionally based on an OS that has an older GLIBC version.
411387
# That GLIBC is incompatibile with GitHub's actions/checkout. Thus we implement a manual checkout step.
388+
# NOTE: replaced evolvedbinary/rocksjava:centos7_x64-be with ghcr.io/facebook/rocksdb_ubuntu:22.0
389+
# until a more appropriate docker image with C++20 support is made.
412390
- name: Checkout
413391
env:
414392
GH_TOKEN: ${{ github.token }}
@@ -425,18 +403,21 @@ jobs:
425403
which java && java -version
426404
which javac && javac -version
427405
- name: Test RocksDBJava
428-
run: scl enable devtoolset-7 'make V=1 J=8 -j8 jtest'
429-
# NOTE: post-steps skipped because of compatibility issues with docker image
406+
# NOTE: replaced scl enable devtoolset-7 'make V=1 J=8 -j8 jtest'
407+
run: make V=1 J=8 -j8 jtest
408+
# post-steps skipped because of compatibility issues with docker image
430409
build-linux-java-static:
431410
if: ${{ github.repository_owner == 'facebook' }}
432411
runs-on:
433412
labels: 4-core-ubuntu
434413
container:
435-
image: evolvedbinary/rocksjava:centos7_x64-be
414+
image: ghcr.io/facebook/rocksdb_ubuntu:22.0
436415
options: --shm-size=16gb
437416
steps:
438417
# The docker image is intentionally based on an OS that has an older GLIBC version.
439418
# That GLIBC is incompatibile with GitHub's actions/checkout. Thus we implement a manual checkout step.
419+
# NOTE: replaced evolvedbinary/rocksjava:centos7_x64-be with ghcr.io/facebook/rocksdb_ubuntu:22.0
420+
# until a more appropriate docker image with C++20 support is made.
440421
- name: Checkout
441422
env:
442423
GH_TOKEN: ${{ github.token }}
@@ -453,8 +434,9 @@ jobs:
453434
which java && java -version
454435
which javac && javac -version
455436
- name: Build RocksDBJava Static Library
456-
run: scl enable devtoolset-7 'make V=1 J=8 -j8 rocksdbjavastatic'
457-
# NOTE: post-steps skipped because of compatibility issues with docker image
437+
# NOTE: replaced scl enable devtoolset-7 'make V=1 J=8 -j8 rocksdbjavastatic'
438+
run: make V=1 J=8 -j8 rocksdbjavastatic
439+
# post-steps skipped because of compatibility issues with docker image
458440
build-macos-java:
459441
if: ${{ github.repository_owner == 'facebook' }}
460442
runs-on: macos-13

CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#
2828
# Linux:
2929
#
30-
# 1. Install a recent toolchain if you're on a older distro. C++17 required (GCC >= 7, Clang >= 5)
30+
# 1. Install a recent toolchain if you're on a older distro. C++20 required (GCC >= 11, Clang >= 10)
3131
# 2. mkdir build; cd build
3232
# 3. cmake ..
3333
# 4. make -j
@@ -100,7 +100,7 @@ endif()
100100
option(ROCKSDB_BUILD_SHARED "Build shared versions of the RocksDB libraries" ON)
101101

102102
if( NOT DEFINED CMAKE_CXX_STANDARD )
103-
set(CMAKE_CXX_STANDARD 17)
103+
set(CMAKE_CXX_STANDARD 20)
104104
endif()
105105

106106
include(CMakeDependentOption)
@@ -314,7 +314,6 @@ endif()
314314

315315
# Check if -latomic is required or not
316316
if (NOT MSVC)
317-
set(CMAKE_REQUIRED_FLAGS "--std=c++17")
318317
CHECK_CXX_SOURCE_COMPILES("
319318
#include <atomic>
320319
std::atomic<uint64_t> x(0);

INSTALL.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ than release mode.
66

77
RocksDB's library should be able to compile without any dependency installed,
88
although we recommend installing some compression libraries (see below).
9-
We do depend on newer gcc/clang with C++17 support (GCC >= 7, Clang >= 5).
9+
We do depend on newer gcc/clang with C++20 support (GCC >= 11, Clang >= 10).
1010

1111
There are few options when compiling RocksDB:
1212

@@ -60,7 +60,7 @@ most processors made since roughly 2013.
6060
## Supported platforms
6161

6262
* **Linux - Ubuntu**
63-
* Upgrade your gcc to version at least 7 to get C++17 support.
63+
* Upgrade your gcc to version at least 11 to get C++20 support.
6464
* Install gflags. First, try: `sudo apt-get install libgflags-dev`
6565
If this doesn't work and you're using Ubuntu, here's a nice tutorial:
6666
(http://askubuntu.com/questions/312173/installing-gflags-12-04)
@@ -72,7 +72,7 @@ most processors made since roughly 2013.
7272
* Install zstandard: `sudo apt-get install libzstd-dev`.
7373

7474
* **Linux - CentOS / RHEL**
75-
* Upgrade your gcc to version at least 7 to get C++17 support
75+
* Upgrade your gcc to version at least 11 to get C++20 support
7676
* Install gflags:
7777

7878
git clone https://github.com/gflags/gflags.git
@@ -122,7 +122,7 @@ most processors made since roughly 2013.
122122
make && sudo make install
123123

124124
* **OS X**:
125-
* Install latest C++ compiler that supports C++ 17:
125+
* Install latest C++ compiler that supports C++20:
126126
* Update XCode: run `xcode-select --install` (or install it from XCode App's settting).
127127
* Install via [homebrew](http://brew.sh/).
128128
* If you're first time developer in MacOS, you still need to run: `xcode-select --install` in your command line.
@@ -213,7 +213,7 @@ most processors made since roughly 2013.
213213
export PATH=/opt/freeware/bin:$PATH
214214

215215
* **Solaris Sparc**
216-
* Install GCC 7 and higher.
216+
* Install GCC 11 and higher.
217217
* Use these environment variables:
218218

219219
export CC=gcc

Makefile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,8 @@ ifeq ($(USE_COROUTINES), 1)
148148
USE_FOLLY = 1
149149
# glog/logging.h requires HAVE_CXX11_ATOMIC
150150
OPT += -DUSE_COROUTINES -DHAVE_CXX11_ATOMIC
151-
ROCKSDB_CXX_STANDARD = c++2a
152151
USE_RTTI = 1
153152
ifneq ($(USE_CLANG), 1)
154-
ROCKSDB_CXX_STANDARD = c++20
155153
PLATFORM_CXXFLAGS += -fcoroutines
156154
endif
157155
endif
@@ -683,7 +681,7 @@ am__v_CCH_1 =
683681
# user build settings
684682
%.h.pub: %.h # .h.pub not actually created, so re-checked on each invocation
685683
$(AM_V_CCH) cd include/ && echo '#include "$(patsubst include/%,%,$<)"' | \
686-
$(CXX) -I. -DROCKSDB_NAMESPACE=42 -x c++ -c - -o /dev/null
684+
$(CXX) -std=$(or $(ROCKSDB_CXX_STANDARD),c++20) -I. -DROCKSDB_NAMESPACE=42 -x c++ -c - -o /dev/null
687685

688686
check-headers: $(HEADER_OK_FILES)
689687

@@ -2251,7 +2249,7 @@ libsnappy.a: snappy-$(SNAPPY_VER).tar.gz
22512249
-rm -rf snappy-$(SNAPPY_VER)
22522250
tar xvzf snappy-$(SNAPPY_VER).tar.gz
22532251
mkdir snappy-$(SNAPPY_VER)/build
2254-
cd snappy-$(SNAPPY_VER)/build && CFLAGS='$(ARCHFLAG) ${JAVA_STATIC_DEPS_CCFLAGS} ${EXTRA_CFLAGS}' CXXFLAGS='$(ARCHFLAG) ${JAVA_STATIC_DEPS_CXXFLAGS} ${EXTRA_CXXFLAGS}' LDFLAGS='${JAVA_STATIC_DEPS_LDFLAGS} ${EXTRA_LDFLAGS}' cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DSNAPPY_BUILD_BENCHMARKS=OFF -DSNAPPY_BUILD_TESTS=OFF --compile-no-warning-as-error ${PLATFORM_CMAKE_FLAGS} .. && $(MAKE) ${SNAPPY_MAKE_TARGET}
2252+
cd snappy-$(SNAPPY_VER)/build && CFLAGS='$(ARCHFLAG) ${JAVA_STATIC_DEPS_CCFLAGS} ${EXTRA_CFLAGS}' CXXFLAGS='$(ARCHFLAG) ${JAVA_STATIC_DEPS_CXXFLAGS} ${EXTRA_CXXFLAGS}' LDFLAGS='${JAVA_STATIC_DEPS_LDFLAGS} ${EXTRA_LDFLAGS}' cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DSNAPPY_BUILD_BENCHMARKS=OFF -DSNAPPY_BUILD_TESTS=OFF ${PLATFORM_CMAKE_FLAGS} .. && $(MAKE) ${SNAPPY_MAKE_TARGET}
22552253
cp snappy-$(SNAPPY_VER)/build/libsnappy.a .
22562254

22572255
lz4-$(LZ4_VER).tar.gz:

build_tools/build_detect_platform

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ if test -z "$OUTPUT"; then
4545
exit 1
4646
fi
4747

48-
# we depend on C++17, but should be compatible with newer standards
48+
# we depend on C++20, but should be compatible with newer standards
4949
if [ "$ROCKSDB_CXX_STANDARD" ]; then
5050
PLATFORM_CXXFLAGS="-std=$ROCKSDB_CXX_STANDARD"
5151
else
52-
PLATFORM_CXXFLAGS="-std=c++17"
52+
PLATFORM_CXXFLAGS="-std=c++20"
5353
fi
5454

5555
# we currently depend on POSIX platform

0 commit comments

Comments
 (0)