Skip to content

Commit d5a1b09

Browse files
Merge pull request #12695 from protocolbuffers/cpp-fixes-23
Backport increased C++ test coverage + fixes
2 parents 3dc68d2 + bc9a1d2 commit d5a1b09

File tree

5 files changed

+72
-12
lines changed

5 files changed

+72
-12
lines changed

.github/workflows/test_cpp.yml

Lines changed: 58 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,26 @@ jobs:
5151
bazel-cache: cpp_linux/${{ matrix.config.name }}
5252
bazel: test ${{ matrix.targets }} ${{ matrix.config.flags }}
5353

54+
linux-gcc:
55+
strategy:
56+
fail-fast: false # Don't cancel all jobs if one fails.
57+
matrix:
58+
version: ['9.5', '13.1']
59+
name: Linux GCC ${{ matrix.version }}
60+
runs-on: ubuntu-latest
61+
steps:
62+
- name: Checkout pending changes
63+
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
64+
with:
65+
ref: ${{ inputs.safe-checkout }}
66+
- name: Run tests
67+
uses: protocolbuffers/protobuf-ci/bazel-docker@v1
68+
with:
69+
image: us-docker.pkg.dev/protobuf-build/containers/test/linux/gcc:${{ matrix.version }}-5.4.0-2d15d9e888c9e7f90961dbd3afc8ea209717fb4b
70+
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
71+
bazel-cache: cpp_linux/gcc-${{ matrix.version }}
72+
bazel: test //pkg/... //src/... @com_google_protobuf_examples//...
73+
5474
linux-release:
5575
strategy:
5676
fail-fast: false # Don't cancel all jobs if one fails.
@@ -116,13 +136,12 @@ jobs:
116136
- name: Run tests
117137
uses: protocolbuffers/protobuf-ci/docker@v1
118138
with:
119-
image: us-docker.pkg.dev/protobuf-build/containers/test/linux/cmake@sha256:7058879cac0224e443043eae2de82c13a63a54dd31855dac020c5522aa573cd2
139+
image: us-docker.pkg.dev/protobuf-build/containers/test/linux/cmake:3.10.3-1da1e086a7d1863b8bdd181ef6388a02dcd62f3a
120140
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
121141
command: >-
122142
/test.sh ${{ matrix.flags}} ${{ env.CCACHE_CMAKE_FLAGS }}
123143
-DCMAKE_CXX_STANDARD=14 -Dprotobuf_BUILD_TESTS=ON
124144
-Dprotobuf_USE_EXTERNAL_GTEST=ON -Dprotobuf_ABSL_PROVIDER=package
125-
126145
127146
linux-cmake-install:
128147
name: Linux CMake Install
@@ -142,7 +161,7 @@ jobs:
142161
- name: Run tests
143162
uses: protocolbuffers/protobuf-ci/docker@v1
144163
with:
145-
image: us-docker.pkg.dev/protobuf-build/containers/test/linux/cmake@sha256:7058879cac0224e443043eae2de82c13a63a54dd31855dac020c5522aa573cd2
164+
image: us-docker.pkg.dev/protobuf-build/containers/test/linux/cmake:3.10.3-1da1e086a7d1863b8bdd181ef6388a02dcd62f3a
146165
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
147166
command: >-
148167
/install.sh -DCMAKE_CXX_STANDARD=14 ${{ env.CCACHE_CMAKE_FLAGS }} -Dprotobuf_USE_EXTERNAL_GTEST=ON -Dprotobuf_ABSL_PROVIDER=package \&\&
@@ -171,16 +190,46 @@ jobs:
171190
- name: Run tests
172191
uses: protocolbuffers/protobuf-ci/docker@v1
173192
with:
174-
image: us-docker.pkg.dev/protobuf-build/containers/test/linux/cmake@sha256:7058879cac0224e443043eae2de82c13a63a54dd31855dac020c5522aa573cd2
193+
image: us-docker.pkg.dev/protobuf-build/containers/test/linux/cmake:3.10.3-1da1e086a7d1863b8bdd181ef6388a02dcd62f3a
175194
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
176195
command: >-
177196
/install.sh -DCMAKE_CXX_STANDARD=14 ${{ env.CCACHE_CMAKE_FLAGS }}
178197
-Dprotobuf_USE_EXTERNAL_GTEST=ON -Dprotobuf_ABSL_PROVIDER=package
179198
-Dprotobuf_BUILD_EXAMPLES=OFF \&\&
180-
cd examples \&\&
181-
mkdir build \&\&
182-
cmake -S . -B build -DCMAKE_CXX_STANDARD=14 \&\&
183-
cmake --build build
199+
mkdir examples/build \&\&
200+
cd examples/build \&\&
201+
cmake .. -DCMAKE_CXX_STANDARD=14 \&\&
202+
cmake --build .
203+
204+
linux-cmake-gcc:
205+
name: Linux CMake GCC
206+
runs-on: ubuntu-latest
207+
steps:
208+
- name: Checkout pending changes
209+
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
210+
with:
211+
ref: ${{ inputs.safe-checkout }}
212+
submodules: recursive
213+
214+
- name: Setup ccache
215+
uses: protocolbuffers/protobuf-ci/ccache@v1
216+
with:
217+
cache-prefix: linux-cmake-gcc
218+
219+
- name: Run tests
220+
uses: protocolbuffers/protobuf-ci/docker@v1
221+
with:
222+
image: us-docker.pkg.dev/protobuf-build/containers/test/linux/gcc:13.1-5.4.0-307caa02808127e49720f3e77d6a9f3b3ef5a915
223+
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
224+
entrypoint: bash
225+
command: >-
226+
-c 'set -ex;
227+
cd /workspace;
228+
ccache -z;
229+
cmake . -DCMAKE_CXX_STANDARD=14 ${{ env.CCACHE_CMAKE_FLAGS }};
230+
cmake --build . --parallel 20;
231+
ctest --verbose --parallel 20;
232+
ccache -s'
184233
185234
linux-cmake-submodules:
186235
name: Linux CMake Submodules
@@ -200,7 +249,7 @@ jobs:
200249
- name: Run tests
201250
uses: protocolbuffers/protobuf-ci/docker@v1
202251
with:
203-
image: us-docker.pkg.dev/protobuf-build/containers/test/linux/cmake@sha256:e0eb6c69b7551d89f0dbdbe11906077a1d501229c28db39623b945e0c5d7029a
252+
image: us-docker.pkg.dev/protobuf-build/containers/test/linux/cmake:3.13.3-1da1e086a7d1863b8bdd181ef6388a02dcd62f3a
204253
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
205254
command: >-
206255
/test.sh ${{ env.CCACHE_CMAKE_FLAGS }}

cmake/install.cmake

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@ foreach(_target IN LISTS protobuf_ABSL_USED_TARGETS)
66
endforeach()
77
list(APPEND _pc_targets "utf8_range")
88

9-
string(JOIN " " _pc_target_list ${_pc_targets})
10-
set(_protobuf_PC_REQUIRES ${_pc_target_list})
9+
set(_protobuf_PC_REQUIRES "")
10+
set(_sep "")
11+
foreach (_target IN LISTS _pc_target_list)
12+
string(CONCAT _protobuf_PC_REQUIRES "${_protobuf_PC_REQUIRES}" "${_sep}" "${_target}")
13+
set(_sep " ")
14+
endforeach ()
1115

1216
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/protobuf.pc.cmake
1317
${CMAKE_CURRENT_BINARY_DIR}/protobuf.pc @ONLY)

src/google/protobuf/io/printer_death_test.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ class FakeAnnotationCollector : public AnnotationCollector {
9090
public:
9191
~FakeAnnotationCollector() override = default;
9292

93+
using AnnotationCollector::AddAnnotation;
9394
void AddAnnotation(size_t begin_offset, size_t end_offset,
9495
const std::string& file_path,
9596
const std::vector<int>& path) override {

src/google/protobuf/port_def.inc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,6 +1013,12 @@ static_assert(PROTOBUF_CPLUSPLUS_MIN(201402L), "Protobuf only supports C++14 and
10131013
// This error has been generally flaky, but we need to disable it specifically
10141014
// to fix https://github.com/protocolbuffers/protobuf/issues/12313
10151015
#pragma GCC diagnostic ignored "-Wunused-parameter"
1016+
#ifndef __clang__
1017+
// This causes spurious warnings in GCC 13.
1018+
#pragma GCC diagnostic ignored "-Wstringop-overflow"
1019+
// This causes spurious warnings in GCC 13.
1020+
#pragma GCC diagnostic ignored "-Wself-move"
1021+
#endif
10161022
#if __GNUC__ == 12 && __GNUC_MINOR__ < 4
10171023
// Wrong warning emitted when assigning a single char c-string to a std::string
10181024
// in c++20 mode and optimization on.

src/google/protobuf/repeated_field.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,7 @@ PROTOBUF_NOINLINE void RepeatedField<Element>::GrowNoAnnotate(int current_size,
977977
Element* pold = elements();
978978
// TODO(b/263791665): add absl::is_trivially_relocatable<Element>
979979
if (std::is_trivial<Element>::value) {
980-
memcpy(pnew, pold, current_size * sizeof(Element));
980+
memcpy(static_cast<void*>(pnew), pold, current_size * sizeof(Element));
981981
} else {
982982
for (Element* end = pnew + current_size; pnew != end; ++pnew, ++pold) {
983983
::new (static_cast<void*>(pnew)) Element(std::move(*pold));

0 commit comments

Comments
 (0)