From 53f01cc350be38229ab6154b300380a79b107b99 Mon Sep 17 00:00:00 2001 From: Mike Kruskal Date: Mon, 15 May 2023 14:54:11 -0700 Subject: [PATCH 1/2] Add a check for minimum supported Abseil version. PiperOrigin-RevId: 532235063 --- src/google/protobuf/port_def.inc | 15 +++++++++++++++ src/google/protobuf/port_undef.inc | 1 + 2 files changed, 16 insertions(+) diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc index fcbbe78129..87dc3fba6a 100644 --- a/src/google/protobuf/port_def.inc +++ b/src/google/protobuf/port_def.inc @@ -199,6 +199,21 @@ static_assert(PROTOBUF_MSC_VER_MIN(1910), "Protobuf only supports MSVC 2017 and #endif static_assert(PROTOBUF_CPLUSPLUS_MIN(201402L), "Protobuf only supports C++14 and newer."); +// Check minimum Abseil version. +#if defined(ABSL_LTS_RELEASE_VERSION) && defined(ABSL_LTS_RELEASE_PATCH_LEVEL) +#define PROTOBUF_ABSL_MIN(x, y) \ + (ABSL_LTS_RELEASE_VERSION > (x) || \ + (ABSL_LTS_RELEASE_VERSION == (x) && ABSL_LTS_RELEASE_PATCH_LEVEL >= (y))) +#else +// If we can't find an Abseil version, it's either not installed at all (which +// should trigger cmake errors), using a non-LTS release, or just isn't used in +// this file. +#define PROTOBUF_ABSL_MIN(x, y) 1 +#endif + +static_assert(PROTOBUF_ABSL_MIN(20230125, 3), + "Protobuf only supports Abseil version 20230125.3 and newer."); + // Future versions of protobuf will include breaking changes to some APIs. // This macro can be set to enable these API changes ahead of time, so that // user code can be updated before upgrading versions of protobuf. diff --git a/src/google/protobuf/port_undef.inc b/src/google/protobuf/port_undef.inc index a0a5f648df..041f3fc124 100644 --- a/src/google/protobuf/port_undef.inc +++ b/src/google/protobuf/port_undef.inc @@ -46,6 +46,7 @@ #undef PROTOBUF_CLANG_MIN #undef PROTOBUF_MSC_VER_MIN #undef PROTOBUF_CPLUSPLUS_MIN +#undef PROTOBUF_ABSL_MIN #undef PROTOBUF_NAMESPACE #undef PROTOBUF_NAMESPACE_ID #undef PROTOBUF_ALWAYS_INLINE From c329e4525396ac225f767a6720f576e6f6ccf34b Mon Sep 17 00:00:00 2001 From: Mike Kruskal Date: Mon, 15 May 2023 16:41:54 -0700 Subject: [PATCH 2/2] Add a workaround for GCC constexpr bug This turns the constexpr constructors into templates to silence errors when constexpr isn't valid. We are also switching to 12.2 for GCC/cmake tests to prevent regressions (9.5 and 13.1 are already tested by GCC/bazel tests). Fixes #12807 PiperOrigin-RevId: 532258101 --- .github/workflows/test_cpp.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_cpp.yml b/.github/workflows/test_cpp.yml index 0a34cdc638..0b2ca12611 100644 --- a/.github/workflows/test_cpp.yml +++ b/.github/workflows/test_cpp.yml @@ -235,7 +235,7 @@ jobs: - 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 + image: us-docker.pkg.dev/protobuf-build/containers/test/linux/gcc:12.2-5.4.0-307caa02808127e49720f3e77d6a9f3b3ef5a915 credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} entrypoint: bash command: >-