[PATCH] D85715: [clangd] Attempt to allow gRPC & Proobuf static linking
Kirill Bobyrev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 11 02:24:03 PDT 2020
kbobyrev created this revision.
kbobyrev added a reviewer: sammccall.
Herald added subscribers: llvm-commits, usaxena95, kadircet, arphaman, jkorous, mgorny.
Herald added a project: LLVM.
kbobyrev requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.
This is a reproducer of static linking issue we've talked about during
1:1. To see the issue, pass -DCLANGD_ENABLE_REMOTE=On and don't set
-DBUILD_SHARED_LIBS=On.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D85715
Files:
llvm/cmake/modules/FindGRPC.cmake
Index: llvm/cmake/modules/FindGRPC.cmake
===================================================================
--- llvm/cmake/modules/FindGRPC.cmake
+++ llvm/cmake/modules/FindGRPC.cmake
@@ -26,6 +26,13 @@
if (GRPC_CPP_PLUGIN-NOTFOUND OR PROTOC-NOTFOUND)
message(FATAL_ERROR "gRPC C++ Plugin and Protoc must be on $PATH for Clangd remote index build")
endif()
+ if (BUILD_SHARED_LIBS)
+ set(GRPC_LIB_NAME "grpc++")
+ set(PROTOBUF_LIB_NAME "libprotobuf")
+ else()
+ set(GRPC_LIB_NAME "libgrpc++.a")
+ set(PROTOBUF_LIB_NAME "libprotobuf.a")
+ endif()
# On macOS the libraries are typically installed via Homebrew and are not on
# the system path.
if (${APPLE})
@@ -46,7 +53,7 @@
if (GRPC_HOMEBREW_RETURN_CODE EQUAL "0")
include_directories(${GRPC_HOMEBREW_PATH}/include)
find_library(GRPC_LIBRARY
- grpc++
+ ${GRPC_LIB_NAME}
PATHS ${GRPC_HOMEBREW_PATH}/lib
NO_DEFAULT_PATH
REQUIRED)
@@ -57,7 +64,7 @@
if (PROTOBUF_HOMEBREW_RETURN_CODE EQUAL "0")
include_directories(${PROTOBUF_HOMEBREW_PATH}/include)
find_library(PROTOBUF_LIBRARY
- protobuf
+ ${PROTOBUF_LIB_NAME}
PATHS ${PROTOBUF_HOMEBREW_PATH}/lib
NO_DEFAULT_PATH
REQUIRED)
@@ -66,6 +73,19 @@
IMPORTED_LOCATION ${PROTOBUF_LIBRARY})
endif()
endif()
+ elseif(${UNIX})
+ find_library(GRPC_LIBRARY
+ ${GRPC_LIB_NAME}
+ REQUIRED)
+ add_library(grpc++ UNKNOWN IMPORTED GLOBAL)
+ set_target_properties(grpc++ PROPERTIES
+ IMPORTED_LOCATION ${GRPC_LIBRARY})
+ find_library(PROTOBUF_LIBRARY
+ ${PROTOBUF_LIB_NAME}
+ REQUIRED)
+ add_library(protobuf UNKNOWN IMPORTED GLOBAL)
+ set_target_properties(protobuf PROPERTIES
+ IMPORTED_LOCATION ${PROTOBUF_LIBRARY})
endif()
endif()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85715.284618.patch
Type: text/x-patch
Size: 2094 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200811/cb13038a/attachment.bin>
More information about the llvm-commits
mailing list