Skip to content

Commit 0ce78c6

Browse files
Merge pull request #12743 from protocolbuffers/gcc-23
Backport GCC tests+fixes
2 parents 21b02b2 + ae7ec4e commit 0ce78c6

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

.github/workflows/test_cpp.yml

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,15 @@ jobs:
114114
fail-fast: false # Don't cancel all jobs if one fails.
115115
matrix:
116116
include:
117-
- flags: -Dprotobuf_BUILD_EXAMPLES=ON
117+
- flags: -Dprotobuf_BUILD_EXAMPLES=ON -DCMAKE_CXX_STANDARD=14
118118
- name: Ninja
119-
flags: -G Ninja
119+
flags: -G Ninja -DCMAKE_CXX_STANDARD=14
120120
- name: Shared
121-
flags: -Dprotobuf_BUILD_SHARED_LIBS=ON -Dprotobuf_BUILD_EXAMPLES=ON
121+
flags: -Dprotobuf_BUILD_SHARED_LIBS=ON -Dprotobuf_BUILD_EXAMPLES=ON -DCMAKE_CXX_STANDARD=14
122+
- name: C++17
123+
flags: -DCMAKE_CXX_STANDARD=17
124+
- name: C++20
125+
flags: -DCMAKE_CXX_STANDARD=20
122126

123127
name: Linux CMake ${{ matrix.name}}
124128
runs-on: ubuntu-latest
@@ -202,7 +206,18 @@ jobs:
202206
cmake --build .
203207
204208
linux-cmake-gcc:
205-
name: Linux CMake GCC
209+
strategy:
210+
fail-fast: false # Don't cancel all jobs if one fails.
211+
matrix:
212+
include:
213+
- name: C++14
214+
flags: -DCMAKE_CXX_STANDARD=14
215+
- name: C++17
216+
flags: -DCMAKE_CXX_STANDARD=17
217+
- name: C++20
218+
flags: -DCMAKE_CXX_STANDARD=20
219+
220+
name: Linux CMake GCC ${{ matrix.name }}
206221
runs-on: ubuntu-latest
207222
steps:
208223
- name: Checkout pending changes
@@ -214,7 +229,7 @@ jobs:
214229
- name: Setup ccache
215230
uses: protocolbuffers/protobuf-ci/ccache@v1
216231
with:
217-
cache-prefix: linux-cmake-gcc
232+
cache-prefix: linux-cmake-gcc-${{ matrix.name }}
218233

219234
- name: Run tests
220235
uses: protocolbuffers/protobuf-ci/docker@v1
@@ -226,7 +241,7 @@ jobs:
226241
-c 'set -ex;
227242
cd /workspace;
228243
ccache -z;
229-
cmake . -DCMAKE_CXX_STANDARD=14 ${{ env.CCACHE_CMAKE_FLAGS }};
244+
cmake . ${{ matrix.flags }} ${{ env.CCACHE_CMAKE_FLAGS }};
230245
cmake --build . --parallel 20;
231246
ctest --verbose --parallel 20;
232247
ccache -s'

src/google/protobuf/port_def.inc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,12 @@ static_assert(PROTOBUF_CPLUSPLUS_MIN(201402L), "Protobuf only supports C++14 and
679679
# define PROTOBUF_CONSTINIT
680680
# define PROTOBUF_CONSTEXPR constexpr
681681
# endif
682+
#elif defined(__GNUC__) && !defined(__clang__)
683+
// GCC doesn't support constinit aggregate initialization of absl::Cord.
684+
# if PROTOBUF_GNUC_MIN(12, 2)
685+
# define PROTOBUF_CONSTINIT
686+
# define PROTOBUF_CONSTEXPR constexpr
687+
# endif
682688
#else
683689
# if defined(__cpp_constinit) && !defined(__CYGWIN__)
684690
# define PROTOBUF_CONSTINIT constinit
@@ -693,9 +699,6 @@ static_assert(PROTOBUF_CPLUSPLUS_MIN(201402L), "Protobuf only supports C++14 and
693699
(!defined(__APPLE__) && PROTOBUF_CLANG_MIN(12, 0)))
694700
# define PROTOBUF_CONSTINIT [[clang::require_constant_initialization]]
695701
# define PROTOBUF_CONSTEXPR constexpr
696-
# elif PROTOBUF_GNUC_MIN(12, 2)
697-
# define PROTOBUF_CONSTINIT __constinit
698-
# define PROTOBUF_CONSTEXPR constexpr
699702
# endif
700703
#endif
701704

0 commit comments

Comments
 (0)