1 Star 0 Fork 44

严莹/iSulad

forked from src-openEuler/iSulad 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0002-fix-compile-error-with-protobuf-25.1-and-grpc-1.60.x.patch 12.31 KB
一键复制 编辑 原始数据 按行查看 历史
jake 提交于 2024-04-02 11:50 . upgrade from upstream
From 71f8d4accbec5153b362281bbaf9a516ccd083f5 Mon Sep 17 00:00:00 2001
From: zhongtao <zhongtao17@huawei.com>
Date: Mon, 22 Jan 2024 15:55:16 +0800
Subject: [PATCH 02/43] fix compile error with protobuf 25.1 and grpc 1.60.x
Signed-off-by: zhongtao <zhongtao17@huawei.com>
---
cmake/checker.cmake | 76 +++++++++++++++++++
cmake/protoc.cmake | 3 -
src/CMakeLists.txt | 12 +--
.../sandbox/controller/manager/CMakeLists.txt | 4 +-
.../sandboxer/async_wait_call/CMakeLists.txt | 4 +-
.../sandboxer/sandboxer_client/CMakeLists.txt | 4 +-
.../sandboxer_controller/CMakeLists.txt | 4 +-
test/sandbox/controller/shim/CMakeLists.txt | 4 +-
test/sandbox/sandbox/CMakeLists.txt | 4 +-
test/sandbox/sandbox_manager/CMakeLists.txt | 4 +-
10 files changed, 87 insertions(+), 32 deletions(-)
diff --git a/cmake/checker.cmake b/cmake/checker.cmake
index e19618e4..b0c395ef 100644
--- a/cmake/checker.cmake
+++ b/cmake/checker.cmake
@@ -154,7 +154,83 @@ if (GRPC_CONNECTOR)
find_library(GPR_LIBRARY gpr)
_CHECK(GPR_LIBRARY "GPR_LIBRARY-NOTFOUND" "libgpr.so")
# no check
+
+ # The use of absl libraries depends on the version of protobuf and grpc.
+ # Versions of protobuf before v22.0 do not require absl libraries at all.
+ # However, versions after v22.0 require the support of absl libraries.
+ # As a result, we skip the check for absl libraries in order to accommodate different protobuf and grpc versions.
+ set(ISULAD_ABSL_USED_TARGETS)
find_library(ABSL_SYNC_LIB absl_synchronization)
+ if (ABSL_SYNC_LIB)
+ set(ISULAD_ABSL_USED_TARGETS
+ ${ISULAD_ABSL_USED_TARGETS}
+ ${ABSL_SYNC_LIB}
+ )
+ endif()
+
+ find_library(ABSL_CORD_LIB absl_cord)
+ if (ABSL_CORD_LIB)
+ set(ISULAD_ABSL_USED_TARGETS
+ ${ISULAD_ABSL_USED_TARGETS}
+ ${ABSL_CORD_LIB}
+ )
+ endif()
+
+ find_library(ABSL_CORDZ_FUNCTIONS_LIB absl_cordz_functions)
+ if (ABSL_CORDZ_FUNCTIONS_LIB)
+ set(ISULAD_ABSL_USED_TARGETS
+ ${ISULAD_ABSL_USED_TARGETS}
+ ${ABSL_CORDZ_FUNCTIONS_LIB}
+ )
+ endif()
+
+ find_library(ABSL_CORDZ_INFO_LIB absl_cordz_info)
+ if (ABSL_CORDZ_INFO_LIB)
+ set(ISULAD_ABSL_USED_TARGETS
+ ${ISULAD_ABSL_USED_TARGETS}
+ ${ABSL_CORDZ_INFO_LIB}
+ )
+ endif()
+
+ find_library(ABSL_HASH_LIB absl_hash)
+ if (ABSL_HASH_LIB)
+ set(ISULAD_ABSL_USED_TARGETS
+ ${ISULAD_ABSL_USED_TARGETS}
+ ${ABSL_HASH_LIB}
+ )
+ endif()
+
+ find_library(ABSL_LOG_INTERNAL_CHECK_OP_LIB absl_log_internal_check_op)
+ if (ABSL_LOG_INTERNAL_CHECK_OP_LIB)
+ set(ISULAD_ABSL_USED_TARGETS
+ ${ISULAD_ABSL_USED_TARGETS}
+ ${ABSL_LOG_INTERNAL_CHECK_OP_LIB}
+ )
+ endif()
+
+ find_library(ABSL_LOG_INTERNAL_MESSAGE_LIB absl_log_internal_message)
+ if (ABSL_LOG_INTERNAL_MESSAGE_LIB)
+ set(ISULAD_ABSL_USED_TARGETS
+ ${ISULAD_ABSL_USED_TARGETS}
+ ${ABSL_LOG_INTERNAL_MESSAGE_LIB}
+ )
+ endif()
+
+ find_library(ABSL_LOG_INTERNAL_NULLGUARD_LIB absl_log_internal_nullguard)
+ if (ABSL_LOG_INTERNAL_NULLGUARD_LIB)
+ set(ISULAD_ABSL_USED_TARGETS
+ ${ISULAD_ABSL_USED_TARGETS}
+ ${ABSL_LOG_INTERNAL_NULLGUARD_LIB}
+ )
+ endif()
+
+ find_library(ABSL_STATUS_LIB absl_status)
+ if (ABSL_STATUS_LIB)
+ set(ISULAD_ABSL_USED_TARGETS
+ ${ISULAD_ABSL_USED_TARGETS}
+ ${ABSL_STATUS_LIB}
+ )
+ endif()
# check websocket
find_path(WEBSOCKET_INCLUDE_DIR libwebsockets.h)
diff --git a/cmake/protoc.cmake b/cmake/protoc.cmake
index 80c08687..6e2d1b84 100644
--- a/cmake/protoc.cmake
+++ b/cmake/protoc.cmake
@@ -69,9 +69,6 @@ endif()
if (ENABLE_CRI_API_V1 AND ENABLE_SANDBOXER)
execute_process(COMMAND mkdir -p ${SANDBOX_PROTOS_OUT_PATH})
- PROTOC_CPP_GEN(sandbox ${SANDBOX_PROTOS_OUT_PATH} ${PROTOS_PATH}/sandbox/google/protobuf/any.proto)
- PROTOC_CPP_GEN(sandbox ${SANDBOX_PROTOS_OUT_PATH} ${PROTOS_PATH}/sandbox/google/protobuf/empty.proto)
- PROTOC_CPP_GEN(sandbox ${SANDBOX_PROTOS_OUT_PATH} ${PROTOS_PATH}/sandbox/google/protobuf/timestamp.proto)
PROTOC_CPP_GEN(sandbox ${SANDBOX_PROTOS_OUT_PATH} ${PROTOS_PATH}/sandbox/sandbox/types/sandbox.proto)
PROTOC_CPP_GEN(sandbox ${SANDBOX_PROTOS_OUT_PATH} ${PROTOS_PATH}/sandbox/sandbox/types/mount.proto)
PROTOC_CPP_GEN(sandbox ${SANDBOX_PROTOS_OUT_PATH} ${PROTOS_PATH}/sandbox/sandbox/types/platform.proto)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 860447de..d1bc65f9 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -85,10 +85,8 @@ target_link_libraries(libisula_client libisulad_tools)
if (GRPC_CONNECTOR)
target_link_libraries(libisula_client -Wl,--as-needed -lstdc++)
target_link_libraries(libisula_client -Wl,--as-needed ${PROTOBUF_LIBRARY})
- target_link_libraries(libisula_client -Wl,--no-as-needed ${GRPC_PP_REFLECTION_LIBRARY} ${GRPC_PP_LIBRARY} ${GRPC_LIBRARY} ${GPR_LIBRARY})
- if(ABSL_SYNC_LIB)
- target_link_libraries(libisula_client -Wl,--no-as-needed ${ABSL_SYNC_LIB})
- endif()
+ target_link_libraries(libisula_client -Wl,--as-needed ${GRPC_PP_REFLECTION_LIBRARY} ${GRPC_PP_LIBRARY} ${GRPC_LIBRARY} ${GPR_LIBRARY})
+ target_link_libraries(libisula_client -Wl,--as-needed ${ISULAD_ABSL_USED_TARGETS})
else()
target_link_libraries(libisula_client -ldl libhttpclient)
set_target_properties(libisula_client PROPERTIES LINKER_LANGUAGE "C")
@@ -182,13 +180,11 @@ endif()
if (GRPC_CONNECTOR)
target_link_libraries(isulad -Wl,--as-needed -lstdc++)
target_link_libraries(isulad -Wl,--as-needed ${WEBSOCKET_LIBRARY} ${PROTOBUF_LIBRARY})
- target_link_libraries(isulad -Wl,--no-as-needed ${GRPC_PP_REFLECTION_LIBRARY} ${GRPC_PP_LIBRARY} ${GRPC_LIBRARY} ${GPR_LIBRARY})
+ target_link_libraries(isulad -Wl,--as-needed ${GRPC_PP_REFLECTION_LIBRARY} ${GRPC_PP_LIBRARY} ${GRPC_LIBRARY} ${GPR_LIBRARY})
if (ENABLE_METRICS)
target_link_libraries(isulad ${EVHTP_LIBRARY} ${EVENT_LIBRARY})
endif()
- if(ABSL_SYNC_LIB)
- target_link_libraries(isulad -Wl,--no-as-needed ${ABSL_SYNC_LIB})
- endif()
+ target_link_libraries(isulad -Wl,--as-needed ${ISULAD_ABSL_USED_TARGETS})
else()
message("Restful iSulad")
target_link_libraries(isulad ${EVHTP_LIBRARY} ${EVENT_LIBRARY})
diff --git a/test/sandbox/controller/manager/CMakeLists.txt b/test/sandbox/controller/manager/CMakeLists.txt
index 3724538e..6e8c9052 100644
--- a/test/sandbox/controller/manager/CMakeLists.txt
+++ b/test/sandbox/controller/manager/CMakeLists.txt
@@ -40,8 +40,6 @@ target_include_directories(${EXE} PUBLIC
)
target_link_libraries(${EXE} ${GTEST_BOTH_LIBRARIES} ${GMOCK_LIBRARY} ${GMOCK_MAIN_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${ISULA_LIBUTILS_LIBRARY} libutils_ut -lgrpc -lgrpc++ -lprotobuf -lcrypto -lyajl -lz)
-if(ABSL_SYNC_LIB)
- target_link_libraries(${EXE} -Wl,--no-as-needed ${ABSL_SYNC_LIB})
-endif()
+target_link_libraries(${EXE} -Wl,--as-needed ${ISULAD_ABSL_USED_TARGETS})
add_test(NAME ${EXE} COMMAND ${EXE} --gtest_output=xml:${EXE}-Results.xml)
set_tests_properties(${EXE} PROPERTIES TIMEOUT 120)
diff --git a/test/sandbox/controller/sandboxer/async_wait_call/CMakeLists.txt b/test/sandbox/controller/sandboxer/async_wait_call/CMakeLists.txt
index c8eb803e..0631988a 100644
--- a/test/sandbox/controller/sandboxer/async_wait_call/CMakeLists.txt
+++ b/test/sandbox/controller/sandboxer/async_wait_call/CMakeLists.txt
@@ -32,8 +32,6 @@ target_include_directories(${EXE} PUBLIC
)
target_link_libraries(${EXE} ${GTEST_BOTH_LIBRARIES} ${GMOCK_LIBRARY} ${GMOCK_MAIN_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${ISULA_LIBUTILS_LIBRARY} libutils_ut -lgrpc -lgrpc++ -lprotobuf -lcrypto -lyajl -lz)
-if(ABSL_SYNC_LIB)
- target_link_libraries(${EXE} -Wl,--no-as-needed ${ABSL_SYNC_LIB})
-endif()
+target_link_libraries(${EXE} -Wl,--as-needed ${ISULAD_ABSL_USED_TARGETS})
add_test(NAME ${EXE} COMMAND ${EXE} --gtest_output=xml:${EXE}-Results.xml)
set_tests_properties(${EXE} PROPERTIES TIMEOUT 120)
diff --git a/test/sandbox/controller/sandboxer/sandboxer_client/CMakeLists.txt b/test/sandbox/controller/sandboxer/sandboxer_client/CMakeLists.txt
index 91f26883..881797c6 100644
--- a/test/sandbox/controller/sandboxer/sandboxer_client/CMakeLists.txt
+++ b/test/sandbox/controller/sandboxer/sandboxer_client/CMakeLists.txt
@@ -36,8 +36,6 @@ target_include_directories(${EXE} PUBLIC
)
target_link_libraries(${EXE} ${GTEST_BOTH_LIBRARIES} ${GMOCK_LIBRARY} ${GMOCK_MAIN_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${ISULA_LIBUTILS_LIBRARY} libutils_ut -lgrpc -lgrpc++ -lprotobuf -lcrypto -lyajl -lz)
-if(ABSL_SYNC_LIB)
- target_link_libraries(${EXE} -Wl,--no-as-needed ${ABSL_SYNC_LIB})
-endif()
+target_link_libraries(${EXE} -Wl,--as-needed ${ISULAD_ABSL_USED_TARGETS})
add_test(NAME ${EXE} COMMAND ${EXE} --gtest_output=xml:${EXE}-Results.xml)
set_tests_properties(${EXE} PROPERTIES TIMEOUT 120)
diff --git a/test/sandbox/controller/sandboxer/sandboxer_controller/CMakeLists.txt b/test/sandbox/controller/sandboxer/sandboxer_controller/CMakeLists.txt
index d38392e0..963ce9a5 100644
--- a/test/sandbox/controller/sandboxer/sandboxer_controller/CMakeLists.txt
+++ b/test/sandbox/controller/sandboxer/sandboxer_controller/CMakeLists.txt
@@ -33,8 +33,6 @@ target_include_directories(${EXE} PUBLIC
)
target_link_libraries(${EXE} ${GTEST_BOTH_LIBRARIES} ${GMOCK_LIBRARY} ${GMOCK_MAIN_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${ISULA_LIBUTILS_LIBRARY} libutils_ut -lgrpc -lgrpc++ -lprotobuf -lcrypto -lyajl -lz)
-if(ABSL_SYNC_LIB)
- target_link_libraries(${EXE} -Wl,--no-as-needed ${ABSL_SYNC_LIB})
-endif()
+target_link_libraries(${EXE} -Wl,--as-needed ${ISULAD_ABSL_USED_TARGETS})
add_test(NAME ${EXE} COMMAND ${EXE} --gtest_output=xml:${EXE}-Results.xml)
set_tests_properties(${EXE} PROPERTIES TIMEOUT 120)
diff --git a/test/sandbox/controller/shim/CMakeLists.txt b/test/sandbox/controller/shim/CMakeLists.txt
index af066546..6423bb80 100644
--- a/test/sandbox/controller/shim/CMakeLists.txt
+++ b/test/sandbox/controller/shim/CMakeLists.txt
@@ -50,8 +50,6 @@ target_include_directories(${EXE} PUBLIC
)
target_link_libraries(${EXE} ${GTEST_BOTH_LIBRARIES} ${GMOCK_LIBRARY} ${GMOCK_MAIN_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${ISULA_LIBUTILS_LIBRARY} libutils_ut -lgrpc++ -lprotobuf -lcrypto -lyajl -lz)
-if(ABSL_SYNC_LIB)
- target_link_libraries(${EXE} -Wl,--no-as-needed ${ABSL_SYNC_LIB})
-endif()
+target_link_libraries(${EXE} -Wl,--as-needed ${ISULAD_ABSL_USED_TARGETS})
add_test(NAME ${EXE} COMMAND ${EXE} --gtest_output=xml:${EXE}-Results.xml)
set_tests_properties(${EXE} PROPERTIES TIMEOUT 120)
diff --git a/test/sandbox/sandbox/CMakeLists.txt b/test/sandbox/sandbox/CMakeLists.txt
index efcc2bdc..138d4d8d 100644
--- a/test/sandbox/sandbox/CMakeLists.txt
+++ b/test/sandbox/sandbox/CMakeLists.txt
@@ -48,8 +48,6 @@ target_include_directories(${EXE} PUBLIC
)
target_link_libraries(${EXE} ${GTEST_BOTH_LIBRARIES} ${GMOCK_LIBRARY} ${GMOCK_MAIN_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${ISULA_LIBUTILS_LIBRARY} libutils_ut -lgrpc -lgrpc++ -lprotobuf -lcrypto -lyajl -lz)
-if(ABSL_SYNC_LIB)
- target_link_libraries(${EXE} -Wl,--no-as-needed ${ABSL_SYNC_LIB})
-endif()
+target_link_libraries(${EXE} -Wl,--as-needed ${ISULAD_ABSL_USED_TARGETS})
add_test(NAME ${EXE} COMMAND ${EXE} --gtest_output=xml:${EXE}-Results.xml)
set_tests_properties(${EXE} PROPERTIES TIMEOUT 120)
diff --git a/test/sandbox/sandbox_manager/CMakeLists.txt b/test/sandbox/sandbox_manager/CMakeLists.txt
index f43b0f97..5a7cb2ea 100644
--- a/test/sandbox/sandbox_manager/CMakeLists.txt
+++ b/test/sandbox/sandbox_manager/CMakeLists.txt
@@ -48,8 +48,6 @@ target_include_directories(${EXE} PUBLIC
)
set_target_properties(${EXE} PROPERTIES LINK_FLAGS "-Wl,--wrap,util_list_all_subdir")
target_link_libraries(${EXE} ${GTEST_BOTH_LIBRARIES} ${GMOCK_LIBRARY} ${GMOCK_MAIN_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${ISULA_LIBUTILS_LIBRARY} libutils_ut -lgrpc -lgrpc++ -lprotobuf -lcrypto -lyajl -lz)
-if(ABSL_SYNC_LIB)
- target_link_libraries(${EXE} -Wl,--no-as-needed ${ABSL_SYNC_LIB})
-endif()
+target_link_libraries(${EXE} -Wl,--as-needed ${ISULAD_ABSL_USED_TARGETS})
add_test(NAME ${EXE} COMMAND ${EXE} --gtest_output=xml:${EXE}-Results.xml)
set_tests_properties(${EXE} PROPERTIES TIMEOUT 120)
--
2.34.1
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yanyir/iSulad.git
git@gitee.com:yanyir/iSulad.git
yanyir
iSulad
iSulad
master

搜索帮助