8000 Bump Protobuf to 6.31.0 by cyyever · Pull Request #147963 · pytorch/pytorch · GitHub
[go: up one dir, main page]

Skip to content

Bump Protobuf to 6.31.0 #147963

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ new_local_repository(

new_local_repository(
name = "opentelemetry-cpp",
build_file = "//third_party::opentelemetry-cpp.BUILD",
build_file = "//third_party:opentelemetry-cpp.BUILD",
path = "third_party/opentelemetry-cpp",
)

Expand Down
31 changes: 8 additions & 23 deletions cmake/Dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,6 @@ set(CMAKE_INSTALL_RPATH "${_rpath_portable_origin}")
# the rpath (per library?)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

# UBSAN triggers when compiling protobuf, so we need to disable it.
set(UBSAN_FLAG "-fsanitize=undefined")

macro(disable_ubsan)
if(CMAKE_C_FLAGS MATCHES ${UBSAN_FLAG} OR CMAKE_CXX_FLAGS MATCHES ${UBSAN_FLAG})
set(CAFFE2_UBSAN_ENABLED ON)
string(REPLACE ${UBSAN_FLAG} "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
string(REPLACE ${UBSAN_FLAG} "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
endif()
endmacro()

macro(enable_ubsan)
if(CAFFE2_UBSAN_ENABLED)
set(CMAKE_C_FLAGS "${UBSAN_FLAG} ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${UBSAN_FLAG} ${CMAKE_CXX_FLAGS}")
endif()
endmacro()

# ---[ CUDA
if(USE_CUDA)
# public/*.cmake uses CAFFE2_USE_*
Expand Down Expand Up @@ -103,9 +85,7 @@ endif()

# ---[ Custom Protobuf
if(CAFFE2_CMAKE_BUILDING_WITH_MAIN_REPO AND NOT INTERN_BUILD_MOBILE)
disable_ubsan()
include(${CMAKE_CURRENT_LIST_DIR}/ProtoBuf.cmake)
enable_ubsan()
endif()

if(USE_ASAN OR USE_TSAN)
Expand Down Expand Up @@ -546,6 +526,14 @@ if(USE_XNNPACK AND NOT USE_SYSTEM_XNNPACK)
set(XNNPACK_BUILD_WITH_LIBM OFF CACHE BOOL "")
endif()

# Update xnnpack memory target name. It has conflict with ProtoBuf.
if(NOT EXISTS "${XNNPACK_SOURCE_DIR}/CMakeLists.txt.tag")
file(READ "${XNNPACK_SOURCE_DIR}/CMakeLists.txt" FILE_CONTENTS)
string(REPLACE "memory " "xnnpack_memory " FILE_CONTENTS "${FILE_CONTENTS}")
file(WRITE "${XNNPACK_SOURCE_DIR}/CMakeLists.txt" "${FILE_CONTENTS}")
file(WRITE "${XNNPACK_SOURCE_DIR}/CMakeLists.txt.tag" "xnnpack_memory")
endif()

add_subdirectory(
"${XNNPACK_SOURCE_DIR}"
"${CONFU_DEPENDENCIES_BINARY_DIR}/XNNPACK")
Expand Down Expand Up @@ -1270,9 +1258,6 @@ if(CAFFE2_CMAKE_BUILDING_WITH_MAIN_REPO AND NOT INTERN_DISABLE_ONNX)
# If linking local protobuf, make sure ONNX has the same protobuf
# patches as Caffe2 and Caffe proto. This forces some functions to
# not be inline and instead route back to the statically-linked protobuf.
if(CAFFE2_LINK_LOCAL_PROTOBUF)
set(ONNX_PROTO_POST_BUILD_SCRIPT ${PROJECT_SOURCE_DIR}/cmake/ProtoBufPatch.cmake)
endif()
if(ONNX_ML)
add_definitions(-DONNX_ML=1)
endif()
Expand Down
48 changes: 14 additions & 34 deletions cmake/ProtoBuf.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,17 @@
# the standard cmake script with version and python generation support
macro(custom_protobuf_find)
message(STATUS "Use custom protobuf build.")
option(protobuf_BUILD_TESTS "" OFF)
option(protobuf_BUILD_EXAMPLES "" OFF)
option(protobuf_WITH_ZLIB "" OFF)
set(ABSL_BUILD_TESTING OFF)
set(ABSL_ENABLE_INSTALL OFF)
set(ABSL_PROPAGATE_CXX_STD ON)
set(protobuf_FORCE_FETCH_DEPENDENCIES ON)
set(protobuf_BUILD_TESTS OFF)
set(protobuf_BUILD_EXAMPLES OFF)
set(protobuf_WITH_ZLIB OFF)
set(__caffe2_CMAKE_POSITION_INDEPENDENT_CODE ${CMAKE_POSITION_INDEPENDENT_CODE})
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(__caffe2_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
set(BUILD_SHARED_LIBS OFF)
if(${CAFFE2_LINK_LOCAL_PROTOBUF})
# If we are going to link protobuf locally, we will need to turn off
# shared libs build for protobuf.
Expand All @@ -18,10 +26,7 @@ macro(custom_protobuf_find)
option(protobuf_MSVC_STATIC_RUNTIME "" ${CAFFE2_USE_MSVC_STATIC_RUNTIME})

if(${CAFFE2_LINK_LOCAL_PROTOBUF})
set(__caffe2_CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ${CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS})
set(__caffe2_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS OFF)
set(BUILD_SHARED_LIBS OFF)
if(${COMPILER_SUPPORTS_HIDDEN_VISIBILITY})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
endif()
Expand All @@ -30,9 +35,6 @@ macro(custom_protobuf_find)
endif()
endif()

set(__caffe2_CMAKE_POSITION_INDEPENDENT_CODE ${CMAKE_POSITION_INDEPENDENT_CODE})
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

if(MSVC)
foreach(flag_var
CMAKE_C_FLAGS CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_MINSIZEREL
Expand All @@ -52,35 +54,13 @@ macro(custom_protobuf_find)
endif(MSVC_Z7_OVERRIDE)
endif(MSVC)

if(CMAKE_VERSION VERSION_GREATER_EQUAL "4.0.0")
message(WARNING "Ancient protobuf forces CMake compatibility")
set(CMAKE_POLICY_VERSION_MINIMUM 3.5)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../third_party/protobuf/cmake)
unset(CMAKE_POLICY_VERSION_MINIMUM)
else()
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../third_party/protobuf/cmake)
endif()

set(CMAKE_POSITION_INDEPENDENT_CODE ${__caffe2_CMAKE_POSITION_INDEPENDENT_CODE})
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../third_party/protobuf)

if(${CAFFE2_LINK_LOCAL_PROTOBUF})
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ${__caffe2_CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS})
set(BUILD_SHARED_LIBS ON)
set(CMAKE_CXX_FLAGS ${__caffe2_CMAKE_CXX_FLAGS})
endif()

# Protobuf "namespaced" target is only added post protobuf 3.5.1. As a
# result, for older versions, we will manually add alias.
if(NOT TARGET protobuf::libprotobuf)
add_library(protobuf::libprotobuf ALIAS libprotobuf)
add_library(protobuf::libprotobuf-lite ALIAS libprotobuf-lite)
# There is link error when cross compiling protoc on mobile:
# https://github.com/protocolbuffers/protobuf/issues/2719
# And protoc is very unlikely needed for mobile builds.
if(NOT (ANDROID OR IOS))
add_executable(protobuf::protoc ALIAS protoc)
endif()
endif()
set(BUILD_SHARED_LIBS ${__caffe2_BUILD_SHARED_LIBS})
set(CMAKE_POSITION_INDEPENDENT_CODE ${__caffe2_CMAKE_POSITION_INDEPENDENT_CODE})
endmacro()

# Main entry for protobuf. If we are building on Android, iOS or we have hard
Expand Down
100 changes: 0 additions & 100 deletions cmake/ProtoBufPatch.cmake

This file was deleted.

2 changes: 1 addition & 1 deletion third_party/onnx
Submodule onnx updated 153 files
2 changes: 1 addition & 1 deletion third_party/protobuf
Submodule protobuf updated 4037 files
Loading
0