Page MenuHomePhabricator

[clangd] Attempt to allow gRPC & Proobuf static linking
Changes PlannedPublic

Authored by kbobyrev on Aug 11 2020, 2:24 AM.

Details

Reviewers
sammccall
Summary

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.

Diff Detail

Event Timeline

kbobyrev created this revision.Aug 11 2020, 2:24 AM
kbobyrev requested review of this revision.Aug 11 2020, 2:24 AM

Error log on Linux:

[1/5] Linking CXX executable bin/clangd-index-server
FAILED: bin/clangd-index-server
: && /usr/bin/clang++  -gmlt -O1 -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -W
implicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -Wno-nested-anon-type
s -O3  -fuse-ld=lld -Wl,--color-diagnostics -Wl,-allow-shlib-undefined    -Wl,-O3 -Wl,--gc-sections tools/clang/tools/extra/clangd/index/remote/server/CMakeFiles/clangd-index-server.dir/Server.cpp.o  -o bin/clangd-index-server  -Wl,-rpath,"
\$ORIGIN/../lib"  lib/libLLVMSupport.a  -lpthread  lib/libclangDaemon.a  lib/libRemoteIndexProtos.a  lib/libclangdRemoteMarshalling.a  /usr/lib/x86_64-linux-gnu/libgrpc++.a  lib/libclangDaemon.a  lib/libclangTidyAndroidModule.a  lib/libclan
gTidyAbseilModule.a  lib/libclangTidyBoostModule.a  lib/libclangTidyCERTModule.a  lib/libclangTidyDarwinModule.a  lib/libclangTidyFuchsiaModule.a  lib/libclangTidyHICPPModule.a  lib/libclangTidyBugproneModule.a  lib/libclangTidyCppCoreGuide
linesModule.a  lib/libclangTidyGoogleModule.a  lib/libclangTidyLinuxKernelModule.a  lib/libclangTidyLLVMModule.a  lib/libclangTidyLLVMLibcModule.a  lib/libclangTidyMiscModule.a  lib/libclangTidyModernizeModule.a  lib/libclangTidyObjCModule.
a  lib/libclangTidyOpenMPModule.a  lib/libclangTidyPerformanceModule.a  lib/libclangTidyPortabilityModule.a  lib/libclangTidyReadabilityModule.a  lib/libclangTidyZirconModule.a  lib/libclangTidyMPIModule.a  lib/libclangTidyUtils.a  lib/libc
langTidy.a  lib/libclangStaticAnalyzerFrontend.a  lib/libclangTransformer.a  lib/libclangStaticAnalyzerCheckers.a  lib/libclangStaticAnalyzerCore.a  lib/libclangCrossTU.a  lib/libclangTooling.a  lib/libclangToolingRefactoring.a  lib/libclan
gIndex.a  lib/libclangFormat.a  lib/libclangToolingInclusions.a  lib/libclangToolingSyntax.a  lib/libclangFrontend.a  lib/libclangDriver.a  lib/libclangSerialization.a  lib/libclangParse.a  lib/libclangSema.a  lib/libclangAnalysis.a  lib/li
bclangASTMatchers.a  lib/libclangEdit.a  lib/libclangToolingCore.a  lib/libclangAST.a  lib/libclangRewrite.a  lib/libclangLex.a  lib/libclangBasic.a  lib/libRemoteIndexProtos.a  /usr/lib/x86_64-linux-gnu/libgrpc++.a  lib/libclangdSupport.a
 lib/libLLVMAArch64Info.a  lib/libLLVMAMDGPUInfo.a  lib/libLLVMARMInfo.a  lib/libLLVMAVRInfo.a  lib/libLLVMBPFInfo.a  lib/libLLVMHexagonInfo.a  lib/libLLVMLanaiInfo.a  lib/libLLVMMipsInfo.a  lib/libLLVMMSP430Info.a  lib/libLLVMNVPTXInfo.a
lib/libLLVMPowerPCInfo.a  lib/libLLVMRISCVInfo.a  lib/libLLVMSparcInfo.a  lib/libLLVMSystemZInfo.a  lib/libLLVMWebAssemblyInfo.a  lib/libLLVMX86Info.a  lib/libLLVMXCoreInfo.a  lib/libLLVMFrontendOpenMP.a  lib/libLLVMTransformUtils.a  lib/li
bLLVMAnalysis.a  lib/libLLVMProfileData.a  lib/libLLVMObject.a  lib/libLLVMBitReader.a  lib/libLLVMCore.a  lib/libLLVMRemarks.a  lib/libLLVMBitstreamReader.a  lib/libLLVMMCParser.a  lib/libLLVMMC.a  lib/libLLVMDebugInfoCodeView.a  lib/libLL
VMDebugInfoMSF.a  lib/libLLVMTextAPI.a  lib/libLLVMBinaryFormat.a  lib/libLLVMOption.a  lib/libLLVMSupport.a  -lz  -lrt  -ldl  -ltinfo  -lpthread  -lm  lib/libLLVMDemangle.a  /usr/lib/x86_64-linux-gnu/libprotobuf.a && :
ld.lld: error: undefined symbol: grpc_server_add_insecure_http2_port
>>> referenced by insecure_server_credentials.o:(.text+0x27) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a

ld.lld: error: undefined symbol: grpc_inproc_channel_create(grpc_server*, grpc_channel_args*, void*)
>>> referenced by server_cc.o:(grpc_impl::Server::InProcessChannel(grpc_impl::ChannelArguments const&)) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a
>>> referenced by server_cc.o:(grpc_impl::Server::experimental_type::InProcessChannelWithInterceptors(grpc_impl::ChannelArguments const&, std::vector<std::unique_ptr<grpc::experimental::ClientInterceptorFactoryInterface, std::default_delete
<grpc::experimental::ClientInterceptorFactoryInterface> >, std::allocator<std::unique_ptr<grpc::experimental::ClientInterceptorFactoryInterface, std::default_delete<grpc::experimental::ClientInterceptorFactoryInterface> > > >)) in archive /
usr/lib/x86_64-linux-gnu/libgrpc++.a

ld.lld: error: undefined symbol: grpc_init
>>> referenced by server_cc.o:(grpc::internal::GrpcLibrary::init()) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a
>>> referenced by core_codegen.o:(grpc::CoreCodegen::grpc_init()) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a
>>> referenced by channel.o:(grpc_channel_create(char const*, grpc_channel_args const*, grpc_channel_stack_type, grpc_transport*, grpc_resource_user*)) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a

ld.lld: error: undefined symbol: grpc_shutdown
>>> referenced by server_cc.o:(grpc::internal::GrpcLibrary::shutdown()) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a
>>> referenced by core_codegen.o:(grpc::CoreCodegen::grpc_shutdown()) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a
>>> referenced by channel.o:(.text+0x2E1) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a
>>> referenced by channel.o:(grpc_channel_create(char const*, grpc_channel_args const*, grpc_channel_stack_type, grpc_transport*, grpc_resource_user*)) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a
>>> referenced by channel.o:(grpc_channel_create(char const*, grpc_channel_args const*, grpc_channel_stack_type, grpc_transport*, grpc_resource_user*)) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a

ld.lld: error: undefined symbol: grpc_census_call_set_context
>>> referenced by channel_cc.o:(grpc_impl::Channel::CreateCallInternal(grpc::internal::RpcMethod const&, grpc_impl::ClientContext*, grpc_impl::CompletionQueue*, unsigned long)) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a

ld.lld: error: undefined symbol: grpc_census_call_get_context
>>> referenced by server_context.o:(grpc_impl::ServerContextBase::census_context() const) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a
clang: error: linker command failed with exit code 1 (use -v to see invocation)
[2/5] Linking CXX executable bin/dexp
FAILED: bin/dexp
: && /usr/bin/clang++  -gmlt -O1 -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -W
implicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -Wno-nested-anon-type
s -O3  -fuse-ld=lld -Wl,--color-diagnostics -Wl,-allow-shlib-undefined    -Wl,-O3 -Wl,--gc-sections tools/clang/tools/extra/clangd/index/dex/dexp/CMakeFiles/dexp.dir/Dexp.cpp.o  -o bin/dexp  -Wl,-rpath,"\$ORIGIN/../lib"  lib/libLLVMLineEdit
or.a  lib/libLLVMSupport.a  -lpthread  lib/libclangBasic.a  lib/libclangDaemon.a  lib/libclangdRemoteIndex.a  -ledit  lib/libclangdRemoteMarshalling.a  lib/libclangDaemon.a  lib/libclangTidyAndroidModule.a  lib/libclangTidyAbseilModule.a  l
ib/libclangTidyBoostModule.a  lib/libclangTidyCERTModule.a  lib/libclangTidyDarwinModule.a  lib/libclangTidyFuchsiaModule.a  lib/libclangTidyHICPPModule.a  lib/libclangTidyBugproneModule.a  lib/libclangTidyCppCoreGuidelinesModule.a  lib/lib
clangTidyGoogleModule.a  lib/libclangTidyLinuxKernelModule.a  lib/libclangTidyLLVMModule.a  lib/libclangTidyLLVMLibcModule.a  lib/libclangTidyMiscModule.a  lib/libclangTidyModernizeModule.a  lib/libclangTidyObjCModule.a  lib/libclangTidyOpe
nMPModule.a  lib/libclangTidyPerformanceModule.a  lib/libclangTidyPortabilityModule.a  lib/libclangTidyReadabilityModule.a  lib/libclangTidyZirconModule.a  lib/libclangTidyMPIModule.a  lib/libclangTidyUtils.a  lib/libclangTidy.a  lib/libcla
ngStaticAnalyzerFrontend.a  lib/libclangTransformer.a  lib/libclangStaticAnalyzerCheckers.a  lib/libclangStaticAnalyzerCore.a  lib/libclangCrossTU.a  lib/libclangTooling.a  lib/libclangToolingRefactoring.a  lib/libclangIndex.a  lib/libclang
Format.a  lib/libclangToolingInclusions.a  lib/libclangToolingSyntax.a  lib/libclangFrontend.a  lib/libclangDriver.a  lib/libclangSerialization.a  lib/libclangParse.a  lib/libclangSema.a  lib/libclangAnalysis.a  lib/libclangASTMatchers.a  l
ib/libclangEdit.a  lib/libclangToolingCore.a  lib/libclangAST.a  lib/libclangRewrite.a  lib/libclangLex.a  lib/libclangBasic.a  lib/libclangdSupport.a  lib/libRemoteIndexProtos.a  lib/libLLVMAArch64Info.a  lib/libLLVMAMDGPUInfo.a  lib/libLL
VMARMInfo.a  lib/libLLVMAVRInfo.a  lib/libLLVMBPFInfo.a  lib/libLLVMHexagonInfo.a  lib/libLLVMLanaiInfo.a  lib/libLLVMMipsInfo.a  lib/libLLVMMSP430Info.a  lib/libLLVMNVPTXInfo.a  lib/libLLVMPowerPCInfo.a  lib/libLLVMRISCVInfo.a  lib/libLLVM
SparcInfo.a  lib/libLLVMSystemZInfo.a  lib/libLLVMWebAssemblyInfo.a  lib/libLLVMX86Info.a  lib/libLLVMXCoreInfo.a  lib/libLLVMFrontendOpenMP.a  lib/libLLVMTransformUtils.a  lib/libLLVMAnalysis.a  lib/libLLVMProfileData.a  lib/libLLVMObject.
a  lib/libLLVMBitReader.a  lib/libLLVMCore.a  lib/libLLVMRemarks.a  lib/libLLVMBitstreamReader.a  lib/libLLVMMCParser.a  lib/libLLVMMC.a  lib/libLLVMDebugInfoCodeView.a  lib/libLLVMDebugInfoMSF.a  lib/libLLVMTextAPI.a  lib/libLLVMBinaryForm
at.a  lib/libLLVMOption.a  lib/libLLVMSupport.a  -lz  -lrt  -ldl  -ltinfo  -lpthread  -lm  lib/libLLVMDemangle.a  /usr/lib/x86_64-linux-gnu/libprotobuf.a  /usr/lib/x86_64-linux-gnu/libgrpc++.a && :
ld.lld: error: undefined symbol: grpc_insecure_channel_create
>>> referenced by insecure_credentials.o:(.text+0x1BC) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a
>>> referenced by insecure_credentials.o:(.text+0x30F) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a
ld.lld: error: undefined symbol: grpc_census_call_set_context
>>> referenced by channel_cc.o:(grpc_impl::Channel::CreateCallInternal(grpc::internal::RpcMethod const&, grpc_impl::ClientContext*, grpc_impl::CompletionQueue*, unsigned long)) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a

ld.lld: error: undefined symbol: grpc_init
>>> referenced by channel_cc.o:(grpc::internal::GrpcLibrary::init()) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a
>>> referenced by channel_cc.o:(grpc::GrpcLibraryCodegen::GrpcLibraryCodegen(bool)) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a
>>> referenced by core_codegen.o:(grpc::CoreCodegen::grpc_init()) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a
>>> referenced by channel.o:(grpc_channel_create(char const*, grpc_channel_args const*, grpc_channel_stack_type, grpc_transport*, grpc_resource_user*)) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a

ld.lld: error: undefined symbol: grpc_shutdown
>>> referenced by channel_cc.o:(grpc::internal::GrpcLibrary::shutdown()) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a
>>> referenced by channel_cc.o:(grpc::GrpcLibraryCodegen::~GrpcLibraryCodegen()) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a
>>> referenced by core_codegen.o:(grpc::CoreCodegen::grpc_shutdown()) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a
>>> referenced by channel.o:(.text+0x2E1) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a
>>> referenced by channel.o:(grpc_channel_create(char const*, grpc_channel_args const*, grpc_channel_stack_type, grpc_transport*, grpc_resource_user*)) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a
>>> referenced by channel.o:(grpc_channel_create(char const*, grpc_channel_args const*, grpc_channel_stack_type, grpc_transport*, grpc_resource_user*)) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a
clang: error: linker command failed with exit code 1 (use -v to see invocation)
[3/5] Linking CXX executable bin/clangd
FAILED: bin/clangd
: && /usr/bin/clang++  -gmlt -O1 -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -W
implicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -Wno-nested-anon-type
s -O3  -fuse-ld=lld -Wl,--color-diagnostics -Wl,-allow-shlib-undefined    -Wl,-O3 -Wl,--gc-sections tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/AddUsing.cpp.o tools/clang/tools/extra/clangd/refactor/t
weaks/CMakeFiles/obj.clangDaemonTweaks.dir/AnnotateHighlightings.cpp.o tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/DumpAST.cpp.o tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaem
onTweaks.dir/DefineInline.cpp.o tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/DefineOutline.cpp.o tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/ExpandAutoType.cpp.o
 tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/ExpandMacro.cpp.o tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/ExtractFunction.cpp.o tools/clang/tools/extra/clangd/
refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/ExtractVariable.cpp.o tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/ObjCLocalizeStringLiteral.cpp.o tools/clang/tools/extra/clangd/refactor/tweaks/CM
akeFiles/obj.clangDaemonTweaks.dir/RawStringLiteral.cpp.o tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/RemoveUsingNamespace.cpp.o tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaem
onTweaks.dir/SwapIfBranches.cpp.o tools/clang/tools/extra/clangd/tool/CMakeFiles/clangd.dir/ClangdMain.cpp.o  -o bin/clangd  -Wl,-rpath,"\$ORIGIN/../lib"  lib/libLLVMSupport.a  lib/libLLVMAArch64Info.a  lib/libLLVMAMDGPUInfo.a  lib/libLLVMA
RMInfo.a  lib/libLLVMAVRInfo.a  lib/libLLVMBPFInfo.a  lib/libLLVMHexagonInfo.a  lib/libLLVMLanaiInfo.a  lib/libLLVMMipsInfo.a  lib/libLLVMMSP430Info.a  lib/libLLVMNVPTXInfo.a  lib/libLLVMPowerPCInfo.a  lib/libLLVMRISCVInfo.a  lib/libLLVMSpa
rcInfo.a  lib/libLLVMSystemZInfo.a  lib/libLLVMWebAssemblyInfo.a  lib/libLLVMX86Info.a  lib/libLLVMXCoreInfo.a  lib/libLLVMFrontendOpenMP.a  lib/libLLVMOption.a  -lpthread  lib/libclangAST.a  lib/libclangBasic.a  lib/libclangFormat.a  lib/l
ibclangFrontend.a  lib/libclangLex.a  lib/libclangSema.a  lib/libclangTooling.a  lib/libclangToolingCore.a  lib/libclangToolingRefactoring.a  lib/libclangToolingSyntax.a  lib/libclangdRemoteIndex.a  lib/libclangTidy.a  lib/libclangDaemon.a
 lib/libclangdSupport.a  lib/libclangdRemoteMarshalling.a  lib/libclangDaemon.a  lib/libclangToolingSyntax.a  lib/libclangTidyAndroidModule.a  lib/libclangTidyAbseilModule.a  lib/libclangTidyBoostModule.a  lib/libclangTidyCERTModule.a  lib/
libclangTidyDarwinModule.a  lib/libclangTidyFuchsiaModule.a  lib/libclangTidyHICPPModule.a  lib/libclangTidyBugproneModule.a  lib/libclangTidyCppCoreGuidelinesModule.a  lib/libclangTidyGoogleModule.a  lib/libclangTidyLinuxKernelModule.a  li
b/libclangTidyLLVMModule.a  lib/libclangTidyLLVMLibcModule.a  lib/libclangTidyMiscModule.a  lib/libclangTidyModernizeModule.a  lib/libclangTidyObjCModule.a  lib/libclangTidyOpenMPModule.a  lib/libclangTidyPerformanceModule.a  lib/libclangTi
dyPortabilityModule.a  lib/libclangTidyReadabilityModule.a  lib/libclangTidyZirconModule.a  lib/libclangTidyMPIModule.a  lib/libclangTidyUtils.a  lib/libclangTidy.a  lib/libclangTooling.a  lib/libclangStaticAnalyzerFrontend.a  lib/libclangS
taticAnalyzerCheckers.a  lib/libclangStaticAnalyzerCore.a  lib/libclangCrossTU.a  lib/libclangTransformer.a  lib/libclangToolingRefactoring.a  lib/libclangIndex.a  lib/libclangFormat.a  lib/libclangToolingInclusions.a  lib/libclangFrontend.
a  lib/libclangDriver.a  lib/libclangParse.a  lib/libclangToolingCore.a  lib/libclangSerialization.a  lib/libclangSema.a  lib/libclangEdit.a  lib/libclangAnalysis.a  lib/libclangRewrite.a  lib/libclangASTMatchers.a  lib/libclangAST.a  lib/l
ibclangLex.a  lib/libclangBasic.a  lib/libclangdSupport.a  lib/libRemoteIndexProtos.a  lib/libLLVMAArch64Info.a  lib/libLLVMAMDGPUInfo.a  lib/libLLVMARMInfo.a  lib/libLLVMAVRInfo.a  lib/libLLVMBPFInfo.a  lib/libLLVMHexagonInfo.a  lib/libLLV
MLanaiInfo.a  lib/libLLVMMipsInfo.a  lib/libLLVMMSP430Info.a  lib/libLLVMNVPTXInfo.a  lib/libLLVMPowerPCInfo.a  lib/libLLVMRISCVInfo.a  lib/libLLVMSparcInfo.a  lib/libLLVMSystemZInfo.a  lib/libLLVMWebAssemblyInfo.a  lib/libLLVMX86Info.a  li
b/libLLVMXCoreInfo.a  lib/libLLVMFrontendOpenMP.a  lib/libLLVMTransformUtils.a  lib/libLLVMAnalysis.a  lib/libLLVMProfileData.a  lib/libLLVMObject.a  lib/libLLVMBitReader.a  lib/libLLVMCore.a  lib/libLLVMRemarks.a  lib/libLLVMBitstreamReade
r.a  lib/libLLVMMCParser.a  lib/libLLVMMC.a  lib/libLLVMDebugInfoCodeView.a  lib/libLLVMDebugInfoMSF.a  lib/libLLVMTextAPI.a  lib/libLLVMBinaryFormat.a  lib/libLLVMOption.a  lib/libLLVMSupport.a  -lz  -lrt  -ldl  -ltinfo  -lpthread  -lm  li
b/libLLVMDemangle.a  /usr/lib/x86_64-linux-gnu/libprotobuf.a  /usr/lib/x86_64-linux-gnu/libgrpc++.a && :
ld.lld: error: undefined symbol: grpc_insecure_channel_create
>>> referenced by insecure_credentials.o:(.text+0x1BC) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a
>>> referenced by insecure_credentials.o:(.text+0x30F) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a

ld.lld: error: undefined symbol: grpc_census_call_set_context
>>> referenced by channel_cc.o:(grpc_impl::Channel::CreateCallInternal(grpc::internal::RpcMethod const&, grpc_impl::ClientContext*, grpc_impl::CompletionQueue*, unsigned long)) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a

ld.lld: error: undefined symbol: grpc_init
>>> referenced by channel_cc.o:(grpc::internal::GrpcLibrary::init()) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a
>>> referenced by channel_cc.o:(grpc::GrpcLibraryCodegen::GrpcLibraryCodegen(bool)) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a
>>> referenced by core_codegen.o:(grpc::CoreCodegen::grpc_init()) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a
>>> referenced by channel.o:(grpc_channel_create(char const*, grpc_channel_args const*, grpc_channel_stack_type, grpc_transport*, grpc_resource_user*)) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a

ld.lld: error: undefined symbol: grpc_shutdown
>>> referenced by channel_cc.o:(grpc::internal::GrpcLibrary::shutdown()) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a
>>> referenced by channel_cc.o:(grpc::GrpcLibraryCodegen::~GrpcLibraryCodegen()) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a
>>> referenced by core_codegen.o:(grpc::CoreCodegen::grpc_shutdown()) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a
>>> referenced by channel.o:(.text+0x2E1) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a
>>> referenced by channel.o:(grpc_channel_create(char const*, grpc_channel_args const*, grpc_channel_stack_type, grpc_transport*, grpc_resource_user*)) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a
>>> referenced by channel.o:(grpc_channel_create(char const*, grpc_channel_args const*, grpc_channel_stack_type, grpc_transport*, grpc_resource_user*)) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a
clang: error: linker command failed with exit code 1 (use -v to see invocation)
[4/5] Linking CXX executable tools/clang/tools/extra/clangd/unittests/ClangdTests
ninja: build stopped: subcommand failed.

macOS error message:

[2268/2268] Linking CXX executable bin/clangd                                                   
FAILED: bin/clangd                                                                                               
: && /usr/local/opt/llvm/bin/clang++ -gmlt -O1 -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -
Wno-long-long -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color -fno-common -Woverloaded-virtual -Wno-nested-anon-types -O3  -isysroot /
Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names -Wl,-dead_strip tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/AddUsing.cpp.o tools/clan
g/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/AnnotateHighlightings.cpp.o tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/DumpAST.cpp.o tools/clang/tools/extra/clangd/refacto
r/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/DefineInline.cpp.o tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/DefineOutline.cpp.o tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDa
emonTweaks.dir/ExpandAutoType.cpp.o tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/ExpandMacro.cpp.o tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/ExtractFunction.
cpp.o tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/ExtractVariable.cpp.o tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/ObjCLocalizeStringLiteral.cpp.o tools/clan
g/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/RawStringLiteral.cpp.o tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/RemoveUsingNamespace.cpp.o tools/clang/tools/extra/clangd
/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/SwapIfBranches.cpp.o tools/clang/tools/extra/clangd/tool/CMakeFiles/clangd.dir/ClangdMain.cpp.o -o bin/clangd  -Wl,-rpath,@loader_path/../lib  lib/libLLVMSupport.a  lib/libLLVMAArch64I
nfo.a  lib/libLLVMAMDGPUInfo.a  lib/libLLVMARMInfo.a  lib/libLLVMAVRInfo.a  lib/libLLVMBPFInfo.a  lib/libLLVMHexagonInfo.a  lib/libLLVMLanaiInfo.a  lib/libLLVMMipsInfo.a  lib/libLLVMMSP430Info.a  lib/libLLVMNVPTXInfo.a  lib/libLLVMPowerPC
Info.a  lib/libLLVMRISCVInfo.a  lib/libLLVMSparcInfo.a  lib/libLLVMSystemZInfo.a  lib/libLLVMWebAssemblyInfo.a  lib/libLLVMX86Info.a  lib/libLLVMXCoreInfo.a  lib/libLLVMFrontendOpenMP.a  lib/libLLVMOption.a  lib/libclangAST.a  lib/libclan
gBasic.a  lib/libclangFormat.a  lib/libclangFrontend.a  lib/libclangLex.a  lib/libclangSema.a  lib/libclangTooling.a  lib/libclangToolingCore.a  lib/libclangToolingRefactoring.a  lib/libclangToolingSyntax.a  lib/libclangdRemoteIndex.a  li
b/libclangTidy.a  lib/libclangDaemon.a  lib/libclangdSupport.a  lib/libclangdXpcJsonConversions.a  lib/libclangdXpcTransport.a  lib/libclangdRemoteMarshalling.a  lib/libRemoteIndexProtos.a  /usr/local/opt/protobuf/lib/libprotobuf.a  /usr/
local/opt/grpc/lib/libgrpc++.a  lib/libclangdXpcJsonConversions.a  lib/libclangDaemon.a  lib/libLLVMAArch64Info.a  lib/libLLVMAMDGPUInfo.a  lib/libLLVMARMInfo.a  lib/libLLVMAVRInfo.a  lib/libLLVMBPFInfo.a  lib/libLLVMHexagonInfo.a  lib/li
bLLVMLanaiInfo.a  lib/libLLVMMipsInfo.a  lib/libLLVMMSP430Info.a  lib/libLLVMNVPTXInfo.a  lib/libLLVMPowerPCInfo.a  lib/libLLVMRISCVInfo.a  lib/libLLVMSparcInfo.a  lib/libLLVMSystemZInfo.a  lib/libLLVMWebAssemblyInfo.a  lib/libLLVMX86Info
.a  lib/libLLVMXCoreInfo.a  lib/libclangToolingSyntax.a  lib/libclangTidyAndroidModule.a  lib/libclangTidyAbseilModule.a  lib/libclangTidyBoostModule.a  lib/libclangTidyCERTModule.a  lib/libclangTidyDarwinModule.a  lib/libclangTidyFuchsia
Module.a  lib/libclangTidyHICPPModule.a  lib/libclangTidyBugproneModule.a  lib/libclangTidyCppCoreGuidelinesModule.a  lib/libclangTidyGoogleModule.a  lib/libclangTidyLinuxKernelModule.a  lib/libclangTidyLLVMModule.a  lib/libclangTidyLLVML
ibcModule.a  lib/libclangTidyMiscModule.a  lib/libclangTidyModernizeModule.a  lib/libclangTidyObjCModule.a  lib/libclangTidyOpenMPModule.a  lib/libclangTidyPerformanceModule.a  lib/libclangTidyPortabilityModule.a  lib/libclangTidyReadabil
ityModule.a  lib/libclangTidyZirconModule.a  lib/libclangTidyMPIModule.a  lib/libclangTidyUtils.a  lib/libclangTidy.a  lib/libclangTooling.a  lib/libclangStaticAnalyzerFrontend.a  lib/libclangStaticAnalyzerCheckers.a  lib/libclangStaticAn
alyzerCore.a  lib/libclangCrossTU.a  lib/libclangTransformer.a  lib/libclangToolingRefactoring.a  lib/libclangIndex.a  lib/libclangFormat.a  lib/libclangToolingInclusions.a  lib/libclangFrontend.a  lib/libclangDriver.a  lib/libLLVMOption.
a  lib/libclangParse.a  lib/libclangToolingCore.a  lib/libclangSerialization.a  lib/libclangSema.a  lib/libclangEdit.a  lib/libclangAnalysis.a  lib/libclangRewrite.a  lib/libclangASTMatchers.a  lib/libclangAST.a  lib/libLLVMFrontendOpenMP.a  lib/libLLVMTransformUtils.a  lib/libLLVMAnalysis.a  lib/libLLVMProfileData.a  lib/libLLVMObject.a  lib/libLLVMBitReader.a  lib/libLLVMMCParser.a  lib/libLLVMTextAPI.a  lib/libclangLex.a  lib/libclangBasic.a  lib/libLLVMCore.a  lib/lib
LLVMRemarks.a  lib/libLLVMBitstreamReader.a  lib/libLLVMMC.a  lib/libLLVMBinaryFormat.a  lib/libLLVMDebugInfoCodeView.a  lib/libLLVMDebugInfoMSF.a  lib/libclangdSupport.a  lib/libLLVMSupport.a  -lz  -lcurses  -lm  lib/libLLVMDemangle.a &&
 :                                                                                                                    
Undefined symbols for architecture x86_64:                                                                                                               
  "_grpc_slice_buffer_pop", referenced from:                                                                        
      grpc::CoreCodegen::grpc_slice_buffer_pop(grpc_slice_buffer*) in libgrpc++.a(core_codegen.o)                                
  "_grpc_slice_buffer_add", referenced from:                                                                                          
      grpc::CoreCodegen::grpc_slice_buffer_add(grpc_slice_buffer*, grpc_slice) in libgrpc++.a(core_codegen.o)                         
  "_grpc_completion_queue_create_for_pluck", referenced from:                                                                        
      grpc::CoreCodegen::grpc_completion_queue_create_for_pluck(void*) in libgrpc++.a(core_codegen.o)
  "_grpc_init", referenced from:
      grpc::internal::GrpcLibrary::init() in libgrpc++.a(completion_queue_cc.o)
      grpc::CoreCodegen::grpc_init() in libgrpc++.a(core_codegen.o)
  "_grpc_slice_from_static_buffer", referenced from:
      grpc::CoreCodegen::grpc_slice_from_static_buffer(void const*, unsigned long) in libgrpc++.a(core_codegen.o)
  "_grpc_raw_byte_buffer_create", referenced from:
      grpc::CoreCodegen::grpc_raw_byte_buffer_create(grpc_slice*, unsigned long) in libgrpc++.a(core_codegen.o)
  "_grpc_slice_sub", referenced from:
      grpc::CoreCodegen::grpc_slice_sub(grpc_slice, unsigned long, unsigned long) in libgrpc++.a(core_codegen.o)
  "_grpc_slice_split_head", referenced from:
      grpc::CoreCodegen::grpc_slice_split_head(grpc_slice*, unsigned long) in libgrpc++.a(core_codegen.o)
  "_grpc_slice_ref", referenced from:
      grpc::CoreCodegen::grpc_slice_ref(grpc_slice) in libgrpc++.a(core_codegen.o)
  "_grpc_slice_new_with_len", referenced from:
      grpc::CoreCodegen::grpc_slice_new_with_len(void*, unsigned long, void (*)(void*, unsigned long)) in libgrpc++.a(core_codegen.o)
  "grpc_core::ExecCtx::exec_ctx_", referenced from:
      grpc_impl::ChannelArguments::~ChannelArguments() in libgrpc++.a(channel_arguments.o)
      grpc_core::ExecCtx::~ExecCtx() in libgrpc++.a(channel_arguments.o)
  "_grpc_slice_new_with_user_data", referenced from:
      grpc::CoreCodegen::grpc_slice_new_with_user_data(void*, unsigned long, void (*)(void*), void*) in libgrpc++.a(core_codegen.o)
  "_grpc_byte_buffer_length", referenced from:
      grpc::CoreCodegen::grpc_byte_buffer_length(grpc_byte_buffer*) in libgrpc++.a(core_codegen.o)
  "_grpc_slice_from_copied_buffer", referenced from:
      grpc::CoreCodegen::grpc_slice_from_copied_buffer(void const*, unsigned long) in libgrpc++.a(core_codegen.o)
  "_grpc_byte_buffer_reader_peek", referenced from:
      grpc::CoreCodegen::grpc_byte_buffer_reader_peek(grpc_byte_buffer_reader*, grpc_slice**) in libgrpc++.a(core_codegen.o)
  "_grpc_byte_buffer_reader_next", referenced from:
      grpc::CoreCodegen::grpc_byte_buffer_reader_next(grpc_byte_buffer_reader*, grpc_slice*) in libgrpc++.a(core_codegen.o)
  "_grpc_byte_buffer_reader_destroy", referenced from:
      grpc::CoreCodegen::grpc_byte_buffer_reader_destroy(grpc_byte_buffer_reader*) in libgrpc++.a(core_codegen.o)
  "_grpc_byte_buffer_reader_init", referenced from:
 grpc::CoreCodegen::grpc_byte_buffer_reader_init(grpc_byte_buffer_reader*, grpc_byte_buffer*) in libgrpc++.a(core_codegen.o)                                                                                                      [4/446]
  "_grpc_call_start_batch", referenced from:
      grpc::CoreCodegen::grpc_call_start_batch(grpc_call*, grpc_op const*, unsigned long, void*, void*) in libgrpc++.a(core_codegen.o)
  "_grpc_call_error_to_string", referenced from:
      grpc::CoreCodegen::grpc_call_error_to_string(grpc_call_error) in libgrpc++.a(core_codegen.o)
  "_grpc_call_ref", referenced from:
      grpc::CoreCodegen::grpc_call_ref(grpc_call*) in libgrpc++.a(core_codegen.o)
  "_grpc_byte_buffer_copy", referenced from:
      grpc::CoreCodegen::grpc_byte_buffer_copy(grpc_byte_buffer*) in libgrpc++.a(core_codegen.o)
  "_grpc_completion_queue_pluck", referenced from:
      grpc::CoreCodegen::grpc_completion_queue_pluck(grpc_completion_queue*, void*, gpr_timespec, void*) in libgrpc++.a(core_codegen.o)
  "_grpc_call_arena_alloc", referenced from:
      grpc::CoreCodegen::grpc_call_arena_alloc(grpc_call*, unsigned long) in libgrpc++.a(core_codegen.o)
  "_grpc_byte_buffer_destroy", referenced from:
      grpc::CoreCodegen::grpc_byte_buffer_destroy(grpc_byte_buffer*) in libgrpc++.a(core_codegen.o)
  "_grpc_completion_queue_destroy", referenced from:
      grpc::CoreCodegen::grpc_completion_queue_destroy(grpc_completion_queue*) in libgrpc++.a(core_codegen.o)
  "_grpc_metadata_array_destroy", referenced from:
      grpc::CoreCodegen::grpc_metadata_array_destroy(grpc_metadata_array*) in libgrpc++.a(core_codegen.o)
  "_grpc_channel_create_call", referenced from:
      grpc_impl::Channel::CreateCallInternal(grpc::internal::RpcMethod const&, grpc_impl::ClientContext*, grpc_impl::CompletionQueue*, unsigned long) in libgrpc++.a(channel_cc.o)
  "_grpc_completion_queue_shutdown", referenced from:
      grpc::CoreCodegen::grpc_completion_queue_shutdown(grpc_completion_queue*) in libgrpc++.a(core_codegen.o)
  "_grpc_slice_split_tail", referenced from:
      grpc::CoreCodegen::grpc_slice_split_tail(grpc_slice*, unsigned long) in libgrpc++.a(core_codegen.o)
  "_grpc_empty_slice", referenced from:
      grpc::CoreCodegen::grpc_empty_slice() in libgrpc++.a(core_codegen.o)
  "_grpc_completion_queue_create_for_next", referenced from:
      grpc::CoreCodegen::grpc_completion_queue_create_for_next(void*) in libgrpc++.a(core_codegen.o)
  "_grpc_completion_queue_create", referenced from:
      grpc::CoreCodegen::grpc_completion_queue_create(grpc_completion_queue_factory const*, grpc_completion_queue_attributes const*, void*) in libgrpc++.a(core_codegen.o)
  "_grpc_channel_create_registered_call", referenced from:
      grpc_impl::Channel::CreateCallInternal(grpc::internal::RpcMethod const&, grpc_impl::ClientContext*, grpc_impl::CompletionQueue*, unsigned long) in libgrpc++.a(channel_cc.o)
  "_grpc_channel_watch_connectivity_state", referenced from:
      grpc_impl::Channel::NotifyOnStateChangeImpl(grpc_connectivity_state, gpr_timespec, grpc_impl::CompletionQueue*, void*) in libgrpc++.a(channel_cc.o)
      grpc_impl::Channel::WaitForStateChangeImpl(grpc_connectivity_state, gpr_timespec) in libgrpc++.a(channel_cc.o)
  "_grpc_call_cancel", referenced from:
      grpc_impl::ClientContext::set_call(grpc_call*, std::__1::shared_ptr<grpc_impl::Channel> const&) in libgrpc++.a(client_context.o)
  "_grpc_completion_queue_factory_lookup", referenced from:
      grpc::CoreCodegen::grpc_completion_queue_factory_lookup(grpc_completion_queue_attributes const*) in libgrpc++.a(core_codegen.o)
  "grpc_core::ExecCtx::Flush()", referenced from:
      grpc_core::ExecCtx::~ExecCtx() in libgrpc++.a(channel_arguments.o)
  "_grpc_insecure_channel_create", referenced from:
      l005 in libgrpc++.a(insecure_credentials.o)
  "_grpc_call_unref", referenced from:
      grpc_impl::ClientContext::~ClientContext() in libgrpc++.a(client_context.o)
      grpc::CoreCodegen::grpc_call_unref(grpc_call*) in libgrpc++.a(core_codegen.o)
  "_grpc_channel_check_connectivity_state", referenced from:
      grpc_impl::Channel::GetState(bool) in libgrpc++.a(channel_cc.o)
  "_grpc_channel_register_call", referenced from:
      grpc_impl::Channel::RegisterMethod(char const*) in libgrpc++.a(channel_cc.o)
  "_grpc_call_cancel_with_status", referenced from:
      grpc_impl::ClientContext::set_call(grpc_call*, std::__1::shared_ptr<grpc_impl::Channel> const&) in libgrpc++.a(client_context.o)
      grpc::CoreCodegen::grpc_call_cancel_with_status(grpc_call*, grpc_status_code, char const*, void*) in libgrpc++.a(core_codegen.o)
  "_grpc_slice_unref", referenced from:
      grpc_impl::Channel::CreateCallInternal(grpc::internal::RpcMethod const&, grpc_impl::ClientContext*, grpc_impl::CompletionQueue*, unsigned long) in libgrpc++.a(channel_cc.o)
      grpc::CoreCodegen::grpc_slice_unref(grpc_slice) in libgrpc++.a(core_codegen.o)
  "_grpc_census_call_set_context", referenced from:
      grpc_impl::Channel::CreateCallInternal(grpc::internal::RpcMethod const&, grpc_impl::ClientContext*, grpc_impl::CompletionQueue*, unsigned long) in libgrpc++.a(channel_cc.o)
  "_grpc_metadata_array_init", referenced from:
      grpc::CoreCodegen::grpc_metadata_array_init(grpc_metadata_array*) in libgrpc++.a(core_codegen.o)
  "_grpc_channel_destroy", referenced from:
      grpc_impl::Channel::~Channel() in libgrpc++.a(channel_cc.o)
  "_grpc_slice_malloc", referenced from:
      grpc::CoreCodegen::grpc_slice_malloc(unsigned long) in libgrpc++.a(core_codegen.o)
  "_grpc_lame_client_channel_create", referenced from:
      grpc_impl::CreateCustomChannelImpl(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::shared_ptr<grpc_impl::ChannelCredentials> const&, grpc_impl::ChannelArguments const&) in libg
rpc++.a(create_channel.o)
  "_grpc_completion_queue_next", referenced from:
      grpc_impl::CompletionQueue::AsyncNextInternal(void**, bool*, gpr_timespec) in libgrpc++.a(completion_queue_cc.o)
  "_grpc_shutdown", referenced from:
      grpc::internal::GrpcLibrary::shutdown() in libgrpc++.a(channel_cc.o)
      grpc::CoreCodegen::grpc_shutdown() in libgrpc++.a(core_codegen.o)

When I also link libgrpc.a and libgrpc++_reflecion.a to the binaries the following error persists:

[1/1] Linking CXX executable bin/clangd-index-server
FAILED: bin/clangd-index-server 
: && /usr/local/opt/llvm/bin/clang++ -gmlt -O1 -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color -fno-common -Woverloaded-virtual -Wno-nested-anon-types -O3  -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names -Wl,-dead_strip tools/clang/tools/extra/clangd/index/remote/server/CMakeFiles/clangd-index-server.dir/Server.cpp.o -o bin/clangd-index-server  -Wl,-rpath,@loader_path/../lib  lib/libLLVMSupport.a  lib/libclangDaemon.a  lib/libRemoteIndexProtos.a  lib/libclangdRemoteMarshalling.a  /usr/local/opt/grpc/lib/libgrpc++.a  /usr/local/opt/grpc/lib//libgrpc.a  /usr/local/opt/grpc/lib/libgrpc++_reflection.a  lib/libclangDaemon.a  lib/libclangTidyAndroidModule.a  lib/libclangTidyAbseilModule.a  lib/libclangTidyBoostModule.a  lib/libclangTidyCERTModule.a  lib/libclangTidyDarwinModule.a  lib/libclangTidyFuchsiaModule.a  lib/libclangTidyHICPPModule.a  lib/libclangTidyBugproneModule.a  lib/libclangTidyCppCoreGuidelinesModule.a  lib/libclangTidyGoogleModule.a  lib/libclangTidyLinuxKernelModule.a  lib/libclangTidyLLVMModule.a  lib/libclangTidyLLVMLibcModule.a  lib/libclangTidyMiscModule.a  lib/libclangTidyModernizeModule.a  lib/libclangTidyObjCModule.a  lib/libclangTidyOpenMPModule.a  lib/libclangTidyPerformanceModule.a  lib/libclangTidyPortabilityModule.a  lib/libclangTidyReadabilityModule.a  lib/libclangTidyZirconModule.a  lib/libclangTidyMPIModule.a  lib/libclangTidyUtils.a  lib/libclangTidy.a  lib/libclangStaticAnalyzerFrontend.a  lib/libclangTransformer.a  lib/libclangStaticAnalyzerCheckers.a  lib/libclangStaticAnalyzerCore.a  lib/libclangCrossTU.a  lib/libclangTooling.a  lib/libclangToolingRefactoring.a  lib/libclangIndex.a  lib/libclangFormat.a  lib/libclangToolingInclusions.a  lib/libclangToolingSyntax.a  lib/libclangFrontend.a  lib/libclangDriver.a  lib/libclangSerialization.a  lib/libclangParse.a  lib/libclangSema.a  lib/libclangAnalysis.a  lib/libclangASTMatchers.a  lib/libclangEdit.a  lib/libclangToolingCore.a  lib/libclangAST.a  lib/libclangRewrite.a  lib/libclangLex.a  lib/libclangBasic.a  lib/libRemoteIndexProtos.a  /usr/local/opt/grpc/lib/libgrpc++.a  lib/libclangdSupport.a  lib/libLLVMAArch64Info.a  lib/libLLVMAMDGPUInfo.a  lib/libLLVMARMInfo.a  lib/libLLVMAVRInfo.a  lib/libLLVMBPFInfo.a  lib/libLLVMHexagonInfo.a  lib/libLLVMLanaiInfo.a  lib/libLLVMMipsInfo.a  lib/libLLVMMSP430Info.a  lib/libLLVMNVPTXInfo.a  lib/libLLVMPowerPCInfo.a  lib/libLLVMRISCVInfo.a  lib/libLLVMSparcInfo.a  lib/libLLVMSystemZInfo.a  lib/libLLVMWebAssemblyInfo.a  lib/libLLVMX86Info.a  lib/libLLVMXCoreInfo.a  lib/libLLVMFrontendOpenMP.a  lib/libLLVMTransformUtils.a  lib/libLLVMAnalysis.a  lib/libLLVMProfileData.a  lib/libLLVMObject.a  lib/libLLVMBitReader.a  lib/libLLVMCore.a  lib/libLLVMRemarks.a  lib/libLLVMBitstreamReader.a  lib/libLLVMMCParser.a  lib/libLLVMMC.a  lib/libLLVMDebugInfoCodeView.a  lib/libLLVMDebugInfoMSF.a  lib/libLLVMTextAPI.a  lib/libLLVMBinaryFormat.a  lib/libLLVMOption.a  lib/libLLVMSupport.a  -lz  -lcurses  -lm  lib/libLLVMDemangle.a  /usr/local/opt/protobuf/lib/libprotobuf.a && :
Undefined symbols for architecture x86_64:
  "_CFTimeZoneGetName", referenced from:
      absl::lts_2020_02_25::time_internal::cctz::local_time_zone() in libgrpc++.a(time_zone_lookup.o)
  "_CFStringGetLength", referenced from:
      absl::lts_2020_02_25::time_internal::cctz::local_time_zone() in libgrpc++.a(time_zone_lookup.o)
  "_CFRelease", referenced from:
      absl::lts_2020_02_25::time_internal::cctz::local_time_zone() in libgrpc++.a(time_zone_lookup.o)
  "_CFStringGetMaximumSizeForEncoding", referenced from:
      absl::lts_2020_02_25::time_internal::cctz::local_time_zone() in libgrpc++.a(time_zone_lookup.o)
  "_CFTimeZoneCopyDefault", referenced from:
      absl::lts_2020_02_25::time_internal::cctz::local_time_zone() in libgrpc++.a(time_zone_lookup.o)
  "_CFStringGetCString", referenced from:
      absl::lts_2020_02_25::time_internal::cctz::local_time_zone() in libgrpc++.a(time_zone_lookup.o)
  "___darwin_check_fd_set_overflow", referenced from:
      l001 in libgrpc++.a(ares_process.o)
ld: symbol(s) not found for architecture x86_64
clang-10: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

This seems to be the related issue for macOS: https://github.com/tensorflow/tensorflow/issues/30117. The proposed solution is hardcoding -framework CoreFoundation :(

When I manually link /usr/lib/x86_64-linux-gnu/libgrpc++_reflection.a to clangdRemoteServer on Linux the following error persists:

[3/6] Linking CXX executable bin/clangd
FAILED: bin/clangd
: && /usr/bin/clang++  -gmlt -O1 -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -Wno-nested-anon-types -O3  -fuse-ld=lld -Wl,--color-diagnostics -Wl,-allow-shlib-undefined    -Wl,-O3 -Wl,--gc-sections tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/AddUsing.cpp.o tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/AnnotateHighlightings.cpp.o tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/DumpAST.cpp.o tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/DefineInline.cpp.o tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/DefineOutline.cpp.o tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/ExpandAutoType.cpp.o tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/ExpandMacro.cpp.o tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/ExtractFunction.cpp.o tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/ExtractVariable.cpp.o tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/ObjCLocalizeStringLiteral.cpp.o tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/RawStringLiteral.cpp.o tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/RemoveUsingNamespace.cpp.o tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/SwapIfBranches.cpp.o tools/clang/tools/extra/clangd/tool/CMakeFiles/clangd.dir/ClangdMain.cpp.o  -o bin/clangd  -Wl,-rpath,"\$ORIGIN/../lib"  lib/libLLVMSupport.a  lib/libLLVMAArch64Info.a  lib/libLLVMAMDGPUInfo.a  lib/libLLVMARMInfo.a  lib/libLLVMAVRInfo.a  lib/libLLVMBPFInfo.a  lib/libLLVMHexagonInfo.a  lib/libLLVMLanaiInfo.a  lib/libLLVMMipsInfo.a  lib/libLLVMMSP430Info.a  lib/libLLVMNVPTXInfo.a  lib/libLLVMPowerPCInfo.a  lib/libLLVMRISCVInfo.a  lib/libLLVMSparcInfo.a  lib/libLLVMSystemZInfo.a  lib/libLLVMWebAssemblyInfo.a  lib/libLLVMX86Info.a  lib/libLLVMXCoreInfo.a  lib/libLLVMFrontendOpenMP.a  lib/libLLVMOption.a  -lpthread  lib/libclangAST.a  lib/libclangBasic.a  lib/libclangFormat.a  lib/libclangFrontend.a  lib/libclangLex.a  lib/libclangSema.a  lib/libclangTooling.a  lib/libclangToolingCore.a  lib/libclangToolingRefactoring.a  lib/libclangToolingSyntax.a  lib/libclangdRemoteIndex.a  lib/libclangTidy.a  lib/libclangDaemon.a  lib/libclangdSupport.a  lib/libclangdRemoteMarshalling.a  lib/libclangDaemon.a  lib/libclangToolingSyntax.a  lib/libclangTidyAndroidModule.a  lib/libclangTidyAbseilModule.a  lib/libclangTidyBoostModule.a  lib/libclangTidyCERTModule.a  lib/libclangTidyDarwinModule.a  lib/libclangTidyFuchsiaModule.a  lib/libclangTidyHICPPModule.a  lib/libclangTidyBugproneModule.a  lib/libclangTidyCppCoreGuidelinesModule.a  lib/libclangTidyGoogleModule.a  lib/libclangTidyLinuxKernelModule.a  lib/libclangTidyLLVMModule.a  lib/libclangTidyLLVMLibcModule.a  lib/libclangTidyMiscModule.a  lib/libclangTidyModernizeModule.a  lib/libclangTidyObjCModule.a  lib/libclangTidyOpenMPModule.a  lib/libclangTidyPerformanceModule.a  lib/libclangTidyPortabilityModule.a  lib/libclangTidyReadabilityModule.a  lib/libclangTidyZirconModule.a  lib/libclangTidyMPIModule.a  lib/libclangTidyUtils.a  lib/libclangTidy.a  lib/libclangTooling.a  lib/libclangStaticAnalyzerFrontend.a  lib/libclangStaticAnalyzerCheckers.a  lib/libclangStaticAnalyzerCore.a  lib/libclangCrossTU.a  lib/libclangTransformer.a  lib/libclangToolingRefactoring.a  lib/libclangIndex.a  lib/libclangFormat.a  lib/libclangToolingInclusions.a  lib/libclangFrontend.a  lib/libclangDriver.a  lib/libclangParse.a  lib/libclangToolingCore.a  lib/libclangSerialization.a  lib/libclangSema.a  lib/libclangEdit.a  lib/libclangAnalysis.a  lib/libclangRewrite.a  lib/libclangASTMatchers.a  lib/libclangAST.a  lib/libclangLex.a  lib/libclangBasic.a  lib/libclangdSupport.a  lib/libRemoteIndexProtos.a  lib/libLLVMAArch64Info.a  lib/libLLVMAMDGPUInfo.a  lib/libLLVMARMInfo.a  lib/libLLVMAVRInfo.a  lib/libLLVMBPFInfo.a  lib/libLLVMHexagonInfo.a  lib/libLLVMLanaiInfo.a  lib/libLLVMMipsInfo.a  lib/libLLVMMSP430Info.a  lib/libLLVMNVPTXInfo.a  lib/libLLVMPowerPCInfo.a  lib/libLLVMRISCVInfo.a  lib/libLLVMSparcInfo.a  lib/libLLVMSystemZInfo.a  lib/libLLVMWebAssemblyInfo.a  lib/libLLVMX86Info.a  lib/libLLVMXCoreInfo.a  lib/libLLVMFrontendOpenMP.a  lib/libLLVMTransformUtils.a  lib/libLLVMAnalysis.a  lib/libLLVMProfileData.a  lib/libLLVMObject.a  lib/libLLVMBitReader.a  lib/libLLVMCore.a  lib/libLLVMRemarks.a  lib/libLLVMBitstreamReader.a  lib/libLLVMMCParser.a  lib/libLLVMMC.a  lib/libLLVMDebugInfoCodeView.a  lib/libLLVMDebugInfoMSF.a  lib/libLLVMTextAPI.a  lib/libLLVMBinaryFormat.a  lib/libLLVMOption.a  lib/libLLVMSupport.a  -lz  -lrt  -ldl  -ltinfo  -lpthread  -lm  lib/libLLVMDemangle.a  /usr/lib/x86_64-linux-gnu/libprotobuf.a  /usr/lib/x86_64-linux-gnu/libgrpc++.a && :
ld.lld: error: undefined symbol: grpc_insecure_channel_create
>>> referenced by insecure_credentials.o:(.text+0x1BC) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a
>>> referenced by insecure_credentials.o:(.text+0x30F) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a

ld.lld: error: undefined symbol: grpc_census_call_set_context
>>> referenced by channel_cc.o:(grpc_impl::Channel::CreateCallInternal(grpc::internal::RpcMethod const&, grpc_impl::ClientContext*, grpc_impl::CompletionQueue*, unsigned long)) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a

ld.lld: error: undefined symbol: grpc_init
>>> referenced by channel_cc.o:(grpc::internal::GrpcLibrary::init()) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a
>>> referenced by channel_cc.o:(grpc::GrpcLibraryCodegen::GrpcLibraryCodegen(bool)) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a
>>> referenced by core_codegen.o:(grpc::CoreCodegen::grpc_init()) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a
>>> referenced by channel.o:(grpc_channel_create(char const*, grpc_channel_args const*, grpc_channel_stack_type, grpc_transport*, grpc_resource_user*)) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a

ld.lld: error: undefined symbol: grpc_shutdown
>>> referenced by channel_cc.o:(grpc::internal::GrpcLibrary::shutdown()) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a
>>> referenced by channel_cc.o:(grpc::GrpcLibraryCodegen::~GrpcLibraryCodegen()) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a
>>> referenced by core_codegen.o:(grpc::CoreCodegen::grpc_shutdown()) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a
>>> referenced by channel.o:(.text+0x2E1) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a
>>> referenced by channel.o:(grpc_channel_create(char const*, grpc_channel_args const*, grpc_channel_stack_type, grpc_transport*, grpc_resource_user*)) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a
>>> referenced by channel.o:(grpc_channel_create(char const*, grpc_channel_args const*, grpc_channel_stack_type, grpc_transport*, grpc_resource_user*)) in archive /usr/lib/x86_64-linux-gnu/libgrpc++.a
clang: error: linker command failed with exit code 1 (use -v to see invocation)
[5/6] Linking CXX executable tools/clang/tools/extra/clangd/unittests/ClangdTests
ninja: build stopped: subcommand failed.

When I link libgrpc.a the following happens:

[2/4] Linking CXX executable bin/clangd-index-server
FAILED: bin/clangd-index-server
: && /usr/bin/clang++  -gmlt -O1 -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -W
implicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -Wno-nested-anon-type
s -O3  -fuse-ld=lld -Wl,--color-diagnostics -Wl,-allow-shlib-undefined    -Wl,-O3 -Wl,--gc-sections tools/clang/tools/extra/clangd/index/remote/server/CMakeFiles/clangd-index-server.dir/Server.cpp.o  -o bin/clangd-index-server  -Wl,-rpath,"
\$ORIGIN/../lib"  lib/libLLVMSupport.a  -lpthread  lib/libclangDaemon.a  lib/libRemoteIndexProtos.a  lib/libclangdRemoteMarshalling.a  /usr/lib/x86_64-linux-gnu/libgrpc++.a  /usr/lib/x86_64-linux-gnu/libgrpc.a  lib/libclangDaemon.a  lib/lib
clangTidyAndroidModule.a  lib/libclangTidyAbseilModule.a  lib/libclangTidyBoostModule.a  lib/libclangTidyCERTModule.a  lib/libclangTidyDarwinModule.a  lib/libclangTidyFuchsiaModule.a  lib/libclangTidyHICPPModule.a  lib/libclangTidyBugproneM
odule.a  lib/libclangTidyCppCoreGuidelinesModule.a  lib/libclangTidyGoogleModule.a  lib/libclangTidyLinuxKernelModule.a  lib/libclangTidyLLVMModule.a  lib/libclangTidyLLVMLibcModule.a  lib/libclangTidyMiscModule.a  lib/libclangTidyModernize
Module.a  lib/libclangTidyObjCModule.a  lib/libclangTidyOpenMPModule.a  lib/libclangTidyPerformanceModule.a  lib/libclangTidyPortabilityModule.a  lib/libclangTidyReadabilityModule.a  lib/libclangTidyZirconModule.a  lib/libclangTidyMPIModule
.a  lib/libclangTidyUtils.a  lib/libclangTidy.a  lib/libclangStaticAnalyzerFrontend.a  lib/libclangTransformer.a  lib/libclangStaticAnalyzerCheckers.a  lib/libclangStaticAnalyzerCore.a  lib/libclangCrossTU.a  lib/libclangTooling.a  lib/libc
langToolingRefactoring.a  lib/libclangIndex.a  lib/libclangFormat.a  lib/libclangToolingInclusions.a  lib/libclangToolingSyntax.a  lib/libclangFrontend.a  lib/libclangDriver.a  lib/libclangSerialization.a  lib/libclangParse.a  lib/libclangS
ema.a  lib/libclangAnalysis.a  lib/libclangASTMatchers.a  lib/libclangEdit.a  lib/libclangToolingCore.a  lib/libclangAST.a  lib/libclangRewrite.a  lib/libclangLex.a  lib/libclangBasic.a  lib/libRemoteIndexProtos.a  /usr/lib/x86_64-linux-gnu
/libgrpc++.a  lib/libclangdSupport.a  lib/libLLVMAArch64Info.a  lib/libLLVMAMDGPUInfo.a  lib/libLLVMARMInfo.a  lib/libLLVMAVRInfo.a  lib/libLLVMBPFInfo.a  lib/libLLVMHexagonInfo.a  lib/libLLVMLanaiInfo.a  lib/libLLVMMipsInfo.a  lib/libLLVMM
SP430Info.a  lib/libLLVMNVPTXInfo.a  lib/libLLVMPowerPCInfo.a  lib/libLLVMRISCVInfo.a  lib/libLLVMSparcInfo.a  lib/libLLVMSystemZInfo.a  lib/libLLVMWebAssemblyInfo.a  lib/libLLVMX86Info.a  lib/libLLVMXCoreInfo.a  lib/libLLVMFrontendOpenMP.a
  lib/libLLVMTransformUtils.a  lib/libLLVMAnalysis.a  lib/libLLVMProfileData.a  lib/libLLVMObject.a  lib/libLLVMBitReader.a  lib/libLLVMCore.a  lib/libLLVMRemarks.a  lib/libLLVMBitstreamReader.a  lib/libLLVMMCParser.a  lib/libLLVMMC.a  lib/
libLLVMDebugInfoCodeView.a  lib/libLLVMDebugInfoMSF.a  lib/libLLVMTextAPI.a  lib/libLLVMBinaryFormat.a  lib/libLLVMOption.a  lib/libLLVMSupport.a  -lz  -lrt  -ldl  -ltinfo  -lpthread  -lm  lib/libLLVMDemangle.a  /usr/lib/x86_64-linux-gnu/li
bprotobuf.a && :
ld.lld: error: undefined symbol: RSA_free
>>> referenced by json_token.o:(grpc_auth_json_key_destruct(grpc_auth_json_key*)) in archive /usr/lib/x86_64-linux-gnu/libgrpc.a

ld.lld: error: undefined symbol: BIO_s_mem
>>> referenced by json_token.o:(grpc_auth_json_key_create_from_json(grpc_json const*)) in archive /usr/lib/x86_64-linux-gnu/libgrpc.a
>>> referenced by aes_gcm.o:(.text+0x15F) in archive /usr/lib/x86_64-linux-gnu/libgrpc.a
>>> referenced by ssl_transport_security.o:(.text+0x12A1) in archive /usr/lib/x86_64-linux-gnu/libgrpc.a

ld.lld: error: undefined symbol: BIO_new
>>> referenced by json_token.o:(grpc_auth_json_key_create_from_json(grpc_json const*)) in archive /usr/lib/x86_64-linux-gnu/libgrpc.a
>>> referenced by aes_gcm.o:(.text+0x167) in archive /usr/lib/x86_64-linux-gnu/libgrpc.a
>>> referenced by ssl_transport_security.o:(.text+0x12AD) in archive /usr/lib/x86_64-linux-gnu/libgrpc.a

ld.lld: error: undefined symbol: BIO_puts
>>> referenced by json_token.o:(grpc_auth_json_key_create_from_json(grpc_json const*)) in archive /usr/lib/x86_64-linux-gnu/libgrpc.a

ld.lld: error: undefined symbol: BIO_free
>>> referenced by json_token.o:(grpc_auth_json_key_create_from_json(grpc_json const*)) in archive /usr/lib/x86_64-linux-gnu/libgrpc.a
>>> referenced by json_token.o:(grpc_auth_json_key_create_from_json(grpc_json const*)) in archive /usr/lib/x86_64-linux-gnu/libgrpc.a
>>> referenced by ssl_transport_security.o:(.text+0x1E7) in archive /usr/lib/x86_64-linux-gnu/libgrpc.a
>>> referenced by ssl_transport_security.o:(.text+0x342) in archive /usr/lib/x86_64-linux-gnu/libgrpc.a
>>> referenced by ssl_transport_security.o:(.text+0x38A) in archive /usr/lib/x86_64-linux-gnu/libgrpc.a
>>> referenced by ssl_transport_security.o:(.text+0xB46) in archive /usr/lib/x86_64-linux-gnu/libgrpc.a
>>> referenced by ssl_transport_security.o:(.text+0xE3D) in archive /usr/lib/x86_64-linux-gnu/libgrpc.a
>>> referenced by ssl_transport_security.o:(.text+0xEBE) in archive /usr/lib/x86_64-linux-gnu/libgrpc.a
>>> referenced by ssl_transport_security.o:(.text+0xF6C) in archive /usr/lib/x86_64-linux-gnu/libgrpc.a
>>> referenced by ssl_transport_security.o:(.text+0xFD4) in archive /usr/lib/x86_64-linux-gnu/libgrpc.a
>>> referenced 4 more times

ld.lld: error: undefined symbol: PEM_read_bio_RSAPrivateKey
>>> referenced by json_token.o:(grpc_auth_json_key_create_from_json(grpc_json const*)) in archive /usr/lib/x86_64-linux-gnu/libgrpc.a

ld.lld: error: undefined symbol: EVP_PKEY_new
>>> referenced by json_token.o:(compute_and_encode_signature(grpc_auth_json_key const*, char const*, char const*)) in archive /usr/lib/x86_64-linux-gnu/libgrpc.a

ld.lld: error: undefined symbol: EVP_MD_CTX_new
>>> referenced by json_token.o:(compute_and_encode_signature(grpc_auth_json_key const*, char const*, char const*)) in archive /usr/lib/x86_64-linux-gnu/libgrpc.a

ld.lld: error: undefined symbol: EVP_PKEY_set1_RSA
>>> referenced by json_token.o:(compute_and_encode_signature(grpc_auth_json_key const*, char const*, char const*)) in archive /usr/lib/x86_64-linux-gnu/libgrpc.a

ld.lld: error: undefined symbol: EVP_DigestSignInit
>>> referenced by json_token.o:(compute_and_encode_signature(grpc_auth_json_key const*, char const*, char const*)) in archive /usr/lib/x86_64-linux-gnu/libgrpc.a

ld.lld: error: undefined symbol: EVP_PKEY_free
>>> referenced by json_token.o:(compute_and_encode_signature(grpc_auth_json_key const*, char const*, char const*)) in archive /usr/lib/x86_64-linux-gnu/libgrpc.a
>>> referenced by json_token.o:(compute_and_encode_signature(grpc_auth_json_key const*, char const*, char const*)) in archive /usr/lib/x86_64-linux-gnu/libgrpc.a
>>> referenced by ssl_transport_security.o:(.text+0xEB0) in archive /usr/lib/x86_64-linux-gnu/libgrpc.a
>>> referenced by ssl_transport_security.o:(.text+0xFCC) in archive /usr/lib/x86_64-linux-gnu/libgrpc.a

ld.lld: error: undefined symbol: EVP_MD_CTX_free
>>> referenced by json_token.o:(compute_and_encode_signature(grpc_auth_json_key const*, char const*, char const*)) in archive /usr/lib/x86_64-linux-gnu/libgrpc.a
>>> referenced by json_token.o:(compute_and_encode_signature(grpc_auth_json_key const*, char const*, char const*)) in archive /usr/lib/x86_64-linux-gnu/libgrpc.a

ld.lld: error: undefined symbol: EVP_DigestUpdate
>>> referenced by json_token.o:(compute_and_encode_signature(grpc_auth_json_key const*, char const*, char const*)) in archive /usr/lib/x86_64-linux-gnu/libgrpc.a

ld.lld: error: undefined symbol: EVP_DigestSignFinal
>>> referenced by json_token.o:(compute_and_encode_signature(grpc_auth_json_key const*, char const*, char const*)) in archive /usr/lib/x86_64-linux-gnu/libgrpc.a
>>> referenced by json_token.o:(compute_and_encode_signature(grpc_auth_json_key const*, char const*, char const*)) in archive /usr/lib/x86_64-linux-gnu/libgrpc.a

ld.lld: error: undefined symbol: EVP_sha256
>>> referenced by json_token.o:(openssl_digest_from_algorithm(char const*)) in archive /usr/lib/x86_64-linux-gnu/libgrpc.a
>>> referenced by aes_gcm.o:(.text+0x5A) in archive /usr/lib/x86_64-linux-gnu/libgrpc.a

ld.lld: error: undefined symbol: HMAC_CTX_new
>>> referenced by aes_gcm.o:(.text+0x49) in archive /usr/lib/x86_64-linux-gnu/libgrpc.a

ld.lld: error: undefined symbol: HMAC_Init_ex
>>> referenced by aes_gcm.o:(.text+0x70) in archive /usr/lib/x86_64-linux-gnu/libgrpc.a

ld.lld: error: undefined symbol: HMAC_Update
>>> referenced by aes_gcm.o:(.text+0x84) in archive /usr/lib/x86_64-linux-gnu/libgrpc.a
>>> referenced by aes_gcm.o:(.text+0x9A) in archive /usr/lib/x86_64-linux-gnu/libgrpc.a

ld.lld: error: undefined symbol: HMAC_Final
>>> referenced by aes_gcm.o:(.text+0xAD) in archive /usr/lib/x86_64-linux-gnu/libgrpc.a

ld.lld: error: undefined symbol: HMAC_CTX_free
>>> referenced by aes_gcm.o:(.text+0xB9) in archive /usr/lib/x86_64-linux-gnu/libgrpc.a
>>> referenced by aes_gcm.o:(.text+0xD4) in archive /usr/lib/x86_64-linux-gnu/libgrpc.a

ld.lld: error: too many errors emitted, stopping now (use -error-limit=0 to see all errors)
clang: error: linker command failed with exit code 1 (use -v to see invocation)

So I suspect once we deal with the libgrpc++.a errors from above we'd have to statically link LibSSL too :(

kbobyrev added a comment.EditedAug 11 2020, 5:48 AM

Easy way to play around some of the things:

~/playground/grpc-static-linking kbobyrev@kbobyrev-workstation.muc.corp.google.com
λ cat HelloGRPC.cpp
#include <grpc++/grpc++.h>
#include <iostream>

int main() {
  const auto Channel =
      grpc::CreateChannel("0.0.0.0:5000", grpc::InsecureChannelCredentials());
}

~/playground/grpc-static-linking kbobyrev@kbobyrev-workstation.muc.corp.google.com
λ clang++ HelloGRPC.cpp -L /usr/lib/x86_64-linux-gnu/libgrpc++.a -L /usr/lib/x86_64-linux-gnu/libgrpc++_reflection.so
/usr/bin/ld: /tmp/HelloGRPC-711a27.o: in function `grpc::CreateChannel(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::shared_ptr<grpc_impl::ChannelCredentials> const&)':
HelloGRPC.cpp:(.text+0xf7): undefined reference to `grpc_impl::CreateChannelImpl(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::shared_ptr<grpc_impl::ChannelCredentials> const&)'
/usr/bin/ld: /tmp/HelloGRPC-711a27.o: in function `grpc::InsecureChannelCredentials()':
HelloGRPC.cpp:(.text+0x127): undefined reference to `grpc_impl::InsecureChannelCredentials()'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Aww, actually no only LibSSL. I'll have to link all the libraries libgrpc++.a is depending on which means I'll have to find all of them somehow: LibSSL, libcares, libcrypto, abseil... Seems like the easiest way is to check gRPC into LLVM or simply disallow static builds with system-installed libs :(

This is a full reproducer of what would work with grpc++ built from source. Seems like the dependencies are pulled by CMake and this way it actually links correctly.

~/playground/grpc-static-linking/build kbobyrev@kbobyrev-workstation.muc.corp.google.com
λ cat ../CMakeLists.txt
project(HelloGRPC)
cmake_minimum_required(VERSION 3.16)

add_executable(HelloGRPC HelloGRPC.cpp)

set(protobuf_MODULE_COMPATIBLE TRUE)
find_package(Protobuf CONFIG REQUIRED HINTS ${GRPC_INSTALL_PATH})
message(STATUS "Using protobuf ${protobuf_VERSION}")
find_package(gRPC CONFIG REQUIRED HINTS ${GRPC_INSTALL_PATH})
message(STATUS "Using gRPC ${gRPC_VERSION}")

include_directories(${Protobuf_INCLUDE_DIRS})

# gRPC CMake CONFIG gives the libraries slightly odd names, make them match
# the conventional system-installed names.
set_target_properties(protobuf::libprotobuf PROPERTIES IMPORTED_GLOBAL TRUE)
add_library(protobuf ALIAS protobuf::libprotobuf)
set_target_properties(gRPC::grpc++ PROPERTIES IMPORTED_GLOBAL TRUE)
add_library(grpc++ ALIAS gRPC::grpc++)

set(GRPC_CPP_PLUGIN $<TARGET_FILE:gRPC::grpc_cpp_plugin>)
set(PROTOC ${Protobuf_PROTOC_EXECUTABLE})

target_link_libraries(HelloGRPC grpc++)

~/playground/grpc-static-linking/build kbobyrev@kbobyrev-workstation.muc.corp.google.com
λ cat ../HelloGRPC.cpp
#include <iostream>
#include "/usr/local/google/home/kbobyrev/software/grpc-latest/include/grpc++/grpc++.h"

int main() {
  const auto Channel =
      grpc::CreateChannel("0.0.0.0:5000", grpc::InsecureChannelCredentials());
}

~/playground/grpc-static-linking/build kbobyrev@kbobyrev-workstation.muc.corp.google.com
λ cmake -G Ninja -DCMAKE_EXPORT_COMPILE_COMMANDS=On -DGRPC_INSTALL_PATH=/usr/local/google/home/kbobyrev/software/grpc-latest ../
-- Using protobuf
-- Using gRPC 1.30.0
-- Configuring done
-- Generating done
-- Build files have been written to: /usr/local/google/home/kbobyrev/playground/grpc-static-linking/build

~/playground/grpc-static-linking/build kbobyrev@kbobyrev-workstation.muc.corp.google.com
λ ninja -v
[1/2] /usr/bin/c++  -DCARES_STATICLIB -D__CLANG_SUPPORT_DYN_ANNOTATION__ -isystem /usr/local/google/home/kbobyrev/software/grpc-latest/include  -MD -MT CMakeFiles/HelloGRPC.dir/HelloGRPC.cpp.o -MF CMakeFiles/HelloGRPC.dir/HelloGRPC.cpp.o.d -o CMakeFiles/HelloGRPC.dir/HelloGRPC.cpp.o -c ../HelloGRPC.cpp
[2/2] : && /usr/bin/c++     CMakeFiles/HelloGRPC.dir/HelloGRPC.cpp.o  -o HelloGRPC  /usr/local/google/home/kbobyrev/software/grpc-latest/lib/libgrpc++.a  /usr/local/google/home/kbobyrev/software/grpc-latest/lib/libprotobuf.a  /usr/local/google/home/kbobyrev/software/grpc-latest/lib/libgrpc.a  /usr/local/google/home/kbobyrev/software/grpc-latest/lib/libssl.a  /usr/local/google/home/kbobyrev/software/grpc-latest/lib/libcrypto.a  /usr/local/google/home/kbobyrev/software/grpc-latest/lib/libz.a  /usr/local/google/home/kbobyrev/software/grpc-latest/lib/libcares.a  -lnsl  /usr/local/google/home/kbobyrev/software/grpc-latest/lib/libabsl_bad_optional_access.a  /usr/local/google/home/kbobyrev/software/grpc-latest/lib/libgpr.a  /usr/local/google/home/kbobyrev/software/grpc-latest/lib/libabsl_time.a  /usr/local/google/home/kbobyrev/software/grpc-latest/lib/libabsl_civil_time.a  /usr/local/google/home/kbobyrev/software/grpc-latest/lib/libabsl_time_zone.a  /usr/local/google/home/kbobyrev/software/grpc-latest/lib/libabsl_str_format_internal.a  /usr/local/google/home/kbobyrev/software/grpc-latest/lib/libabsl_strings.a  /usr/local/google/home/kbobyrev/software/grpc-latest/lib/libabsl_strings_internal.a  /usr/local/google/home/kbobyrev/software/grpc-latest/lib/libabsl_base.a  /usr/local/google/home/kbobyrev/software/grpc-latest/lib/libabsl_dynamic_annotations.a  /usr/local/google/home/kbobyrev/software/grpc-latest/lib/libabsl_spinlock_wait.a  -lpthread  /usr/lib/x86_64-linux-gnu/librt.so  /usr/local/google/home/kbobyrev/software/grpc-latest/lib/libabsl_int128.a  /usr/local/google/home/kbobyrev/software/grpc-latest/lib/libabsl_throw_delegate.a  /usr/local/google/home/kbobyrev/software/grpc-latest/lib/libabsl_raw_logging_internal.a  /usr/local/google/home/kbobyrev/software/grpc-latest/lib/libabsl_log_severity.a  /usr/local/google/home/kbobyrev/software/grpc-latest/lib/libaddress_sorting.a  /usr/local/google/home/kbobyrev/software/grpc-latest/lib/libupb.a  -ldl  -lrt  -lm  -lpthread && :
kbobyrev planned changes to this revision.Aug 12 2020, 12:54 AM

This is not an actual patch, so removing from reviews to reduce noise.