Skip to content

Commit bc9a1d2

Browse files
Add tests for GCC support window.
Note: gcc only supports docker images down to 9.5, and the 7.3 image is very old and problematic. A follow-up change might enable testing for GCC 7.3, which is our minimal supported version PiperOrigin-RevId: 529885733
1 parent 54caf40 commit bc9a1d2

File tree

4 files changed

+58
-2
lines changed

4 files changed

+58
-2
lines changed

.github/workflows/test_cpp.yml

Lines changed: 50 additions & 1 deletion
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.
@@ -122,7 +142,6 @@ jobs:
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
@@ -182,6 +201,36 @@ jobs:
182201
cmake .. -DCMAKE_CXX_STANDARD=14 \&\&
183202
cmake --build .
184203
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'
233+
185234
linux-cmake-submodules:
186235
name: Linux CMake Submodules
187236
runs-on: ubuntu-latest

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)