Skip to content

Commit d15998f

Browse files
committed
CVS-171145 Update Protobuf to 4.25.1
- Solution revised by Copilot
1 parent ffdeb83 commit d15998f

3 files changed

Lines changed: 24 additions & 63 deletions

File tree

cmake/developer_package/frontends/frontends.cmake

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -99,22 +99,6 @@ macro(ov_frontend_group_files root_dir rel_path file_mask)
9999
endforeach()
100100
endmacro()
101101

102-
#
103-
# ov_suppress_version_dependent_warnings(TARGET_NAME)
104-
#
105-
# Suppress version dependent warnings in third-party libraries for specific compilers
106-
#
107-
function(ov_suppress_version_dependent_warnings target_name)
108-
# Required for abseil lts_20230802 and GCC 14
109-
# Remove once abseil is updated to a newer version
110-
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
111-
target_compile_options(${target_name} PRIVATE
112-
-Wno-error=array-bounds
113-
-Wno-error=stringop-overflow
114-
)
115-
endif()
116-
endfunction()
117-
118102
#
119103
# ov_add_frontend(NAME <IR|ONNX|...>
120104
# FILEDESCRIPTION <description> # used on Windows to describe DLL file
@@ -335,7 +319,14 @@ macro(ov_add_frontend)
335319
endif()
336320

337321
ov_link_system_libraries(${TARGET_NAME} PRIVATE ${protobuf_target_name})
338-
ov_suppress_version_dependent_warnings(${TARGET_NAME})
322+
323+
# GCC emits -Warray-bounds / -Wstringop-overflow even from SYSTEM includes
324+
# when instantiating header-only abseil code inside frontend translation units.
325+
# With -Werror these become hard errors; downgrade to warnings here.
326+
if(CMAKE_COMPILER_IS_GNUCXX)
327+
target_compile_options(${TARGET_NAME} PRIVATE
328+
-Wno-error=array-bounds -Wno-error=stringop-overflow)
329+
endif()
339330

340331
# protobuf generated code emits -Wsuggest-override error
341332
if(SUGGEST_OVERRIDE_SUPPORTED)

thirdparty/dependencies.cmake

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -401,15 +401,6 @@ if(ENABLE_OV_PADDLE_FRONTEND OR ENABLE_OV_ONNX_FRONTEND OR ENABLE_OV_TF_FRONTEND
401401
endif()
402402
else()
403403
add_subdirectory(thirdparty/protobuf EXCLUDE_FROM_ALL)
404-
# protobuf fails to build with -fsanitize=thread by clang
405-
if(ENABLE_THREAD_SANITIZER AND OV_COMPILER_IS_CLANG)
406-
foreach(proto_target protoc libprotobuf libprotobuf-lite)
407-
if(TARGET ${proto_target})
408-
target_compile_options(${proto_target} PRIVATE -fno-sanitize=thread)
409-
target_link_options(${proto_target} PRIVATE -fno-sanitize=thread)
410-
endif()
411-
endforeach()
412-
endif()
413404
endif()
414405

415406
# forward additional variables used in the other places
@@ -435,30 +426,6 @@ if(ENABLE_OV_PADDLE_FRONTEND OR ENABLE_OV_ONNX_FRONTEND OR ENABLE_OV_TF_FRONTEND
435426

436427
_ov_fix_protobuf_warnings(protobuf::libprotobuf)
437428
_ov_fix_protobuf_warnings(protobuf::libprotobuf-lite)
438-
439-
function(_ov_fix_absl_warnings target_name)
440-
if(TARGET ${target_name})
441-
if(CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG OR (OV_COMPILER_IS_INTEL_LLVM AND UNIX))
442-
set(link_type PRIVATE)
443-
get_target_property(target_type ${target_name} TYPE)
444-
if(target_type STREQUAL "INTERFACE_LIBRARY")
445-
set(link_type INTERFACE)
446-
endif()
447-
448-
get_target_property(original_name ${target_name} ALIASED_TARGET)
449-
if(TARGET ${original_name})
450-
set(target_name ${original_name})
451-
endif()
452-
453-
target_compile_options(${target_name} ${link_type} -Wno-sign-conversion)
454-
endif()
455-
endif()
456-
endfunction()
457-
458-
_ov_fix_absl_warnings(absl::base)
459-
_ov_fix_absl_warnings(absl::debugging)
460-
_ov_fix_absl_warnings(absl::malloc_internal)
461-
_ov_fix_absl_warnings(absl::stacktrace)
462429
endif()
463430

464431
#

thirdparty/protobuf/CMakeLists.txt

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,14 @@ set(BUILD_SHARED_LIBS OFF)
1515

1616
if(CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG OR (OV_COMPILER_IS_INTEL_LLVM AND UNIX))
1717
ov_add_compiler_flags(-Wno-all)
18-
# GCC (any version) may emit "overflow in constant expression" for the
19-
# static_assert in abseil's ascii.cc when evaluating static_cast<char>(i)
20-
# for i >= 128 in a constexpr context. -fpermissive downgrades it from
21-
# a hard error to a warning (GCC >= 12 only). For GCC < 12, -fpermissive
22-
# does NOT affect static_assert, so we additionally use -funsigned-char
23-
# which makes char unsigned — then static_cast<char>(i) for i < 256 is
24-
# always in-range and the constexpr evaluator accepts it on all versions.
25-
ov_add_compiler_flags(-fpermissive)
2618
if(CMAKE_COMPILER_IS_GNUCXX)
19+
# GCC may emit "non-constant condition for static assertion" in abseil's
20+
# ascii.cc because static_cast<char>(i) for i >= 128 is implementation-
21+
# defined when char is signed, and older GCC constexpr evaluators reject
22+
# it. -fpermissive downgrades it to a warning on GCC >= 12.
23+
# -funsigned-char makes char unsigned so the cast is always in-range,
24+
# fixing all GCC versions.
25+
ov_add_compiler_flags(-fpermissive)
2726
ov_add_compiler_flags(-funsigned-char)
2827
endif()
2928
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 11 AND CMAKE_COMPILER_IS_GNUCXX)
@@ -125,12 +124,16 @@ if(CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG OR OV_COMPILER_IS_INTEL_LLVM
125124
C_VISIBILITY_PRESET default
126125
VISIBILITY_INLINES_HIDDEN OFF
127126
INTERPROCEDURAL_OPTIMIZATION_RELEASE OFF)
128-
if(ENABLE_THREAD_SANITIZER)
129-
foreach(_lib ${_protoc_libs})
127+
endif()
128+
# Disable thread sanitizer for all protobuf/abseil targets — protobuf
129+
# is incompatible with -fsanitize=thread (especially under clang).
130+
if(ENABLE_THREAD_SANITIZER)
131+
foreach(_lib protoc libprotoc libprotobuf libprotobuf-lite)
132+
if(TARGET ${_lib})
130133
target_compile_options(${_lib} PRIVATE -fno-sanitize=thread)
131-
endforeach()
132-
target_link_options(protoc PRIVATE -fno-sanitize=thread)
133-
endif()
134+
target_link_options(${_lib} PRIVATE -fno-sanitize=thread)
135+
endif()
136+
endforeach()
134137
endif()
135138
ov_disable_all_warnings(${_protoc_libs} libprotobuf-lite)
136139
set_target_properties(libprotobuf-lite PROPERTIES

0 commit comments

Comments
 (0)