From e24056c1c09eecace5197feb813fe29e19e30ede Mon Sep 17 00:00:00 2001
From: zhangxiaoyu <zhangxiaoyu58@huawei.com>
Date: Tue, 11 Jan 2022 10:00:37 +0800
Subject: [PATCH] fix compile error with grpc 1.41.x

Signed-off-by: zhangxiaoyu <zhangxiaoyu58@huawei.com>
---
 cmake/checker.cmake | 2 ++
 src/CMakeLists.txt  | 9 +++++++++
 2 files changed, 11 insertions(+)

diff --git a/cmake/checker.cmake b/cmake/checker.cmake
index 17a324f6..946ee730 100644
--- a/cmake/checker.cmake
+++ b/cmake/checker.cmake
@@ -147,6 +147,8 @@ if (GRPC_CONNECTOR OR ENABLE_OCI_IMAGE)
     _CHECK(GRPC_LIBRARY "GRPC_LIBRARY-NOTFOUND" "libgrpc.so")
     find_library(GPR_LIBRARY gpr)
     _CHECK(GPR_LIBRARY "GPR_LIBRARY-NOTFOUND" "libgpr.so")
+    # no check
+    find_library(ABSL_SYNC_LIB absl_synchronization)
 
     # check devmapper
     find_path(DEVMAPPER_INCLUDE_DIR libdevmapper.h)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 1401784b..30f451d4 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -95,6 +95,9 @@ if (GRPC_CONNECTOR)
     target_link_libraries(libisula -Wl,--as-needed -lstdc++)
     target_link_libraries(libisula -Wl,--as-needed ${PROTOBUF_LIBRARY})
     target_link_libraries(libisula -Wl,--no-as-needed ${GRPC_PP_REFLECTION_LIBRARY} ${GRPC_PP_LIBRARY} ${GRPC_LIBRARY} ${GPR_LIBRARY})
+    if(ABSL_SYNC_LIB)
+        target_link_libraries(libisula -Wl,--no-as-needed ${ABSL_SYNC_LIB})
+    endif()
 else()
     target_link_libraries(libisula ${EVHTP_LIBRARY} ${EVENT_LIBRARY} ${ZLIB_LIBRARY} -ldl libhttpclient)
 endif()
@@ -167,6 +170,9 @@ if (GRPC_CONNECTOR)
     target_link_libraries(isulad -Wl,--as-needed -lstdc++)
     target_link_libraries(isulad -Wl,--as-needed ${PROTOBUF_LIBRARY})
     target_link_libraries(isulad -Wl,--no-as-needed ${GRPC_PP_REFLECTION_LIBRARY} ${GRPC_PP_LIBRARY} ${GRPC_LIBRARY} ${GPR_LIBRARY})
+    if(ABSL_SYNC_LIB)
+        target_link_libraries(isulad -Wl,--no-as-needed ${ABSL_SYNC_LIB})
+    endif()
     target_link_libraries(isulad ${CLIBCNI_LIBRARY})
 else()
     message("Restful iSulad")
@@ -182,6 +188,9 @@ if (ENABLE_OCI_IMAGE)
     target_link_libraries(isulad -Wl,--as-needed -ldevmapper)
     target_link_libraries(isulad -Wl,--as-needed ${PROTOBUF_LIBRARY})
     target_link_libraries(isulad -Wl,--no-as-needed ${GRPC_PP_REFLECTION_LIBRARY} ${GRPC_PP_LIBRARY} ${GRPC_LIBRARY} ${GPR_LIBRARY})
+    if(ABSL_SYNC_LIB)
+        target_link_libraries(isulad -Wl,--no-as-needed ${ABSL_SYNC_LIB})
+    endif()
 endif()
 
 if (ISULAD_GCOV)
-- 
2.25.1

