[llvm] 1786908 - [clangd] Warn developers when trying to link system-installed gRPC statically

Kirill Bobyrev via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 14 01:22:25 PDT 2020


Author: Kirill Bobyrev
Date: 2020-08-14T10:22:10+02:00
New Revision: 1786908f8cefe4c5f114543d73a8de23c130e94e

URL: https://github.com/llvm/llvm-project/commit/1786908f8cefe4c5f114543d73a8de23c130e94e
DIFF: https://github.com/llvm/llvm-project/commit/1786908f8cefe4c5f114543d73a8de23c130e94e.diff

LOG: [clangd] Warn developers when trying to link system-installed gRPC statically

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D85815

Added: 
    

Modified: 
    llvm/cmake/modules/FindGRPC.cmake

Removed: 
    


################################################################################
diff  --git a/llvm/cmake/modules/FindGRPC.cmake b/llvm/cmake/modules/FindGRPC.cmake
index 70d67ceb791d..bf05a10e69f2 100644
--- a/llvm/cmake/modules/FindGRPC.cmake
+++ b/llvm/cmake/modules/FindGRPC.cmake
@@ -1,8 +1,9 @@
-# This setup requires gRPC to be built from sources using CMake and installed to
-# ${GRPC_INSTALL_PATH} via -DCMAKE_INSTALL_PREFIX=${GRPC_INSTALL_PATH}.
 # FIXME(kirillbobyrev): Check if gRPC and Protobuf headers can be included at
 # configure time.
 if (GRPC_INSTALL_PATH)
+  # This setup requires gRPC to be built from sources using CMake and installed
+  # to ${GRPC_INSTALL_PATH} via -DCMAKE_INSTALL_PREFIX=${GRPC_INSTALL_PATH}.
+  # gRPC and Protobuf will be linked statically.
   set(protobuf_MODULE_COMPATIBLE TRUE)
   find_package(Protobuf CONFIG REQUIRED HINTS ${GRPC_INSTALL_PATH})
   message(STATUS "Using protobuf ${protobuf_VERSION}")
@@ -21,10 +22,17 @@ if (GRPC_INSTALL_PATH)
   set(GRPC_CPP_PLUGIN $<TARGET_FILE:gRPC::grpc_cpp_plugin>)
   set(PROTOC ${Protobuf_PROTOC_EXECUTABLE})
 else()
+  # This setup requires system-installed gRPC and Protobuf.
+  # We always link dynamically in this mode. While the static libraries are
+  # usually installed, the CMake files telling us *which* static libraries to
+  # link are not.
+  if (NOT BUILD_SHARED_LIBS)
+    message(NOTICE "gRPC and Protobuf will be linked dynamically. If you want static linking, build gRPC from sources.")
+  endif()
   find_program(GRPC_CPP_PLUGIN grpc_cpp_plugin)
   find_program(PROTOC protoc)
   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")
+    message(FATAL_ERROR "gRPC C++ Plugin and Protoc must be on $PATH for Clangd remote index build.")
   endif()
   # On macOS the libraries are typically installed via Homebrew and are not on
   # the system path.


        


More information about the llvm-commits mailing list