From b167cf6acb288a9c869ff21841b427831a4ae555 Mon Sep 17 00:00:00 2001 From: ganchuantao Date: Mon, 11 Aug 2025 18:02:31 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9Aprotobuf=E4=BB=A3=E7=A0=81=E5=B7=AE?= =?UTF-8?q?=E5=BC=82=20Signed-off-by:ganchuantao=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ganchuantao --- bundle.json | 28 +++++++++++++++++++ cmake/abseil-cpp.cmake | 8 +++++- libprotobuf.map | 18 ++++++++++++ src/file_lists.cmake | 2 -- src/google/protobuf/{endian.h => endian_pb.h} | 0 src/google/protobuf/io/coded_stream.h | 2 +- src/google/protobuf/parse_context.h | 2 +- src/google/protobuf/wire_format_lite.cc | 11 +++++++- src/google/protobuf/wire_format_lite.h | 6 ++++ third_party/utf8_range/CMakeLists.txt | 4 +-- 10 files changed, 73 insertions(+), 8 deletions(-) rename src/google/protobuf/{endian.h => endian_pb.h} (100%) diff --git a/bundle.json b/bundle.json index 26c1d18..3056a87 100644 --- a/bundle.json +++ b/bundle.json @@ -30,27 +30,55 @@ "sub_component": [], "inner_kits": [ { + "header": { + "header_base": "//third_party/protobuf/src/google/protobuf", + "header_files": [] + }, "name": "//third_party/protobuf:protobuf" }, { + "header": { + "header_base": "//third_party/protobuf/src/google/protobuf", + "header_files": [] + }, "name": "//third_party/protobuf:protobuf_lite" }, { + "header": { + "header_base": "//third_party/protobuf/src/google/protobuf", + "header_files": [] + }, "name": "//third_party/protobuf:protobuf_lite_static" }, { + "header": { + "header_base": "//third_party/protobuf/src/google/protobuf", + "header_files": [] + }, "name": "//third_party/protobuf:protobuf_static" }, { + "header": { + "header_base": "//third_party/protobuf/src/google/protobuf", + "header_files": [] + }, "name": "//third_party/protobuf:protobuf" }, { "name": "//third_party/protobuf:protoc" }, { + "header": { + "header_base": "//third_party/protobuf/src/google/protobuf", + "header_files": [] + }, "name": "//third_party/protobuf:protoc_lib" }, { + "header": { + "header_base": "//third_party/protobuf/src/google/protobuf/compiler", + "header_files": [] + }, "name": "//third_party/protobuf:protoc_static_lib" } ], diff --git a/cmake/abseil-cpp.cmake b/cmake/abseil-cpp.cmake index 1b64aff..2b73259 100644 --- a/cmake/abseil-cpp.cmake +++ b/cmake/abseil-cpp.cmake @@ -15,7 +15,13 @@ if(TARGET absl::strings) # (https://github.com/protocolbuffers/protobuf/issues/10435) elseif(protobuf_ABSL_PROVIDER STREQUAL "module") if(NOT ABSL_ROOT_DIR) - set(ABSL_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp) + if (NOT EXISTS "{protobuf_SOURCE_DIR}/../../out/abseil-cpp/CMakeLists.txt") + execute_process(COMMAND ${protobuf_SOURCE_DIR}/../abseil-cpp/install_no_lock.sh ${protobuf_SOURCE_DIR}/../../out/ ${protobuf_SOURCE_DIR}/../abseil-cpp + WORKING_DIRECTORY ${protobuf_SOURCE_DIR}/../abseil-cpp + RESULT_VARIABLE result) + endif() + set(ABSL_ROOT_DIR ${protobuf_SOURCE_DIR}/../../out/abseil-cpp) + set(EXPORT_ABSL_ROOT_DIR "out/abseil-cpp" CACHE PATH "absl_root_dir") endif() if(EXISTS "${ABSL_ROOT_DIR}/CMakeLists.txt") if(protobuf_INSTALL) diff --git a/libprotobuf.map b/libprotobuf.map index e6abeca..80982e8 100644 --- a/libprotobuf.map +++ b/libprotobuf.map @@ -268,6 +268,11 @@ "google::protobuf::FileDescriptorProto::InternalSwap(google::protobuf::FileDescriptorProto*)"; "google::protobuf::Arena::Allocate(unsigned long)"; "google::protobuf::_GeneratedCodeInfo_default_instance_"; + "google::protobuf::GeneratedCodeInfo::MergeFrom(google::protobuf::GeneratedCodeInfo const&)"; + "scc_info_GeneratedCodeInfo_google_2fprotobuf_2fdescriptor_2eproto"; + "google::protobuf::internal::ArenaStringPtr::Destroy(google::protobuf::internal::ArenaStringPtr::EmptyDefault, google::protobuf::Arena*)"; + "google::protobuf::internal::kGlobalEmptyTable"; + "google::protobuf::internal::ArenaStringPtr::Set(std::__h::basic_string, std::__h::allocator> const*, std::__h::basic_string, std::__h::allocator> const&, google::protobuf::Arena*)"; "google::protobuf::io::Printer::PrintImpl(std::basic_string_view>, absl::lts_20230802::Span, std::allocator> const>, google::protobuf::io::Printer::PrintOptions)"; "google::protobuf::io::StringOutputStream::Next(void**, int*)"; "google::protobuf::io::StringOutputStream::BackUp(int)"; @@ -402,12 +407,24 @@ "google::protobuf::Message::MaybeComputeUnknownFieldsSize(unsigned int, google::protobuf::internal::CachedSize*) const"; "google::protobuf::internal::TcParser::GenericFallback(google::protobuf::MessageLite*, char const*, google::protobuf::internal::ParseContext*, google::protobuf::internal::TcFieldData, google::protobuf::internal::TcParseTableBase const*, unsigned long long)"; "google::protobuf::internal::TcParser::FastV32P2(google::protobuf::MessageLite*, char const*, google::protobuf::internal::ParseContext*, google::protobuf::internal::TcFieldData, google::protobuf::internal::TcParseTableBase const*, unsigned long long)"; + "absl::lts_20230802::log_internal::LogMessageFatal::LogMessageFatal(char const*, int, std::__h::basic_string_view>)"; + "absl::lts_20230802::log_internal::LogMessageFatal::~LogMessageFatal()"; + "absl::lts_20230802::Mutex::~Mutex()"; + "absl::lts_20230802::Cord::Append(absl::lts_20230802::Cord&&)"; + "absl::lts_20230802::Cord::DestroyCordSlow()"; + "absl::lts_20230802::cord_internal::InitializeCordRepExternal(std::__h::basic_string_view>, absl::lts_20230802::cord_internal::CordRepExternal*)"; + "absl::lts_20230802::cord_internal::cordz_should_profile_slow()"; + "absl::lts_20230802::cord_internal::CordzInfo::TrackCord(absl::lts_20230802::cord_internal::InlineData&, absl::lts_20230802::cord_internal::CordzUpdateTracker::MethodIdentifier)"; + "absl::lts_20230802::Cord::Subcord(unsigned int, unsigned int) const"; + "absl::lts_20230802::Mutex::Lock()"; + "absl::lts_20230802::Mutex::Unlock()"; "__emutls_v._ZN6google8protobuf8internal15ThreadSafeArena13thread_cache_E"; "google::protobuf::internal::TcParser::FastEr0S1(google::protobuf::MessageLite*, char const*, google::protobuf::internal::ParseContext*, google::protobuf::internal::TcFieldData, google::protobuf::internal::TcParseTableBase const*, unsigned long long)"; "google::protobuf::internal::TcParser::FastSS1(google::protobuf::MessageLite*, char const*, google::protobuf::internal::ParseContext*, google::protobuf::internal::TcFieldData, google::protobuf::internal::TcParseTableBase const*, unsigned long long)"; "google::protobuf::internal::TcParser::FastSR1(google::protobuf::MessageLite*, char const*, google::protobuf::internal::ParseContext*, google::protobuf::internal::TcFieldData, google::protobuf::internal::TcParseTableBase const*, unsigned long long)"; "__emutls_v._ZN4absl12lts_2023080213cord_internal17cordz_next_sampleE"; "google::protobuf::TextFormat::ParseFromString(std::__h::basic_string_view>, google::protobuf::Message*)"; + "void absl::lts_20230802::log_internal::LogMessage::CopyToEncodedBuffer<(absl::lts_20230802::log_internal::LogMessage::StringType)0>(std::__h::basic_string_view>)"; "google::protobuf::internal::protobuf_assumption_failed(char const*, char const*, int)"; "google::protobuf::internal::TcParser::GenericFallbackLite(google::protobuf::MessageLite*, char const*, google::protobuf::internal::ParseContext*, google::protobuf::internal::TcFieldData, google::protobuf::internal::TcParseTableBase const*, unsigned long)"; "google::protobuf::internal::TcParser::FastBS1(google::protobuf::MessageLite*, char const*, google::protobuf::internal::ParseContext*, google::protobuf::internal::TcFieldData, google::protobuf::internal::TcParseTableBase const*, unsigned long)"; @@ -430,6 +447,7 @@ "google::protobuf::internal::TcParser::FastUR1(google::protobuf::MessageLite*, char const*, google::protobuf::internal::ParseContext*, google::protobuf::internal::TcFieldData, google::protobuf::internal::TcParseTableBase const*, unsigned long)"; "std::__h::basic_string, std::__h::allocator>* absl::lts_20230802::log_internal::MakeCheckOpString(long, long, char const*)"; "google::protobuf::internal::TcParser::FastV32P1(google::protobuf::MessageLite*, char const*, google::protobuf::internal::ParseContext*, google::protobuf::internal::TcFieldData, google::protobuf::internal::TcParseTableBase const*, unsigned long)"; + "absl::lts_20230802::Cord::Subcord(unsigned long, unsigned long) const"; "google::protobuf::internal::TcParser::FastV32P2(google::protobuf::MessageLite*, char const*, google::protobuf::internal::ParseContext*, google::protobuf::internal::TcFieldData, google::protobuf::internal::TcParseTableBase const*, unsigned long)"; "google::protobuf::internal::TcParser::FastV32P1(google::protobuf::MessageLite*, char const*, google::protobuf::internal::ParseContext*, google::protobuf::internal::TcFieldData, google::protobuf::internal::TcParseTableBase const*, unsigned long)"; "google::protobuf::internal::TcParser::FastUS2(google::protobuf::MessageLite*, char const*, google::protobuf::internal::ParseContext*, google::protobuf::internal::TcFieldData, google::protobuf::internal::TcParseTableBase const*, unsigned long)"; diff --git a/src/file_lists.cmake b/src/file_lists.cmake index 104a296..9e7b689 100644 --- a/src/file_lists.cmake +++ b/src/file_lists.cmake @@ -119,7 +119,6 @@ set(libprotobuf_hdrs ${protobuf_SOURCE_DIR}/src/google/protobuf/descriptor_lite.h ${protobuf_SOURCE_DIR}/src/google/protobuf/descriptor_visitor.h ${protobuf_SOURCE_DIR}/src/google/protobuf/dynamic_message.h - ${protobuf_SOURCE_DIR}/src/google/protobuf/endian.h ${protobuf_SOURCE_DIR}/src/google/protobuf/explicitly_constructed.h ${protobuf_SOURCE_DIR}/src/google/protobuf/extension_set.h ${protobuf_SOURCE_DIR}/src/google/protobuf/extension_set_inl.h @@ -245,7 +244,6 @@ set(libprotobuf_lite_hdrs ${protobuf_SOURCE_DIR}/src/google/protobuf/arenastring.h ${protobuf_SOURCE_DIR}/src/google/protobuf/arenaz_sampler.h ${protobuf_SOURCE_DIR}/src/google/protobuf/descriptor_lite.h - ${protobuf_SOURCE_DIR}/src/google/protobuf/endian.h ${protobuf_SOURCE_DIR}/src/google/protobuf/explicitly_constructed.h ${protobuf_SOURCE_DIR}/src/google/protobuf/extension_set.h ${protobuf_SOURCE_DIR}/src/google/protobuf/extension_set_inl.h diff --git a/src/google/protobuf/endian.h b/src/google/protobuf/endian_pb.h similarity index 100% rename from src/google/protobuf/endian.h rename to src/google/protobuf/endian_pb.h diff --git a/src/google/protobuf/io/coded_stream.h b/src/google/protobuf/io/coded_stream.h index dc03435..a0cab49 100644 --- a/src/google/protobuf/io/coded_stream.h +++ b/src/google/protobuf/io/coded_stream.h @@ -110,7 +110,7 @@ #include "absl/numeric/bits.h" #include "absl/strings/cord.h" #include "absl/strings/string_view.h" -#include "google/protobuf/endian.h" +#include "google/protobuf/endian_pb.h" // Must be included last. #include "google/protobuf/port_def.inc" diff --git a/src/google/protobuf/parse_context.h b/src/google/protobuf/parse_context.h index 22ed821..8d30655 100644 --- a/src/google/protobuf/parse_context.h +++ b/src/google/protobuf/parse_context.h @@ -23,7 +23,7 @@ #include "absl/types/optional.h" #include "google/protobuf/arena.h" #include "google/protobuf/arenastring.h" -#include "google/protobuf/endian.h" +#include "google/protobuf/endian_pb.h" #include "google/protobuf/inlined_string_field.h" #include "google/protobuf/io/coded_stream.h" #include "google/protobuf/io/zero_copy_stream.h" diff --git a/src/google/protobuf/wire_format_lite.cc b/src/google/protobuf/wire_format_lite.cc index 0e56429..3ed31bb 100644 --- a/src/google/protobuf/wire_format_lite.cc +++ b/src/google/protobuf/wire_format_lite.cc @@ -610,8 +610,13 @@ void PrintUTF8ErrorLog(absl::string_view message_name, ABSL_LOG(ERROR) << error_message; } +#if defined (__MINGW64__) || defined(__MINGW32__) bool WireFormatLite::VerifyUtf8String(const char* data, int size, Operation op, - std::string_view field_name) { + const std::string_view field_name) { +#else +bool WireFormatLite::VerifyUtf8String(const char* data, int size, Operation op, + const absl::string_view field_name) { +#endif if (!utf8_range::IsStructurallyValid({data, static_cast(size)})) { const char* operation_str = nullptr; switch (op) { @@ -623,7 +628,11 @@ bool WireFormatLite::VerifyUtf8String(const char* data, int size, Operation op, break; // no default case: have the compiler warn if a case is not covered. } +#if defined (__MINGW64__) || defined(__MINGW32__) PrintUTF8ErrorLog("", absl::string_view{field_name.data(), field_name.size()}, operation_str, false); +#else + PrintUTF8ErrorLog("", field_name, operation_str, false); +#endif return false; } return true; diff --git a/src/google/protobuf/wire_format_lite.h b/src/google/protobuf/wire_format_lite.h index 9f8a119..96b223d 100644 --- a/src/google/protobuf/wire_format_lite.h +++ b/src/google/protobuf/wire_format_lite.h @@ -317,8 +317,14 @@ class PROTOBUF_EXPORT WireFormatLite { }; // Returns true if the data is valid UTF-8. +#if defined (__MINGW64__) || defined(__MINGW32__) static bool VerifyUtf8String(const char* data, int size, Operation op, std::string_view field_name); +#else + static bool VerifyUtf8String(const char* data, int size, Operation op, + absl::string_view field_name); +#endif + template static inline bool ReadGroup(int field_number, io::CodedInputStream* input, diff --git a/third_party/utf8_range/CMakeLists.txt b/third_party/utf8_range/CMakeLists.txt index 4276b97..8d7a6e1 100644 --- a/third_party/utf8_range/CMakeLists.txt +++ b/third_party/utf8_range/CMakeLists.txt @@ -11,13 +11,13 @@ option (utf8_range_ENABLE_INSTALL "Configure installation" ON) ## # Create the lightweight C library -add_library (utf8_range +add_library (utf8_range STATIC utf8_range.c ) ## # A heavier-weight C++ wrapper that supports Abseil. -add_library (utf8_validity utf8_validity.cc utf8_range.c) +add_library (utf8_validity STATIC utf8_validity.cc utf8_range.c) # Load Abseil dependency. if (NOT TARGET absl::strings) -- Gitee