8251d8c255
Currently, grpc depends on the full host-grpc, which in turn depends on host versions of many other libraries. One of these, host-libabseil-cpp, also requires a host gcc 4.9 or larger, a dependency which is not met on CentOS 7. But in fact, the target grpc only needs the 'grpc_cpp_plugin' binary from host-grpc. And that binary does not depend on host-libabseil-cpp or other libraries, only on host-protobuf. Given the above, simplify the grpc/host-grpc situation. - Add a patch to the (host-)grpc CMakeLists.txt file to add an option to only build grpc_cpp_plugin. - Update grpc.mk and Config.in to remove the unnecessary dependencies, and change the host-grpc configure options to make cmake happy. The advantages of these changes are: - making grpc available to older hosts with gcc < 4.8, like CentOS 7 - significantly reducing the build time of host-grpc and its dependencies The patch was proposed upstream but not accepted with below rationale. Perhaps input from others can help in persuading upstream in a future attempt. 'What you're doing sounds like quite a narrow use case. But we simply cannot provide a cmake option for every possible scenario in the world. Introducing a new cmake option isn't for free and requires careful design and maintenance.' Nevertheless, given the benefits in terms of build time and dependency reduction, it makes sense to apply this patch in spite of the disadvantage of a local non-upstreamed patch. Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com> [Arnout: propagate removed dependency to collectd] Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
95 lines
3.3 KiB
Makefile
95 lines
3.3 KiB
Makefile
################################################################################
|
|
#
|
|
# grpc
|
|
#
|
|
################################################################################
|
|
|
|
GRPC_VERSION = 1.43.0
|
|
GRPC_SITE = $(call github,grpc,grpc,v$(GRPC_VERSION))
|
|
GRPC_LICENSE = Apache-2.0, BSD-3-Clause (third_party code), MPL-2.0 (etc/roots.pem)
|
|
GRPC_LICENSE_FILES = LICENSE
|
|
GRPC_CPE_ID_VENDOR = grpc
|
|
|
|
GRPC_INSTALL_STAGING = YES
|
|
|
|
# Need to use host grpc_cpp_plugin during cross compilation.
|
|
GRPC_DEPENDENCIES = c-ares host-grpc libabseil-cpp openssl protobuf re2 zlib
|
|
HOST_GRPC_DEPENDENCIES = host-protobuf
|
|
|
|
# gRPC_CARES_PROVIDER=package won't work because it requires c-ares to have
|
|
# installed a cmake config file, but buildroot uses c-ares' autotools build,
|
|
# which doesn't do this. These CARES settings trick the gRPC cmake code into
|
|
# not looking for c-ares at all and yet still linking with the library.
|
|
GRPC_CONF_OPTS = \
|
|
-DgRPC_ABSL_PROVIDER=package \
|
|
-D_gRPC_CARES_LIBRARIES=cares \
|
|
-DgRPC_CARES_PROVIDER=none \
|
|
-DgRPC_PROTOBUF_PROVIDER=package \
|
|
-DgRPC_RE2_PROVIDER=package \
|
|
-DgRPC_SSL_PROVIDER=package \
|
|
-DgRPC_ZLIB_PROVIDER=package \
|
|
-DgRPC_BUILD_GRPC_CPP_PLUGIN=OFF \
|
|
-DgRPC_BUILD_GRPC_CSHARP_PLUGIN=OFF \
|
|
-DgRPC_BUILD_GRPC_NODE_PLUGIN=OFF \
|
|
-DgRPC_BUILD_GRPC_OBJECTIVE_C_PLUGIN=OFF \
|
|
-DgRPC_BUILD_GRPC_PHP_PLUGIN=OFF \
|
|
-DgRPC_BUILD_GRPC_PYTHON_PLUGIN=OFF \
|
|
-DgRPC_BUILD_GRPC_RUBY_PLUGIN=OFF
|
|
|
|
# grpc can use __atomic builtins, so we need to link with
|
|
# libatomic when available
|
|
ifeq ($(BR2_TOOLCHAIN_HAS_LIBATOMIC),y)
|
|
GRPC_CONF_OPTS += -DCMAKE_EXE_LINKER_FLAGS=-latomic
|
|
endif
|
|
|
|
GRPC_CFLAGS = $(TARGET_CFLAGS)
|
|
GRPC_CXXFLAGS = $(TARGET_CXXFLAGS)
|
|
|
|
# Set GPR_DISABLE_WRAPPED_MEMCPY otherwise build will fail on x86_64 with uclibc
|
|
# because grpc tries to link with memcpy@GLIBC_2.2.5
|
|
ifeq ($(BR2_x86_64):$(BR2_TOOLCHAIN_USES_GLIBC),y:)
|
|
GRPC_CFLAGS += -DGPR_DISABLE_WRAPPED_MEMCPY
|
|
GRPC_CXXFLAGS += -DGPR_DISABLE_WRAPPED_MEMCPY
|
|
endif
|
|
|
|
ifeq ($(BR2_TOOLCHAIN_HAS_GCC_BUG_85180),y)
|
|
GRPC_CFLAGS += -O0
|
|
GRPC_CXXFLAGS += -O0
|
|
endif
|
|
|
|
# Toolchains older than gcc5 will fail to compile with -0s due to:
|
|
# error: failure memory model cannot be stronger than success memory model for
|
|
# '__atomic_compare_exchange', so we use -O2 in these cases
|
|
ifeq ($(BR2_TOOLCHAIN_GCC_AT_LEAST_5):$(BR2_OPTIMIZE_S),:y)
|
|
GRPC_CFLAGS += -O2
|
|
GRPC_CXXFLAGS += -O2
|
|
endif
|
|
|
|
GRPC_CONF_OPTS += \
|
|
-DCMAKE_C_FLAGS="$(GRPC_CFLAGS)" \
|
|
-DCMAKE_CXX_FLAGS="$(GRPC_CXXFLAGS)"
|
|
|
|
# For host-grpc, we only need the 'grpc_cpp_plugin' binary, which is needed for
|
|
# target grpc compilation. To avoid unnecessary build steps and host
|
|
# dependencies, supply enough options to pass the configure checks without
|
|
# requiring other host packages, unless those needed by grpc_cpp_plugin.
|
|
HOST_GRPC_CONF_OPTS = \
|
|
-DgRPC_PROTOBUF_PROVIDER=package \
|
|
-DgRPC_ABSL_PROVIDER=none \
|
|
-DgRPC_CARES_PROVIDER=none \
|
|
-DgRPC_RE2_PROVIDER=none \
|
|
-DgRPC_SSL_PROVIDER=none \
|
|
-DgRPC_ZLIB_PROVIDER=none \
|
|
-DgRPC_BUILD_CODEGEN=OFF \
|
|
-DgRPC_BUILD_CSHARP_EXT=OFF \
|
|
-DgRPC_BUILD_PLUGIN_SUPPORT_ONLY=ON \
|
|
-DgRPC_BUILD_GRPC_CSHARP_PLUGIN=OFF \
|
|
-DgRPC_BUILD_GRPC_NODE_PLUGIN=OFF \
|
|
-DgRPC_BUILD_GRPC_OBJECTIVE_C_PLUGIN=OFF \
|
|
-DgRPC_BUILD_GRPC_PHP_PLUGIN=OFF \
|
|
-DgRPC_BUILD_GRPC_PYTHON_PLUGIN=OFF \
|
|
-DgRPC_BUILD_GRPC_RUBY_PLUGIN=OFF
|
|
|
|
$(eval $(cmake-package))
|
|
$(eval $(host-cmake-package))
|