Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

Revert "Update Protobuf to 6.31.1" (#39654)

Mikhail Ryzhov0f8c17cb5ddc
diff --git a/.gitmodules b/.gitmodules
index 2d936b46ebc..2f78919d66f 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -41,7 +41,6 @@
[submodule "thirdparty/protobuf"]
path = thirdparty/protobuf/protobuf
url = https://github.com/protocolbuffers/protobuf.git
- ignore = dirty
[submodule "src/bindings/python/thirdparty/pybind11"]
path = src/bindings/python/thirdparty/pybind11
url = https://github.com/pybind/pybind11.git
diff --git a/cmake/toolchains/riscv64.linux.toolchain.cmake b/cmake/toolchains/riscv64.linux.toolchain.cmake
index 18a68df55fc..7b4caeea90f 100644
--- a/cmake/toolchains/riscv64.linux.toolchain.cmake
+++ b/cmake/toolchains/riscv64.linux.toolchain.cmake
@@ -14,8 +14,3 @@ set(CMAKE_CXX_COMPILER_TARGET riscv64-linux-gnu)
set(CMAKE_C_COMPILER riscv64-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER riscv64-linux-gnu-g++)
set(CMAKE_STRIP riscv64-linux-gnu-strip)
-
-# GCC on RISC-V emits calls to __atomic_* libcalls for certain atomic ops.
-# These are resolved by libatomic which must appear at the END of the link
-# command (after static libraries that reference the symbols).
-set(OV_EXPLICIT_ATOMIC_LIB "-latomic" CACHE STRING "" FORCE)
diff --git a/src/bindings/python/constraints.txt b/src/bindings/python/constraints.txt
index 6f390da75ec..28eff149433 100644
--- a/src/bindings/python/constraints.txt
+++ b/src/bindings/python/constraints.txt
@@ -21,5 +21,5 @@ h5py>=3.1.0,<3.17.0
docopt~=0.6.2
paddlepaddle==3.0.0
tensorflow>=1.15.5,<2.21.0
-protobuf>=6.31.1,<7.34.0 # 7.34 drops text_format float_format, still used by tf.io.write_graph
+protobuf>=5.26.0,<7.0.0
onnx==1.22.0
diff --git a/src/frontends/onnx/frontend/src/core/graph_iterator_proto.cpp b/src/frontends/onnx/frontend/src/core/graph_iterator_proto.cpp
index 16387f2feeb..4463adddc0b 100644
--- a/src/frontends/onnx/frontend/src/core/graph_iterator_proto.cpp
+++ b/src/frontends/onnx/frontend/src/core/graph_iterator_proto.cpp
@@ -452,11 +452,8 @@ ov::frontend::onnx::TensorMetaInfo extract_tensor_meta_info(const TensorProto* t
tensor_meta_info.m_is_raw = true;
} else {
const auto assign_numeric_data = [&](const auto& container) {
- // Non-null even when empty: a non-null payload is what marks a tensor as an initializer.
- static const uint8_t empty_payload{};
+ tensor_meta_info.m_tensor_data = reinterpret_cast<const uint8_t*>(container.data());
tensor_meta_info.m_tensor_data_size = static_cast<size_t>(container.size());
- tensor_meta_info.m_tensor_data =
- container.size() == 0 ? &empty_payload : reinterpret_cast<const uint8_t*>(container.data());
};
switch (tensor_info->data_type()) {
case TensorProto_DataType::TensorProto_DataType_FLOAT:
diff --git a/src/frontends/onnx/frontend/src/translate_session.cpp b/src/frontends/onnx/frontend/src/translate_session.cpp
index 35365336cea..c6e9f3fcfab 100644
--- a/src/frontends/onnx/frontend/src/translate_session.cpp
+++ b/src/frontends/onnx/frontend/src/translate_session.cpp
@@ -141,19 +141,14 @@ std::shared_ptr<ov::Node> TranslateSession::create_const_or_param(
std::shared_ptr<ov::Node> node;
const auto& shape = input_tensor->get_partial_shape();
const bool is_empty_shape = shape.is_static() && ov::shape_size(shape.to_shape()) == 0;
- const bool has_inline_data = input_tensor->get_data() != nullptr;
- const bool has_external_data = input_tensor->get_data_location() != nullptr;
// STRING initializers carry data in get_data_any() with get_data()==nullptr; treat as Constants.
- const bool has_string_data = !input_tensor->get_data_any().empty();
- // get_ov_constant() would turn a zero-element initializer into a scalar failsafe Constant.
- const bool is_empty_initializer = is_empty_shape && input_tensor->get_data_size() == 0 && !has_external_data &&
- !has_string_data && (has_inline_data || !is_model_input);
- if (is_empty_initializer) {
+ if (input_tensor->get_data_location() != nullptr || input_tensor->get_data() != nullptr ||
+ !input_tensor->get_data_any().empty()) {
+ node = Tensor(input_tensor).get_ov_constant();
+ } else if (!is_model_input && is_empty_shape) { // empty constant
node = ov::op::v0::Constant::create(input_tensor->get_element_type(),
input_tensor->get_partial_shape().to_shape(),
{});
- } else if (has_inline_data || has_external_data || has_string_data) {
- node = Tensor(input_tensor).get_ov_constant();
} else {
node = std::make_shared<ov::op::v0::Parameter>(input_tensor->get_element_type(),
input_tensor->get_partial_shape());
diff --git a/src/frontends/onnx/tests/graph_iterator.cpp b/src/frontends/onnx/tests/graph_iterator.cpp
index ac90ecba1ef..d92c0534ecb 100644
--- a/src/frontends/onnx/tests/graph_iterator.cpp
+++ b/src/frontends/onnx/tests/graph_iterator.cpp
@@ -697,82 +697,6 @@ TEST(FrontEndGraphIteratorTest, multidimensional_empty_initializer_is_not_parame
}
}
-TEST(FrontEndGraphIteratorTest, empty_initializer_as_graph_output_is_empty_constant) {
- const std::vector<std::pair<ONNX_NAMESPACE::TensorProto_DataType, ov::Shape>> cases{
- {ONNX_NAMESPACE::TensorProto_DataType_INT64, ov::Shape{0}},
- {ONNX_NAMESPACE::TensorProto_DataType_FLOAT, ov::Shape{2, 0}},
- };
- for (const auto& [data_type, empty_shape] : cases) {
- for (bool materialize_places : {false, true}) {
- SCOPED_TRACE(testing::Message() << "data_type=" << data_type << " shape=" << empty_shape
- << " materialize_places=" << materialize_places);
- auto model_proto = std::make_shared<ModelProto>();
- model_proto->set_ir_version(8);
- model_proto->add_opset_import()->set_version(13);
- auto* graph = model_proto->mutable_graph();
- graph->set_name("empty_initializer_output");
-
- // No node consumes "empty"; it is only reachable as a declared graph output.
- auto* initializer = graph->add_initializer();
- initializer->set_name("empty");
- initializer->set_data_type(data_type);
- for (const auto dimension : empty_shape) {
- initializer->add_dims(static_cast<int64_t>(dimension));
- }
-
- auto* input = graph->add_input();
- input->set_name("input");
- auto* input_type = input->mutable_type()->mutable_tensor_type();
- input_type->set_elem_type(ONNX_NAMESPACE::TensorProto_DataType_FLOAT);
- input_type->mutable_shape()->add_dim()->set_dim_value(3);
-
- auto* identity = graph->add_node();
- identity->set_op_type("Identity");
- identity->add_input("input");
- identity->add_output("output");
-
- auto* output = graph->add_output();
- output->set_name("output");
- *output->mutable_type() = input->type();
-
- auto* empty_output = graph->add_output();
- empty_output->set_name("empty");
- auto* empty_output_type = empty_output->mutable_type()->mutable_tensor_type();
- empty_output_type->set_elem_type(data_type);
- for (const auto dimension : empty_shape) {
- empty_output_type->mutable_shape()->add_dim()->set_dim_value(static_cast<int64_t>(dimension));
- }
-
- auto iterator = std::make_shared<ov::frontend::onnx::GraphIteratorProto>(
- ov::frontend::onnx::GraphIteratorProtoMemoryManagementMode::External_Stream);
- iterator->initialize(model_proto);
- iterator->reset();
- ov::frontend::onnx::GraphIterator::Ptr graph_iterator = iterator;
- auto frontend = ov::frontend::FrontEndManager().load_by_framework("onnx");
- ASSERT_NE(frontend, nullptr);
- auto input_model = frontend->load(graph_iterator);
- ASSERT_NE(input_model, nullptr);
- if (materialize_places) {
- // Force the Place-graph conversion path; otherwise convert directly from the iterator.
- ASSERT_EQ(input_model->get_inputs().size(), 1);
- }
-
- std::shared_ptr<ov::Model> model;
- ASSERT_NO_THROW(model = frontend->convert(input_model));
- ASSERT_NE(model, nullptr);
- ASSERT_EQ(model->get_parameters().size(), 1);
- ASSERT_EQ(model->get_results().size(), 2);
-
- const auto empty_result = model->output("empty");
- const auto constant =
- ov::as_type_ptr<ov::op::v0::Constant>(empty_result.get_node()->get_input_node_shared_ptr(0));
- ASSERT_NE(constant, nullptr);
- EXPECT_EQ(constant->get_shape(), empty_shape);
- EXPECT_EQ(constant->get_byte_size(), 0);
- }
- }
-}
-
// =====================================================================================================
// Accuracy / structural equivalence of the deferred-InputModel single-pass converter (translate
// straight from the GraphIterator decoders, skipping load_model()) against the InputModel-backed
diff --git a/tests/constraints.txt b/tests/constraints.txt
index e827847b4c8..2cfd1360b82 100644
--- a/tests/constraints.txt
+++ b/tests/constraints.txt
@@ -16,7 +16,7 @@ onnx>=1.22.0
onnxruntime>=1.23.2
opencv-python>=4.5
paddlepaddle==3.3.0
-protobuf>=6.31.1,<7.34.0 # 7.34 drops text_format float_format, still used by tf.io.write_graph
+protobuf>=5.26.0,<7.0.0
py>=1.9.0
pytest>=5.0,<9.2
pytest-dependency==0.6.1
diff --git a/tests/requirements_onnx b/tests/requirements_onnx
index 6237879708b..b846a7f7200 100644
--- a/tests/requirements_onnx
+++ b/tests/requirements_onnx
@@ -1,4 +1,4 @@
numpy>=1.23.2,<2.2.0
onnx==1.22.0
ml_dtypes==0.5.4
-protobuf>=6.31.1,<7.34.0
+protobuf>=5.26.0,<7.0.0
diff --git a/thirdparty/dependencies.cmake b/thirdparty/dependencies.cmake
index 91481cb1452..6838f8f5736 100644
--- a/thirdparty/dependencies.cmake
+++ b/thirdparty/dependencies.cmake
@@ -387,21 +387,12 @@ if(ENABLE_OV_PADDLE_FRONTEND OR ENABLE_OV_ONNX_FRONTEND OR ENABLE_OV_TF_FRONTEND
if(CMAKE_VERBOSE_MAKEFILE)
set(Protobuf_DEBUG ON)
endif()
- set(Protobuf_VERSION_REQUIRED "6.31.1")
# only protobuf's own CONFIG package propagates Abseil, which protobuf 22 and newer requires
find_package(Protobuf REQUIRED CONFIG)
- if(Protobuf_VERSION VERSION_LESS "${Protobuf_VERSION_REQUIRED}")
- message(FATAL_ERROR "Protobuf ${Protobuf_VERSION_REQUIRED} or newer is required, but ${Protobuf_VERSION} is found")
- endif()
- if(Protobuf_FOUND)
- # protobuf was found via CONFIG mode, let's save it for later usage in OpenVINOConfig.cmake static build
- set(protobuf_config CONFIG)
- else()
- if(OV_VCPKG_BUILD)
- set(protobuf_config CONFIG)
- endif()
- # otherwise, fallback to existing default
- find_package(Protobuf ${Protobuf_VERSION_REQUIRED} REQUIRED ${protobuf_config})
+ # protobuf release number is the minor component: release 26 is 5.26, release 33 is 6.33.
+ # it cannot be checked by find_package, whose version argument requires an exact major match
+ if(Protobuf_VERSION_MINOR VERSION_LESS 26)
+ message(FATAL_ERROR "Protobuf 26 (5.26) or newer is required, but ${Protobuf_VERSION} is found")
endif()
# exported into OpenVINOConfig.cmake for static build
set(protobuf_config CONFIG)
diff --git a/thirdparty/patches.cmake b/thirdparty/patches.cmake
deleted file mode 100644
index 5f9d19ef492..00000000000
--- a/thirdparty/patches.cmake
+++ /dev/null
@@ -1,88 +0,0 @@
-# Copyright (C) 2018-2026 Intel Corporation
-# SPDX-License-Identifier: Apache-2.0
-#
-
-#
-# ov_apply_patch(
-# PATCH <absolute-path-to-.patch-file>
-# [WORKING_DIRECTORY <dir>] -- directory passed to 'git apply'; defaults to CMAKE_SOURCE_DIR
-# )
-#
-# Applies a local patch file via 'git apply' during the CMake configure phase.
-# Idempotent: uses 'git apply --reverse --check' to detect whether the patch is
-# already applied and skips the apply step if so.
-# Relies on GIT_FOUND / GIT_EXECUTABLE, which are set by find_package(Git) in version.cmake.
-#
-function(ov_apply_patch)
- cmake_parse_arguments(ARG "" "PATCH;WORKING_DIRECTORY" "" ${ARGN})
-
- if(NOT DEFINED ARG_PATCH OR ARG_PATCH STREQUAL "")
- message(FATAL_ERROR "ov_apply_patch: PATCH argument is required")
- endif()
-
- if(NOT EXISTS "${ARG_PATCH}")
- message(FATAL_ERROR "ov_apply_patch: patch file does not exist: ${ARG_PATCH}")
- endif()
-
- if(NOT DEFINED ARG_WORKING_DIRECTORY OR ARG_WORKING_DIRECTORY STREQUAL "")
- set(ARG_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")
- endif()
-
- if(NOT IS_DIRECTORY "${ARG_WORKING_DIRECTORY}")
- message(FATAL_ERROR "ov_apply_patch: working directory does not exist: ${ARG_WORKING_DIRECTORY}")
- endif()
-
- # GIT_FOUND / GIT_EXECUTABLE are set by find_package(Git) in version.cmake,
- # but may be absent (e.g. Git not on PATH at configure time on Windows).
- # Re-run find_package locally as a fallback — it is cheap and cached by CMake.
- if(NOT GIT_FOUND)
- find_package(Git QUIET)
- endif()
- if(NOT GIT_FOUND)
- message(FATAL_ERROR
- "ov_apply_patch: Git is required to apply patches but was not found.\n"
- " Patch: ${ARG_PATCH}")
- endif()
-
- get_filename_component(_patch_display "${ARG_PATCH}" NAME)
-
- # Check whether the patch is already applied by attempting a dry-run reverse.
- # Exit code 0 → reverse applies cleanly → patch IS already applied → skip.
- # Exit code ≠ 0 → reverse fails → patch is NOT yet applied → apply it.
- execute_process(
- COMMAND "${GIT_EXECUTABLE}" -c core.autocrlf=false apply
- --reverse --check
- --ignore-space-change
- --ignore-whitespace
- "${ARG_PATCH}"
- WORKING_DIRECTORY "${ARG_WORKING_DIRECTORY}"
- RESULT_VARIABLE _ov_reverse_rc
- OUTPUT_QUIET
- ERROR_QUIET
- )
-
- if(_ov_reverse_rc EQUAL 0)
- return()
- endif()
-
- # Patch not yet applied — apply it now.
- # -c core.autocrlf=false: patch files on Windows may have CRLF line endings;
- # disabling autocrlf makes git apply agnostic of the patch file's line endings.
- execute_process(
- COMMAND "${GIT_EXECUTABLE}" -c core.autocrlf=false apply
- --ignore-space-change
- --ignore-whitespace
- "${ARG_PATCH}"
- WORKING_DIRECTORY "${ARG_WORKING_DIRECTORY}"
- RESULT_VARIABLE _ov_patch_rc
- ERROR_VARIABLE _ov_patch_err
- OUTPUT_QUIET
- )
-
- if(NOT _ov_patch_rc EQUAL 0)
- message(FATAL_ERROR
- "ov_apply_patch: failed to apply '${_patch_display}':\n${_ov_patch_err}")
- endif()
-
- message(STATUS "Applied patch: ${_patch_display}")
-endfunction()
diff --git a/thirdparty/protobuf/CMakeLists.txt b/thirdparty/protobuf/CMakeLists.txt
index 5e34983c0f7..200fe01874d 100644
--- a/thirdparty/protobuf/CMakeLists.txt
+++ b/thirdparty/protobuf/CMakeLists.txt
@@ -6,17 +6,6 @@
# Configure Google Protobuf ...
#------------------------------------------------------------------------------
-set(OV_SAVED_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES}")
-set(OV_SAVED_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES}")
-
-if(OV_EXPLICIT_ATOMIC_LIB)
- set(CMAKE_CXX_STANDARD_LIBRARIES
- "${CMAKE_CXX_STANDARD_LIBRARIES} ${OV_EXPLICIT_ATOMIC_LIB}")
-
- set(CMAKE_C_STANDARD_LIBRARIES
- "${CMAKE_C_STANDARD_LIBRARIES} ${OV_EXPLICIT_ATOMIC_LIB}")
-endif()
-
if(ENABLE_THREAD_SANITIZER AND OV_COMPILER_IS_CLANG)
string(REPLACE "-ltsan" "" CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
string(REPLACE "-shared-libsan" "" CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
@@ -88,46 +77,6 @@ endif()
set(CMAKE_COMPILE_WARNING_AS_ERROR OFF)
-include("${CMAKE_CURRENT_LIST_DIR}/../patches.cmake")
-
-# Protobuf 6.30 unconditionally sets ABSL_MSVC_STATIC_RUNTIME=ON for static
-# builds (protobuf_BUILD_SHARED_LIBS=OFF), ignoring protobuf_MSVC_STATIC_RUNTIME.
-# This causes abseil to compile with /MT while protobuf uses /MD, resulting in
-# LNK2038 "mismatch detected for RuntimeLibrary" on MSVC. Patch protobuf's
-# CMakeLists.txt to propagate protobuf_MSVC_STATIC_RUNTIME to abseil.
-ov_apply_patch(
- PATCH "${CMAKE_CURRENT_SOURCE_DIR}/patches/0001-fix-absl-msvc-runtime.patch"
- WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/protobuf")
-
-# Abseil 20250127 (bundled with protobuf 6.31) fails to build with some GCC
-# versions (e.g. the aarch64 cross toolchain and RHEL8) because of two constexpr
-# issues: raw_hash_set::GetPolicyFunctions() compares a function-template address
-# against nullptr in a 'static constexpr', and ascii.cc's ValidateAsciiCasefold()
-# self-test hits an implementation-defined signed-char conversion. Patch
-# protobuf's abseil-cpp.cmake so the FetchContent'd Abseil gets the source fixes
-# applied at populate time. This covers both this build and the native
-# host_protoc build, which share the same protobuf source tree.
-ov_apply_patch(
- PATCH "${CMAKE_CURRENT_SOURCE_DIR}/patches/0003-protobuf-absl-apply-openvino-patch.patch"
- WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/protobuf")
-
-# Protobuf's JSON UntypedMessage stores a std::variant (which holds UntypedMessage
-# itself) in an absl::flat_hash_map member. Abseil's containers probe trivial-type
-# traits on the value_type at class instantiation, which requires the still-incomplete
-# UntypedMessage to be complete and breaks Clang + libstdc++ builds. Use a node-based
-# std::map, which accepts the incomplete mapped type.
-ov_apply_patch(
- PATCH "${CMAKE_CURRENT_SOURCE_DIR}/patches/0004-protobuf-untyped-message-stdmap.patch"
- WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/protobuf")
-
-# protoc's Java generator keeps absl::flat_hash_map members of FieldGeneratorInfo /
-# OneofGeneratorInfo while those structs are only forward-declared. Abseil probes
-# trivial-type traits on the value_type at class instantiation, which needs the type
-# complete and breaks Clang + libstdc++. Include field_common.h to complete them.
-ov_apply_patch(
- PATCH "${CMAKE_CURRENT_SOURCE_DIR}/patches/0005-protobuf-java-context-complete-types.patch"
- WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/protobuf")
-
add_subdirectory(${protobuf_dir} EXCLUDE_FROM_ALL)
get_directory_property(protobuf_VERSION DIRECTORY ${protobuf_dir} DEFINITION protobuf_VERSION)
@@ -200,6 +149,10 @@ if(NOT protobuf_BUILD_PROTOC_BINARIES)
"-Dprotobuf_WITH_ZLIB=${protobuf_WITH_ZLIB}"
NATIVE_SOURCE_SUBDIR "${protobuf_dir}"
NATIVE_TARGETS protoc libprotobuf-lite
+ # Declare the produced protoc binary as a byproduct so that Ninja knows
+ # the rule that generates it. Newer ONNX (>=1.22) adds the imported
+ # protobuf::protoc target to the DEPENDS of its proto-generation custom
+ # commands, which CMake lowers to a file-level dependency on this path.
BUILD_BYPRODUCTS "${PROTOC_EXECUTABLE}")
add_executable(protobuf::protoc IMPORTED GLOBAL)
@@ -218,6 +171,3 @@ else()
set(PROTOC_EXECUTABLE $<TARGET_FILE:protoc> PARENT_SCOPE)
set(PROTOC_DEPENDENCY protoc PARENT_SCOPE)
endif()
-
-set(CMAKE_CXX_STANDARD_LIBRARIES "${OV_SAVED_CXX_STANDARD_LIBRARIES}")
-set(CMAKE_C_STANDARD_LIBRARIES "${OV_SAVED_C_STANDARD_LIBRARIES}")
diff --git a/thirdparty/protobuf/patches/0001-fix-absl-msvc-runtime.patch b/thirdparty/protobuf/patches/0001-fix-absl-msvc-runtime.patch
deleted file mode 100644
index 3d0ebd5cd85..00000000000
--- a/thirdparty/protobuf/patches/0001-fix-absl-msvc-runtime.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff --git a/CMakeLists.txt b/CMakeLists.txt
-index ae3c3246d..d2f4f0b29 100644
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -203,7 +203,7 @@ if (protobuf_BUILD_SHARED_LIBS)
- set(protobuf_SHARED_OR_STATIC "SHARED")
- else (protobuf_BUILD_SHARED_LIBS)
- set(protobuf_SHARED_OR_STATIC "STATIC")
-- set(ABSL_MSVC_STATIC_RUNTIME ON)
-+ set(ABSL_MSVC_STATIC_RUNTIME ${protobuf_MSVC_STATIC_RUNTIME})
- if (protobuf_MSVC_STATIC_RUNTIME)
- set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded$<$<CONFIG:Debug>:Debug>)
- else()
diff --git a/thirdparty/protobuf/patches/0002-absl-gcc-constexpr-fixes.patch b/thirdparty/protobuf/patches/0002-absl-gcc-constexpr-fixes.patch
deleted file mode 100644
index 9fc219d83af..00000000000
--- a/thirdparty/protobuf/patches/0002-absl-gcc-constexpr-fixes.patch
+++ /dev/null
@@ -1,64 +0,0 @@
-Subject: [PATCH] Fix Abseil 20250127 compile-time constexpr failures on some GCC
-
-Abseil 20250127 (bundled with protobuf 6.31 and fetched via FetchContent when no
-system Abseil is available, e.g. when cross-compiling or on RHEL8) fails to
-compile with several GCC versions because of two unrelated constant-expression
-issues. Both are compiler bugs; upstream Abseil keeps the same code, so OpenVINO
-patches the fetched source.
-
-1. container/internal/raw_hash_set.h: GetPolicyFunctions() initializes a
- `static constexpr PolicyFunctions value`. Its `get_hash_slot_fn<hasher>()`
- member compares the address of the function template `TypeErasedApplyToSlotFn`
- against nullptr, which those GCCs reject in a core constant expression:
- hash_policy_traits.h:163: error: '(... == 0)' is not a constant expression
- Making `value` `static const` keeps the exact same semantics (a once-
- initialized function-local static) without forcing constant evaluation.
-
-2. strings/ascii.cc: the compile-time self-test
- `static_assert(ValidateAsciiCasefold() == 0, ...)` forces constant evaluation
- of AsciiStrCaseFold, which performs several `static_cast<char>(v)` conversions
- with v > 127. Those implementation-defined conversions are rejected in a
- constant expression by some GCC versions (e.g. RHEL8):
- ascii.cc: error: non-constant condition for static assertion
- ascii.cc: error: overflow in constant expression
- The self-test has no runtime effect (upstream Abseil CI already covers it), so
- remove the ValidateAsciiCasefold() helper and its static_assert.
---- a/absl/container/internal/raw_hash_set.h
-+++ b/absl/container/internal/raw_hash_set.h
-@@ -4100,5 +4100,5 @@
- static const PolicyFunctions& GetPolicyFunctions() {
-- static constexpr PolicyFunctions value = {
-+ static const PolicyFunctions value = {
- sizeof(slot_type),
- // TODO(b/328722020): try to type erase
- // for standard layout and alignof(Hash) <= alignof(CommonFields).
---- a/absl/strings/ascii.cc
-+++ b/absl/strings/ascii.cc
-@@ -228,27 +228,3 @@
- }
-
--static constexpr size_t ValidateAsciiCasefold() {
-- constexpr size_t num_chars = 1 + CHAR_MAX - CHAR_MIN;
-- size_t incorrect_index = 0;
-- char lowered[num_chars] = {};
-- char uppered[num_chars] = {};
-- for (unsigned int i = 0; i < num_chars; ++i) {
-- uppered[i] = lowered[i] = static_cast<char>(i);
-- }
-- AsciiStrCaseFold<false>(&lowered[0], &lowered[0], num_chars);
-- AsciiStrCaseFold<true>(&uppered[0], &uppered[0], num_chars);
-- for (size_t i = 0; i < num_chars; ++i) {
-- const char ch = static_cast<char>(i),
-- ch_upper = ('a' <= ch && ch <= 'z' ? 'A' + (ch - 'a') : ch),
-- ch_lower = ('A' <= ch && ch <= 'Z' ? 'a' + (ch - 'A') : ch);
-- if (uppered[i] != ch_upper || lowered[i] != ch_lower) {
-- incorrect_index = i > 0 ? i : num_chars;
-- break;
-- }
-- }
-- return incorrect_index;
--}
--
--static_assert(ValidateAsciiCasefold() == 0, "error in case conversion");
--
- } // namespace ascii_internal
diff --git a/thirdparty/protobuf/patches/0003-protobuf-absl-apply-openvino-patch.patch b/thirdparty/protobuf/patches/0003-protobuf-absl-apply-openvino-patch.patch
deleted file mode 100644
index 1f191d1d16b..00000000000
--- a/thirdparty/protobuf/patches/0003-protobuf-absl-apply-openvino-patch.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-Subject: [PATCH] cmake: apply OpenVINO abseil source fix when fetching Abseil
-
-Protobuf downloads Abseil via FetchContent when it is not found locally (e.g.
-when cross-compiling, where no target-arch Abseil package is available). The
-bundled Abseil 20250127 fails to compile with some GCC versions because
-raw_hash_set::GetPolicyFunctions() uses a `static constexpr PolicyFunctions`
-whose initializer compares a function-template address against nullptr.
-
-Attach a PATCH_COMMAND to the Abseil FetchContent_Declare so the OpenVINO source
-fix is applied at populate time. The helper script and patch live in OpenVINO's
-thirdparty/protobuf/patches directory, referenced relative to this file so it
-works for both the main build and the native host protoc build.
---- a/cmake/abseil-cpp.cmake
-+++ b/cmake/abseil-cpp.cmake
-@@ -24,6 +24,9 @@
- include(FetchContent)
- FetchContent_Declare(
- absl
- GIT_REPOSITORY "https://github.com/abseil/abseil-cpp.git"
- GIT_TAG "${abseil-cpp-version}"
-+ PATCH_COMMAND "${CMAKE_COMMAND}"
-+ "-DPATCH=${CMAKE_CURRENT_LIST_DIR}/../../patches/0002-absl-gcc-constexpr-fixes.patch"
-+ -P "${CMAKE_CURRENT_LIST_DIR}/../../patches/git_apply_once.cmake"
- )
- if (protobuf_INSTALL)
- # When protobuf_INSTALL is enabled and Abseil will be built as a module,
diff --git a/thirdparty/protobuf/patches/0004-protobuf-untyped-message-stdmap.patch b/thirdparty/protobuf/patches/0004-protobuf-untyped-message-stdmap.patch
deleted file mode 100644
index deb6040333c..00000000000
--- a/thirdparty/protobuf/patches/0004-protobuf-untyped-message-stdmap.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-Subject: [PATCH] json: use std::map for UntypedMessage::fields_
-
-UntypedMessage declares `absl::flat_hash_map<int32_t, Value> fields_` as a member,
-where Value is a std::variant that holds UntypedMessage itself (both singular and
-as std::vector<UntypedMessage>). Abseil's open-addressing containers compute
-trivial-type traits (e.g. is_trivially_copyable) on the map's value_type at class
-instantiation to decide slot relocation. That forces the variant's alternatives to
-be complete, including the singular UntypedMessage alternative - which is impossible
-inside UntypedMessage's own definition. Clang with libstdc++ evaluates these traits
-eagerly and fails to build:
-
- type_traits: error: incomplete type 'UntypedMessage' used in type trait expression
- variant: error: ... must be initialized by a constant expression
-
-A node-based std::map does not perform this relocation-trait probing, so it accepts
-an incomplete mapped type at member-declaration time. The field is only looked up by
-number (order-independent), so std::map is a drop-in replacement.
---- a/src/google/protobuf/json/internal/untyped_message.h
-+++ b/src/google/protobuf/json/internal/untyped_message.h
-@@ -15,4 +15,5 @@
- #include <cstddef>
- #include <cstdint>
-+#include <map>
- #include <memory>
- #include <string>
-@@ -232,3 +232,3 @@
- const ResolverPool::Message* desc_;
-- absl::flat_hash_map<int32_t, Value> fields_;
-+ std::map<int32_t, Value> fields_;
- };
diff --git a/thirdparty/protobuf/patches/0005-protobuf-java-context-complete-types.patch b/thirdparty/protobuf/patches/0005-protobuf-java-context-complete-types.patch
deleted file mode 100644
index 70aa4d95164..00000000000
--- a/thirdparty/protobuf/patches/0005-protobuf-java-context-complete-types.patch
+++ /dev/null
@@ -1,22 +0,0 @@
-Subject: [PATCH] java: complete FieldGeneratorInfo/OneofGeneratorInfo in context.h
-
-Context declares `absl::flat_hash_map<const FieldDescriptor*, FieldGeneratorInfo>`
-and `absl::flat_hash_map<const OneofDescriptor*, OneofGeneratorInfo>` members while
-those structs are only forward-declared (they are defined in field_common.h).
-Abseil's open-addressing containers compute trivial-type traits on the map's
-value_type at class instantiation, which requires the value type to be complete.
-Clang with libstdc++ evaluates these eagerly and fails to build:
-
- stl_pair.h: error: field has incomplete type 'FieldGeneratorInfo'
- type_traits: static_assert failed ... __is_complete_or_unbounded
-
-Include field_common.h so both structs are complete at the point of the map
-declarations.
---- a/src/google/protobuf/compiler/java/context.h
-+++ b/src/google/protobuf/compiler/java/context.h
-@@ -12,4 +12,5 @@
- #include <vector>
-
- #include "absl/container/flat_hash_map.h"
-+#include "google/protobuf/compiler/java/field_common.h"
- #include "google/protobuf/compiler/java/helpers.h"
diff --git a/thirdparty/protobuf/patches/git_apply_once.cmake b/thirdparty/protobuf/patches/git_apply_once.cmake
deleted file mode 100644
index d9086fd805a..00000000000
--- a/thirdparty/protobuf/patches/git_apply_once.cmake
+++ /dev/null
@@ -1,47 +0,0 @@
-# Copyright (C) 2018-2026 Intel Corporation
-# SPDX-License-Identifier: Apache-2.0
-#
-# Idempotently apply a git patch to the tree in the current working directory.
-# Used as a FetchContent PATCH_COMMAND; FetchContent runs it with the working
-# directory set to the dependency's populated source tree.
-#
-# Usage:
-# cmake -DPATCH=<absolute-path-to-.patch> -P git_apply_once.cmake
-#
-# If the patch already applies in reverse, it is considered applied and the
-# step is skipped, so re-running configure/populate does not fail.
-
-if(NOT DEFINED PATCH OR PATCH STREQUAL "")
- message(FATAL_ERROR "git_apply_once.cmake: PATCH argument is required")
-endif()
-
-if(NOT EXISTS "${PATCH}")
- message(FATAL_ERROR "git_apply_once.cmake: patch file does not exist: ${PATCH}")
-endif()
-
-find_package(Git QUIET REQUIRED)
-
-# Reverse-check succeeds only if the patch is already applied -> nothing to do.
-execute_process(
- COMMAND "${GIT_EXECUTABLE}" -c core.autocrlf=false apply
- --reverse --check --ignore-whitespace --ignore-space-change "${PATCH}"
- RESULT_VARIABLE _reverse_rc
- OUTPUT_QUIET
- ERROR_QUIET)
-
-if(_reverse_rc EQUAL 0)
- message(STATUS "git_apply_once: patch already applied: ${PATCH}")
- return()
-endif()
-
-execute_process(
- COMMAND "${GIT_EXECUTABLE}" -c core.autocrlf=false apply
- --ignore-whitespace --ignore-space-change "${PATCH}"
- RESULT_VARIABLE _apply_rc
- ERROR_VARIABLE _apply_err)
-
-if(NOT _apply_rc EQUAL 0)
- message(FATAL_ERROR "git_apply_once: failed to apply ${PATCH}:\n${_apply_err}")
-endif()
-
-message(STATUS "git_apply_once: applied patch: ${PATCH}")
diff --git a/thirdparty/protobuf/protobuf b/thirdparty/protobuf/protobuf
index 74211c0dfc2..d6511091a0c 160000
--- a/thirdparty/protobuf/protobuf
+++ b/thirdparty/protobuf/protobuf
@@ -1 +1 @@
-Subproject commit 74211c0dfc2777318ab53c2cd2c317a2ef9012de
+Subproject commit d6511091a0cab1ad13f676a02676ad2a0e5eb9ae
diff --git a/vcpkg.json b/vcpkg.json
index ebf8efbe3ab..79cd629d4bf 100644
--- a/vcpkg.json
+++ b/vcpkg.json
@@ -84,12 +84,12 @@
},
{
"name": "protobuf",
- "version>=": "6.31.1"
+ "version>=": "5.26.0"
},
{
"name": "protobuf",
"host": true,
- "version>=": "6.31.1"
+ "version>=": "5.26.0"
}
]
},