From 064438830bff4d87bb7fcfdaa53aa2598168e524 Mon Sep 17 00:00:00 2001 From: Bill Stoffel Date: Fri, 31 Jan 2025 12:31:00 -0800 Subject: [PATCH] Fix missing port_undef (#20052) unparser.cc, arenaz_sampler_test.cc, and message_module.cc included port_def.inc but forgot to include the undef file. This can cause some issues on which absl macros are defined: In file included from /opt/protobuf-29/include/google/protobuf/arena.h:36: In file included from /opt/protobuf-29/include/google/protobuf/arena_align.h:63: /opt/protobuf-29/include/google/protobuf/port_def.inc:542:5: error: function-like macro 'ABSL_HAVE_FEATURE' is not defined \#if ABSL_HAVE_FEATURE(address_sanitizer) Closes #20052 COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/20052 from wilstoff:port_undef_fix 861d2e654f0f0b45f1d43ed911779e6e4aa9855a PiperOrigin-RevId: 721863566 --- python/google/protobuf/pyext/message_module.cc | 10 ++++++++++ src/google/protobuf/arenaz_sampler_test.cc | 11 +++++++++++ src/google/protobuf/json/BUILD.bazel | 2 ++ src/google/protobuf/json/internal/unparser.cc | 7 +++++++ 4 files changed, 30 insertions(+) diff --git a/python/google/protobuf/pyext/message_module.cc b/python/google/protobuf/pyext/message_module.cc index 1ec017b4e69a9..fbebaf491d40f 100644 --- a/python/google/protobuf/pyext/message_module.cc +++ b/python/google/protobuf/pyext/message_module.cc @@ -4,12 +4,20 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file or at // https://developers.google.com/open-source/licenses/bsd +#include +#include #define PY_SSIZE_T_CLEAN #include #include "google/protobuf/descriptor.pb.h" +#include "absl/log/absl_check.h" #include "absl/log/absl_log.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_cat.h" +#include "google/protobuf/descriptor.h" +#include "google/protobuf/descriptor_database.h" #include "google/protobuf/dynamic_message.h" #include "google/protobuf/message_lite.h" #include "google/protobuf/proto_api.h" @@ -347,3 +355,5 @@ PyMODINIT_FUNC PyInit__message() { return m; } + +#include "google/protobuf/port_undef.inc" diff --git a/src/google/protobuf/arenaz_sampler_test.cc b/src/google/protobuf/arenaz_sampler_test.cc index 20a0473207e52..dd8063900c778 100644 --- a/src/google/protobuf/arenaz_sampler_test.cc +++ b/src/google/protobuf/arenaz_sampler_test.cc @@ -8,6 +8,9 @@ #include "google/protobuf/arenaz_sampler.h" #include +#include +#include +#include #include #include #include @@ -16,6 +19,12 @@ #include #include +#include "absl/log/absl_check.h" +#include "absl/strings/str_cat.h" +#include "absl/synchronization/mutex.h" +#include "absl/time/clock.h" +#include "google/protobuf/arena_allocation_policy.h" +#include "google/protobuf/serial_arena.h" // Must be included last. @@ -598,3 +607,5 @@ TEST(ThreadSafeArenazSamplerTest, UsedAndWasted) { } // namespace internal } // namespace protobuf } // namespace google + +#include "google/protobuf/port_undef.inc" diff --git a/src/google/protobuf/json/BUILD.bazel b/src/google/protobuf/json/BUILD.bazel index 0bcb4afede0b1..8c6f5e712285d 100644 --- a/src/google/protobuf/json/BUILD.bazel +++ b/src/google/protobuf/json/BUILD.bazel @@ -266,12 +266,14 @@ cc_library( "//src/google/protobuf:port", "//src/google/protobuf:type_cc_proto", "//src/google/protobuf/io", + "//src/google/protobuf/io:zero_copy_sink", "//src/google/protobuf/stubs", "//src/google/protobuf/util:type_resolver", "@com_google_absl//absl/container:flat_hash_map", "@com_google_absl//absl/log:absl_check", "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/status", + "@com_google_absl//absl/status:statusor", "@com_google_absl//absl/strings", "@com_google_absl//absl/strings:str_format", "@com_google_absl//absl/types:optional", diff --git a/src/google/protobuf/json/internal/unparser.cc b/src/google/protobuf/json/internal/unparser.cc index 33e4505d1369c..6d5b63b9dc8c8 100644 --- a/src/google/protobuf/json/internal/unparser.cc +++ b/src/google/protobuf/json/internal/unparser.cc @@ -18,10 +18,12 @@ #include #include #include +#include #include "absl/log/absl_check.h" #include "absl/log/absl_log.h" #include "absl/status/status.h" +#include "absl/status/statusor.h" #include "absl/strings/ascii.h" #include "absl/strings/escaping.h" #include "absl/strings/str_cat.h" @@ -31,11 +33,14 @@ #include "google/protobuf/descriptor.h" #include "google/protobuf/dynamic_message.h" #include "google/protobuf/io/coded_stream.h" +#include "google/protobuf/io/zero_copy_sink.h" #include "google/protobuf/io/zero_copy_stream.h" +#include "google/protobuf/io/zero_copy_stream_impl_lite.h" #include "google/protobuf/json/internal/descriptor_traits.h" #include "google/protobuf/json/internal/unparser_traits.h" #include "google/protobuf/json/internal/writer.h" #include "google/protobuf/message.h" +#include "google/protobuf/util/type_resolver.h" #include "google/protobuf/stubs/status_macros.h" // Must be included last. @@ -905,3 +910,5 @@ absl::Status BinaryToJsonStream(google::protobuf::util::TypeResolver* resolver, } // namespace json_internal } // namespace protobuf } // namespace google + +#include "google/protobuf/port_undef.inc"