fix the link issue on grpc

This commit is contained in:
Sylvestre Ledru 2022-12-27 12:43:58 +01:00
parent 3d813bd71a
commit 060f11df25
2 changed files with 50 additions and 0 deletions

49
debian/patches/link-grpc.diff vendored Normal file
View File

@ -0,0 +1,49 @@
Index: llvm-toolchain-snapshot_16~++20221227120055+36d70a6aea6b/cmake/Modules/FindGRPC.cmake
===================================================================
--- llvm-toolchain-snapshot_16~++20221227120055+36d70a6aea6b.orig/cmake/Modules/FindGRPC.cmake
+++ llvm-toolchain-snapshot_16~++20221227120055+36d70a6aea6b/cmake/Modules/FindGRPC.cmake
@@ -82,11 +82,30 @@ else()
endif()
endif()
if(NOT TARGET grpc++)
- find_library(GRPC_LIBRARY grpc++ ${GRPC_OPTS} REQUIRED)
+ find_library(GRPCPP_LIBRARY grpc++ ${GRPC_OPTS} REQUIRED)
add_library(grpc++ UNKNOWN IMPORTED GLOBAL)
- message(STATUS "Using grpc++: " ${GRPC_LIBRARY})
- set_target_properties(grpc++ PROPERTIES IMPORTED_LOCATION ${GRPC_LIBRARY})
+ message(STATUS "Using grpc++: " ${GRPCPP_LIBRARY})
+ set_target_properties(grpc++ PROPERTIES IMPORTED_LOCATION ${GRPCPP_LIBRARY})
target_include_directories(grpc++ INTERFACE ${GRPC_INCLUDE_PATHS})
+
+ # On some distro (ex: Debian/Ubuntu), libgrpc++ doesn't have direct references
+ # to it dependencies. Needs to link against gpr, grpc and absl_synchronization
+ find_library(GPR_LIBRARY gpr ${GRPC_OPTS} REQUIRED)
+ add_library(gpr UNKNOWN IMPORTED GLOBAL)
+ message(STATUS "Using gpr: " ${GPR_LIBRARY})
+ set_target_properties(gpr PROPERTIES IMPORTED_LOCATION ${GPR_LIBRARY})
+
+ find_library(GRPC_LIBRARY grpc ${GRPC_OPTS} REQUIRED)
+ add_library(grpc UNKNOWN IMPORTED GLOBAL)
+ message(STATUS "Using grpc: " ${GRPC_LIBRARY})
+ set_target_properties(grpc PROPERTIES IMPORTED_LOCATION ${GRPC_LIBRARY})
+
+ find_library(ABSL_SYNCHRONIZATION_LIBRARY absl_synchronization ${GRPC_OPTS} REQUIRED)
+ add_library(absl_synchronization UNKNOWN IMPORTED GLOBAL)
+ message(STATUS "Using absl_synchronization: " ${ABSL_SYNCHRONIZATION})
+ set_target_properties(absl_synchronization PROPERTIES IMPORTED_LOCATION ${ABSL_SYNCHRONIZATION_LIBRARY})
+
+
if (ENABLE_GRPC_REFLECTION)
find_library(GRPC_REFLECTION_LIBRARY grpc++_reflection ${GRPC_OPTS} REQUIRED)
add_library(grpc++_reflection UNKNOWN IMPORTED GLOBAL)
Index: llvm-toolchain-snapshot_16~++20221227120055+36d70a6aea6b/clang/cmake/modules/AddGRPC.cmake
===================================================================
--- llvm-toolchain-snapshot_16~++20221227120055+36d70a6aea6b.orig/clang/cmake/modules/AddGRPC.cmake
+++ llvm-toolchain-snapshot_16~++20221227120055+36d70a6aea6b/clang/cmake/modules/AddGRPC.cmake
@@ -7,5 +7,5 @@ function(generate_clang_protos_library L
add_clang_library(${LibraryName} ${ProtoSource}
PARTIAL_SOURCES_INTENDED
- LINK_LIBS PUBLIC grpc++ protobuf)
+ LINK_LIBS PUBLIC grpc++ protobuf gpr grpc absl_synchronization)
endfunction()

View File

@ -146,3 +146,4 @@ revert-update-doc.diff
unwind-force-pthread-dl.diff
force-sse2-compiler-rt.diff
bolt-disable-emit-relocs.patch
link-grpc.diff