Skip to content

Commit

Permalink
Add tests for GCC support window.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mkruskal-google authored and copybara-github committed May 6, 2023
1 parent 0d3b0c6 commit da2c4a6
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 2 deletions.
51 changes: 50 additions & 1 deletion .github/workflows/test_cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,26 @@ jobs:
bazel-cache: cpp_linux/${{ matrix.config.name }}
bazel: test ${{ matrix.targets }} ${{ matrix.config.flags }}

linux-gcc:
strategy:
fail-fast: false # Don't cancel all jobs if one fails.
matrix:
version: ['9.5', '13.1']
name: Linux GCC ${{ matrix.version }}
runs-on: ubuntu-latest
steps:
- name: Checkout pending changes
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
ref: ${{ inputs.safe-checkout }}
- name: Run tests
uses: protocolbuffers/protobuf-ci/bazel-docker@v1
with:
image: us-docker.pkg.dev/protobuf-build/containers/test/linux/gcc:${{ matrix.version }}-5.4.0-2d15d9e888c9e7f90961dbd3afc8ea209717fb4b
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
bazel-cache: cpp_linux/gcc-${{ matrix.version }}
bazel: test //pkg/... //src/... @com_google_protobuf_examples//...

linux-release:
strategy:
fail-fast: false # Don't cancel all jobs if one fails.
Expand Down Expand Up @@ -122,7 +142,6 @@ jobs:
/test.sh ${{ matrix.flags}} ${{ env.CCACHE_CMAKE_FLAGS }}
-DCMAKE_CXX_STANDARD=14 -Dprotobuf_BUILD_TESTS=ON
-Dprotobuf_USE_EXTERNAL_GTEST=ON -Dprotobuf_ABSL_PROVIDER=package
linux-cmake-install:
name: Linux CMake Install
Expand Down Expand Up @@ -182,6 +201,36 @@ jobs:
cmake .. -DCMAKE_CXX_STANDARD=14 \&\&
cmake --build .
linux-cmake-gcc:
name: Linux CMake GCC
runs-on: ubuntu-latest
steps:
- name: Checkout pending changes
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
ref: ${{ inputs.safe-checkout }}
submodules: recursive

- name: Setup ccache
uses: protocolbuffers/protobuf-ci/ccache@v1
with:
cache-prefix: linux-cmake-gcc

- name: Run tests
uses: protocolbuffers/protobuf-ci/docker@v1
with:
image: us-docker.pkg.dev/protobuf-build/containers/test/linux/gcc:13.1-5.4.0-307caa02808127e49720f3e77d6a9f3b3ef5a915
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
entrypoint: bash
command: >-
-c 'set -ex;
cd /workspace;
ccache -z;
cmake . -DCMAKE_CXX_STANDARD=14 ${{ env.CCACHE_CMAKE_FLAGS }};
cmake --build . --parallel 20;
ctest --verbose --parallel 20;
ccache -s'
linux-cmake-submodules:
name: Linux CMake Submodules
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions src/google/protobuf/io/printer_death_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class FakeAnnotationCollector : public AnnotationCollector {
public:
~FakeAnnotationCollector() override = default;

using AnnotationCollector::AddAnnotation;
void AddAnnotation(size_t begin_offset, size_t end_offset,
const std::string& file_path,
const std::vector<int>& path) override {
Expand Down
6 changes: 6 additions & 0 deletions src/google/protobuf/port_def.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1013,6 +1013,12 @@ static_assert(PROTOBUF_CPLUSPLUS_MIN(201402L), "Protobuf only supports C++14 and
// This error has been generally flaky, but we need to disable it specifically
// to fix https://github.com/protocolbuffers/protobuf/issues/12313
#pragma GCC diagnostic ignored "-Wunused-parameter"
#ifndef __clang__
// This causes spurious warnings in GCC 13.
#pragma GCC diagnostic ignored "-Wstringop-overflow"
// This causes spurious warnings in GCC 13.
#pragma GCC diagnostic ignored "-Wself-move"
#endif
#if __GNUC__ == 12 && __GNUC_MINOR__ < 4
// Wrong warning emitted when assigning a single char c-string to a std::string
// in c++20 mode and optimization on.
Expand Down
2 changes: 1 addition & 1 deletion src/google/protobuf/repeated_field.h
Original file line number Diff line number Diff line change
Expand Up @@ -988,7 +988,7 @@ PROTOBUF_NOINLINE void RepeatedField<Element>::GrowNoAnnotate(int current_size,
Element* pold = elements();
// TODO(b/263791665): add absl::is_trivially_relocatable<Element>
if (std::is_trivial<Element>::value) {
memcpy(pnew, pold, current_size * sizeof(Element));
memcpy(static_cast<void*>(pnew), pold, current_size * sizeof(Element));
} else {
for (Element* end = pnew + current_size; pnew != end; ++pnew, ++pold) {
::new (static_cast<void*>(pnew)) Element(std::move(*pold));
Expand Down

0 comments on commit da2c4a6

Please sign in to comment.