[v2,4/5] grpc: new package

Message ID 20180521175310.18563-5-charles.hardin@storagecraft.com
State Changes Requested
Headers show
Series
  • add support for gRPC C and C++ bindings
Related show

Commit Message

Charles Hardin May 21, 2018, 5:53 p.m.
From: Charles Hardin <charles.hardin@storagecraft.com>

add the gRPC package from Google's github repo. This is
currently just installing the C and C++ libraries on the
target installation for now. Some effort could be made
to add the python bindings as a subsequent patch.

This also adds a patch to specify the protoc to use since
that is provided by buildroot and not the host in addition
to overriding the ldconfig command since that doesn't apply
to the buildroot compile.

NOTE: This doesn't add the python or any other bindings

Signed-off-by: Charles Hardin <charles.hardin@storagecraft.com>
---
 package/Config.in                                  |   1 +
 ...onmental-overrides-of-protoc-dtrace-and-l.patch |  72 +++++++++++++++
 package/grpc/Config.in                             |  19 ++++
 package/grpc/grpc.hash                             |   2 +
 package/grpc/grpc.mk                               | 101 +++++++++++++++++++++
 5 files changed, 195 insertions(+)
 create mode 100644 package/grpc/0001-Allow-environmental-overrides-of-protoc-dtrace-and-l.patch
 create mode 100644 package/grpc/Config.in
 create mode 100644 package/grpc/grpc.hash
 create mode 100644 package/grpc/grpc.mk

Comments

Thomas Petazzoni June 28, 2018, 9:36 p.m. | #1
Hello Charles,

On Mon, 21 May 2018 10:53:09 -0700, charles.hardin@storagecraft.com
wrote:
> From: Charles Hardin <charles.hardin@storagecraft.com>
> 
> add the gRPC package from Google's github repo. This is
> currently just installing the C and C++ libraries on the
> target installation for now. Some effort could be made
> to add the python bindings as a subsequent patch.
> 
> This also adds a patch to specify the protoc to use since
> that is provided by buildroot and not the host in addition
> to overriding the ldconfig command since that doesn't apply
> to the buildroot compile.
> 
> NOTE: This doesn't add the python or any other bindings
> 
> Signed-off-by: Charles Hardin <charles.hardin@storagecraft.com>

I tried this here, and unfortunately it doesn't build.

First, the CFLAGS/CXXFLAGS/LDFLAGS passed as make options were
completely overriding the ones from GRPC makefile, causing a build
failure. I fixed that with:

diff --git a/package/grpc/grpc.mk b/package/grpc/grpc.mk
index 738cd7f851..da5def4ceb 100644
--- a/package/grpc/grpc.mk
+++ b/package/grpc/grpc.mk
@@ -15,7 +15,8 @@ HOST_GRPC_DEPENDENCIES = host-c-ares host-protobuf host-openssl
 
 GRPC_INSTALL_STAGING = YES
 
-GRPC_CROSS_MAKE_OPTS_BASE = \
+GRPC_MAKE_ENV = \
+       $(TARGET_MAKE_ENV) \
        GRPC_CROSS_COMPILE="true" \
        LDCONFIG=/bin/true \
        HOST_CC="$(HOSTCC)" \
@@ -34,15 +35,12 @@ GRPC_CROSS_MAKE_OPTS_BASE = \
        STRIP=/bin/true
 
 GRPC_MAKE_OPTS = \
-       $(GRPC_CROSS_MAKE_OPTS_BASE) \
        PROTOC="$(HOST_DIR)/usr/bin/protoc"
 
 GRPC_INSTALL_TARGET_OPTS = \
-       $(GRPC_CROSS_MAKE_OPTS_BASE) \
        prefix="$(TARGET_DIR)/usr"
 
 GRPC_INSTALL_STAGING_OPTS = \
-       $(GRPC_CROSS_MAKE_OPTS_BASE) \
        prefix="$(STAGING_DIR)/usr"
 
 ifeq ($(BR2_SHARED_LIBS),y)
@@ -60,17 +58,17 @@ GRPC_INSTALL_TARGETS = install-shared_c install-shared_cxx
 endif
 
 define GRPC_BUILD_CMDS
-       $(TARGET_MAKE_ENV) $(MAKE) $(GRPC_MAKE_OPTS) -C $(@D) \
+       $(GRPC_MAKE_ENV) $(MAKE) $(GRPC_MAKE_OPTS) -C $(@D) \
                $(GRPC_BUILD_TARGETS)
 endef
 
 define GRPC_INSTALL_STAGING_CMDS
-       $(TARGET_MAKE_ENV) $(MAKE) $(GRPC_INSTALL_STAGING_OPTS) -C $(@D) \
+       $(GRPC_MAKE_ENV) $(MAKE) $(GRPC_INSTALL_STAGING_OPTS) -C $(@D) \
                $(GRPC_STAGING_TARGETS)
 endef
 
 define GRPC_INSTALL_TARGET_CMDS
-       $(TARGET_MAKE_ENV) $(MAKE) $(GRPC_INSTALL_TARGET_OPTS) -C $(@D) \
+       $(GRPC_MAKE_ENV) $(MAKE) $(GRPC_INSTALL_TARGET_OPTS) -C $(@D) \
                $(GRPC_INSTALL_TARGETS)
 endef

With that in place, the GRPC build moved on, but failed at a later point, with:

[HOSTCXX] Compiling src/compiler/cpp_generator.cc
[HOSTCXX] Compiling src/compiler/csharp_generator.cc
[HOSTCXX] Compiling src/compiler/node_generator.cc
In file included from /usr/include/c++/7/ext/string_conversions.h:41:0,
                 from /usr/include/c++/7/bits/basic_string.h:6349,
                 from /usr/include/c++/7/string:52,
                 from /usr/include/c++/7/stdexcept:39,
                 from /usr/include/c++/7/array:39,
                 from /usr/include/c++/7/tuple:39,
                 from /usr/include/c++/7/bits/stl_map.h:63,
                 from /usr/include/c++/7/map:61,
                 from src/compiler/cpp_generator.cc:19:
/usr/include/c++/7/cstdlib:131:11: error: ‘::at_quick_exit’ has not been declared
   using ::at_quick_exit;
           ^~~~~~~~~~~~~
/usr/include/c++/7/cstdlib:154:11: error: ‘::quick_exit’ has not been declared
   using ::quick_exit;
           ^~~~~~~~~~
[HOSTCXX] Compiling src/compiler/objective_c_generator.cc
In file included from /usr/include/c++/7/ext/string_conversions.h:41:0,
                 from /usr/include/c++/7/bits/basic_string.h:6349,
                 from /usr/include/c++/7/string:52,
                 from /usr/include/c++/7/stdexcept:39,
                 from /usr/include/c++/7/array:39,
                 from /usr/include/c++/7/tuple:39,
                 from /usr/include/c++/7/bits/stl_map.h:63,
                 from /usr/include/c++/7/map:61,
                 from src/compiler/csharp_generator.cc:20:
/usr/include/c++/7/cstdlib:131:11: error: ‘::at_quick_exit’ has not been declared
   using ::at_quick_exit;
           ^~~~~~~~~~~~~
/usr/include/c++/7/cstdlib:154:11: error: ‘::quick_exit’ has not been declared
   using ::quick_exit;
           ^~~~~~~~~~
In file included from ./src/compiler/cpp_generator.h:26:0,
                 from src/compiler/cpp_generator.cc:21:
/usr/include/c++/7/memory: In function ‘void* std::align(std::size_t, std::size_t, void*&, std::size_t&)’:
/usr/include/c++/7/memory:116:58: error: cast from ‘void*’ to ‘uintptr_t {aka unsigned int}’ loses precision [-fpermissive]
   const auto __intptr = reinterpret_cast<uintptr_t>(__ptr);

And more of those issues. Here is the defconfig I have used:

BR2_arm=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y
BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y
BR2_TOOLCHAIN_EXTERNAL_URL="http://autobuild.buildroot.org/toolchains/tarballs/br-arm-full-2018.02-891-g046c5e2.tar.bz2"
BR2_TOOLCHAIN_EXTERNAL_GCC_4_9=y
BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_1=y
BR2_TOOLCHAIN_EXTERNAL_LOCALE=y
# BR2_TOOLCHAIN_EXTERNAL_HAS_THREADS_DEBUG is not set
BR2_TOOLCHAIN_EXTERNAL_CXX=y
BR2_INIT_NONE=y
BR2_SYSTEM_BIN_SH_NONE=y
# BR2_PACKAGE_BUSYBOX is not set
BR2_PACKAGE_GRPC=y
# BR2_TARGET_ROOTFS_TAR is not set

Could you have a look ?

I'll also do a regular review of the package in a separate e-mail, so
that you can take into account other comments at the same time.

Thanks!

Thomas
Charles Hardin June 28, 2018, 9:45 p.m. | #2
Hmm….

> On Jun 28, 2018, at 2:36 PM, Thomas Petazzoni <thomas.petazzoni@bootlin.com> wrote:
> 
> Hello Charles,
> 
> On Mon, 21 May 2018 10:53:09 -0700, charles.hardin@storagecraft.com
> wrote:
>> From: Charles Hardin <charles.hardin@storagecraft.com>
>> 
>> add the gRPC package from Google's github repo. This is
>> currently just installing the C and C++ libraries on the
>> target installation for now. Some effort could be made
>> to add the python bindings as a subsequent patch.
>> 
>> This also adds a patch to specify the protoc to use since
>> that is provided by buildroot and not the host in addition
>> to overriding the ldconfig command since that doesn't apply
>> to the buildroot compile.
>> 
>> NOTE: This doesn't add the python or any other bindings
>> 
>> Signed-off-by: Charles Hardin <charles.hardin@storagecraft.com>
> 
> I tried this here, and unfortunately it doesn't build.
> 


Ok - never tried “arm” builds - only mips and x86, so this is likely going to be a bit
more involved. But, I think this is a HOSTCXX problem - what is that version because
I barely recall that I have to build the gRPC proto gen tools on the host to generate
the stubs for the cross.

It’s entirely possible I just assumed the host toolchain will work - this is what we use
on the host.

> vagrant@dev:~/buildroot$ cc --version
> cc (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
> Copyright (C) 2015 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.  There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> 
> vagrant@dev:~/buildroot$ c++ --version
> c++ (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
> Copyright (C) 2015 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.  There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> 

So, it looks like it is a gcc 7 build on this host side?

> First, the CFLAGS/CXXFLAGS/LDFLAGS passed as make options were
> completely overriding the ones from GRPC makefile, causing a build
> failure. I fixed that with:
> 
> diff --git a/package/grpc/grpc.mk b/package/grpc/grpc.mk
> index 738cd7f851..da5def4ceb 100644
> --- a/package/grpc/grpc.mk
> +++ b/package/grpc/grpc.mk
> @@ -15,7 +15,8 @@ HOST_GRPC_DEPENDENCIES = host-c-ares host-protobuf host-openssl
> 
> GRPC_INSTALL_STAGING = YES
> 
> -GRPC_CROSS_MAKE_OPTS_BASE = \
> +GRPC_MAKE_ENV = \
> +       $(TARGET_MAKE_ENV) \
>        GRPC_CROSS_COMPILE="true" \
>        LDCONFIG=/bin/true \
>        HOST_CC="$(HOSTCC)" \
> @@ -34,15 +35,12 @@ GRPC_CROSS_MAKE_OPTS_BASE = \
>        STRIP=/bin/true
> 
> GRPC_MAKE_OPTS = \
> -       $(GRPC_CROSS_MAKE_OPTS_BASE) \
>        PROTOC="$(HOST_DIR)/usr/bin/protoc"
> 
> GRPC_INSTALL_TARGET_OPTS = \
> -       $(GRPC_CROSS_MAKE_OPTS_BASE) \
>        prefix="$(TARGET_DIR)/usr"
> 
> GRPC_INSTALL_STAGING_OPTS = \
> -       $(GRPC_CROSS_MAKE_OPTS_BASE) \
>        prefix="$(STAGING_DIR)/usr"
> 
> ifeq ($(BR2_SHARED_LIBS),y)
> @@ -60,17 +58,17 @@ GRPC_INSTALL_TARGETS = install-shared_c install-shared_cxx
> endif
> 
> define GRPC_BUILD_CMDS
> -       $(TARGET_MAKE_ENV) $(MAKE) $(GRPC_MAKE_OPTS) -C $(@D) \
> +       $(GRPC_MAKE_ENV) $(MAKE) $(GRPC_MAKE_OPTS) -C $(@D) \
>                $(GRPC_BUILD_TARGETS)
> endef
> 
> define GRPC_INSTALL_STAGING_CMDS
> -       $(TARGET_MAKE_ENV) $(MAKE) $(GRPC_INSTALL_STAGING_OPTS) -C $(@D) \
> +       $(GRPC_MAKE_ENV) $(MAKE) $(GRPC_INSTALL_STAGING_OPTS) -C $(@D) \
>                $(GRPC_STAGING_TARGETS)
> endef
> 
> define GRPC_INSTALL_TARGET_CMDS
> -       $(TARGET_MAKE_ENV) $(MAKE) $(GRPC_INSTALL_TARGET_OPTS) -C $(@D) \
> +       $(GRPC_MAKE_ENV) $(MAKE) $(GRPC_INSTALL_TARGET_OPTS) -C $(@D) \
>                $(GRPC_INSTALL_TARGETS)
> endef
> 
> With that in place, the GRPC build moved on, but failed at a later point, with:
> 
> [HOSTCXX] Compiling src/compiler/cpp_generator.cc
> [HOSTCXX] Compiling src/compiler/csharp_generator.cc
> [HOSTCXX] Compiling src/compiler/node_generator.cc
> In file included from /usr/include/c++/7/ext/string_conversions.h:41:0,
>                 from /usr/include/c++/7/bits/basic_string.h:6349,
>                 from /usr/include/c++/7/string:52,
>                 from /usr/include/c++/7/stdexcept:39,
>                 from /usr/include/c++/7/array:39,
>                 from /usr/include/c++/7/tuple:39,
>                 from /usr/include/c++/7/bits/stl_map.h:63,
>                 from /usr/include/c++/7/map:61,
>                 from src/compiler/cpp_generator.cc:19:
> /usr/include/c++/7/cstdlib:131:11: error: ‘::at_quick_exit’ has not been declared
>   using ::at_quick_exit;
>           ^~~~~~~~~~~~~
> /usr/include/c++/7/cstdlib:154:11: error: ‘::quick_exit’ has not been declared
>   using ::quick_exit;
>           ^~~~~~~~~~
> [HOSTCXX] Compiling src/compiler/objective_c_generator.cc
> In file included from /usr/include/c++/7/ext/string_conversions.h:41:0,
>                 from /usr/include/c++/7/bits/basic_string.h:6349,
>                 from /usr/include/c++/7/string:52,
>                 from /usr/include/c++/7/stdexcept:39,
>                 from /usr/include/c++/7/array:39,
>                 from /usr/include/c++/7/tuple:39,
>                 from /usr/include/c++/7/bits/stl_map.h:63,
>                 from /usr/include/c++/7/map:61,
>                 from src/compiler/csharp_generator.cc:20:
> /usr/include/c++/7/cstdlib:131:11: error: ‘::at_quick_exit’ has not been declared
>   using ::at_quick_exit;
>           ^~~~~~~~~~~~~
> /usr/include/c++/7/cstdlib:154:11: error: ‘::quick_exit’ has not been declared
>   using ::quick_exit;
>           ^~~~~~~~~~
> In file included from ./src/compiler/cpp_generator.h:26:0,
>                 from src/compiler/cpp_generator.cc:21:
> /usr/include/c++/7/memory: In function ‘void* std::align(std::size_t, std::size_t, void*&, std::size_t&)’:
> /usr/include/c++/7/memory:116:58: error: cast from ‘void*’ to ‘uintptr_t {aka unsigned int}’ loses precision [-fpermissive]
>   const auto __intptr = reinterpret_cast<uintptr_t>(__ptr);
> 
> And more of those issues. Here is the defconfig I have used:
> 
> BR2_arm=y
> BR2_TOOLCHAIN_EXTERNAL=y
> BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y
> BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y
> BR2_TOOLCHAIN_EXTERNAL_URL="http://autobuild.buildroot.org/toolchains/tarballs/br-arm-full-2018.02-891-g046c5e2.tar.bz2"
> BR2_TOOLCHAIN_EXTERNAL_GCC_4_9=y
> BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_1=y
> BR2_TOOLCHAIN_EXTERNAL_LOCALE=y
> # BR2_TOOLCHAIN_EXTERNAL_HAS_THREADS_DEBUG is not set
> BR2_TOOLCHAIN_EXTERNAL_CXX=y
> BR2_INIT_NONE=y
> BR2_SYSTEM_BIN_SH_NONE=y
> # BR2_PACKAGE_BUSYBOX is not set
> BR2_PACKAGE_GRPC=y
> # BR2_TARGET_ROOTFS_TAR is not set
> 
> Could you have a look ?
> 
> I'll also do a regular review of the package in a separate e-mail, so
> that you can take into account other comments at the same time.
> 
> Thanks!
> 
> Thomas
> -- 
> Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
> Embedded Linux and Kernel engineering
> https://bootlin.com
Thomas Petazzoni June 28, 2018, 9:47 p.m. | #3
Hello,

On Mon, 21 May 2018 10:53:09 -0700, charles.hardin@storagecraft.com
wrote:
> From: Charles Hardin <charles.hardin@storagecraft.com>
> 
> add the gRPC package from Google's github repo. This is
> currently just installing the C and C++ libraries on the
> target installation for now. Some effort could be made
> to add the python bindings as a subsequent patch.
> 
> This also adds a patch to specify the protoc to use since
> that is provided by buildroot and not the host in addition
> to overriding the ldconfig command since that doesn't apply
> to the buildroot compile.
> 
> NOTE: This doesn't add the python or any other bindings
> 
> Signed-off-by: Charles Hardin <charles.hardin@storagecraft.com>
> ---
>  package/Config.in                                  |   1 +
>  ...onmental-overrides-of-protoc-dtrace-and-l.patch |  72 +++++++++++++++
>  package/grpc/Config.in                             |  19 ++++
>  package/grpc/grpc.hash                             |   2 +
>  package/grpc/grpc.mk                               | 101 +++++++++++++++++++++
>  5 files changed, 195 insertions(+)
>  create mode 100644 package/grpc/0001-Allow-environmental-overrides-of-protoc-dtrace-and-l.patch
>  create mode 100644 package/grpc/Config.in
>  create mode 100644 package/grpc/grpc.hash
>  create mode 100644 package/grpc/grpc.mk

Please add an entry to the DEVELOPERS file when adding a new package.

> diff --git a/package/grpc/0001-Allow-environmental-overrides-of-protoc-dtrace-and-l.patch b/package/grpc/0001-Allow-environmental-overrides-of-protoc-dtrace-and-l.patch
> new file mode 100644
> index 0000000000..79a16786fd
> --- /dev/null
> +++ b/package/grpc/0001-Allow-environmental-overrides-of-protoc-dtrace-and-l.patch
> @@ -0,0 +1,72 @@
> +From dedb8e2ba6d1ea4ea5745d2d991bc333353478ba Mon Sep 17 00:00:00 2001
> +From: Charles Hardin <charles.hardin@storagecraft.com>
> +Date: Mon, 21 May 2018 09:39:31 -0700
> +Subject: [PATCH 1/1] Allow environmental overrides of protoc, dtrace, and
> + ldconfg

Please generate patches with "git format-patch -N" to not have "PATCH
1/1" but just "PATCH".

> +Some build systems (ie. buildroot) provide host tools as part
> +of the build and those paths are local to build.
>
> To address this
> +just do a "which" against the passed in PROTOC=my/path/protoc
> +and that can be used for the check version command.
> +
> +In addition, allow an ldconfig override on the install shared
> +library builds since this might be cross compiling or being
> +dumped into a chroot environment for something else.
> +
> +Signed-off-by: Charles Hardin <ckhardin@gmail.com>

I think this should be split in two patches:

 - One making sure the PROTOC and DTRACE variables get used everywhere
   applicable.

 - One introducing LDCONFIG

Also, it would be good to submit those patches upstream.


> diff --git a/package/grpc/Config.in b/package/grpc/Config.in
> new file mode 100644
> index 0000000000..d7096d0853
> --- /dev/null
> +++ b/package/grpc/Config.in
> @@ -0,0 +1,19 @@
> +config BR2_PACKAGE_GRPC
> +	bool "grpc"
> +	depends on BR2_INSTALL_LIBSTDCPP
> +	depends on BR2_TOOLCHAIN_HAS_THREADS

	depends on BR2_USE_MMU
	depends on BR2_USE_WCHAR

(because you select gtest)

        depends on BR2_PACKAGE_PROTOBUF_ARCH_SUPPORTS
        depends on BR2_HOST_GCC_AT_LEAST_4_8 # C++11
        depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_8 # C++11
        depends on !BR2_STATIC_LIBS

(because you select protobuf)

> +	select BR2_PACKAGE_C_ARES
> +	select BR2_PACKAGE_GFLAGS
> +	select BR2_PACKAGE_GTEST
> +	select BR2_PACKAGE_GTEST_GMOCK
> +	select BR2_PACKAGE_OPENSSL
> +	select BR2_PACKAGE_PROTOBUF
> +	select BR2_PACKAGE_ZLIB
> +	help
> +	  gRPC is Google's protocol buffer based implementation of a
> +	  remote procedure call protocol.
> +
> +	  http://www.grpc.io
> +
> +comment "grpc needs a toolchain w/ C++, threads"
> +	depends on !(BR2_INSTALL_LIBSTDCPP && BR2_TOOLCHAIN_HAS_THREADS)

Please update this comment according to the additional dependencies
above.

> +GRPC_VERSION = v1.11.1
> +GRPC_SITE = $(call github,grpc,grpc,$(GRPC_VERSION))
> +GRPC_LICENSE = BSD-3-Clause

The LICENSE file contains the Apache-2.0 license text. Are you sure
about BSD-3-Clause here ?

> +GRPC_LICENSE_FILES = LICENSE
> +
> +# Need a host protoc grpc plugin during the compilation
> +GRPC_DEPENDENCIES = host-grpc gflags gtest c-ares openssl protobuf zlib
> +HOST_GRPC_DEPENDENCIES = host-c-ares host-protobuf host-openssl
> +
> +GRPC_INSTALL_STAGING = YES
> +
> +GRPC_CROSS_MAKE_OPTS_BASE = \
> +	GRPC_CROSS_COMPILE="true" \
> +	LDCONFIG=/bin/true \
> +	HOST_CC="$(HOSTCC)" \
> +	HOST_CXX="$(HOSTCXX)" \
> +	HOST_LD="$(HOSTCC)" \
> +	HOST_LDXX="$(HOSTCXX)" \
> +	HOST_CPPFLAGS="$(HOST_CPPFLAGS)" \
> +	HOST_CFLAGS="$(HOST_CFLAGS)" \
> +	HOST_LDFLAGS="$(HOST_LDFLAGS)" \
> +	CC="$(TARGET_CC)" \
> +	CXX="$(TARGET_CXX)" \
> +	LD="$(TARGET_CC)" \
> +	LDXX="$(TARGET_CXX)" \
> +	CFLAGS="$(TARGET_CFLAGS)" \
> +	LDFLAGS="$(TARGET_LDFLAGS)" \
> +	STRIP=/bin/true

As explained in my other e-mail, pass this in the environment so that
the Makefile can do CFLAGS += something.

> +ifeq ($(BR2_SHARED_LIBS),y)
> +GRPC_BUILD_TARGETS = shared plugins
> +GRPC_STAGING_TARGETS = install-headers install-shared_c install-shared_cxx
> +GRPC_INSTALL_TARGETS = install-shared_c install-shared_cxx
> +else ifeq ($(BR2_STATIC_LIBS),y)
> +GRPC_BUILD_TARGETS = static plugins
> +GRPC_STAGING_TARGETS = install-headers install-static_c install-static_cxx
> +GRPC_INSTALL_TARGETS = install-static_c install-static_cxx
> +else
> +GRPC_BUILD_TARGETS = static shared plugins
> +GRPC_STAGING_TARGETS = install
> +GRPC_INSTALL_TARGETS = install-shared_c install-shared_cxx
> +endif

Perhaps this could be:

GRPC_BUILD_TARGETS = plugins
GRPC_STAGING_INSTALL_TARGETS = install-headers

ifeq ($(BR2_SHARED_LIBS)$(BR2_SHARED_STATIC_LIBS),y)
GRPC_BUILD_TARGETS += shared
GRPC_STAGING_INSTALL_TARGETS += install-shared_c install-shared_cxx
GRPC_TARGET_INSTALL_TARGETS += install-shared_c install-shared_cxx
endif

ifeq ($(BR2_STATIC_LIBS)$(BR2_SHARED_STATIC_LIBS),y)
GRPC_BUILD_TARGETS += static
GRPC_STAGING_INSTALL_TARGETS += install-static_c install-static_cxx
GRPC_TARGET_INSTALL_TARGETS += install-static_c install-static_cxx
endif

Best regards,

Thomas
Thomas Petazzoni June 28, 2018, 9:52 p.m. | #4
Hello,

On Thu, 28 Jun 2018 21:45:32 +0000, Charles Hardin wrote:

> Ok - never tried “arm” builds - only mips and x86, so this is likely going to be a bit
> more involved. But, I think this is a HOSTCXX problem - what is that version because
> I barely recall that I have to build the gRPC proto gen tools on the host to generate
> the stubs for the cross.

The problem is when building host tools with the host compiler, so the
target architecture shouldn't matter.

> So, it looks like it is a gcc 7 build on this host side?

Yes, I'm running a Fedora system with gcc 7.3.1.

I see on https://github.com/grpc/grpc/releases that they have newer
releases. Perhaps this issue has been fixed upstream.

Best regards,

Thomas

Patch

diff --git a/package/Config.in b/package/Config.in
index ecee4938c9..f4b9a7d7cd 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -1506,6 +1506,7 @@  menu "Other"
 	source "package/glibmm/Config.in"
 	source "package/glm/Config.in"
 	source "package/gmp/Config.in"
+	source "package/grpc/Config.in"
 	source "package/gsl/Config.in"
 	source "package/gtest/Config.in"
 	source "package/jemalloc/Config.in"
diff --git a/package/grpc/0001-Allow-environmental-overrides-of-protoc-dtrace-and-l.patch b/package/grpc/0001-Allow-environmental-overrides-of-protoc-dtrace-and-l.patch
new file mode 100644
index 0000000000..79a16786fd
--- /dev/null
+++ b/package/grpc/0001-Allow-environmental-overrides-of-protoc-dtrace-and-l.patch
@@ -0,0 +1,72 @@ 
+From dedb8e2ba6d1ea4ea5745d2d991bc333353478ba Mon Sep 17 00:00:00 2001
+From: Charles Hardin <charles.hardin@storagecraft.com>
+Date: Mon, 21 May 2018 09:39:31 -0700
+Subject: [PATCH 1/1] Allow environmental overrides of protoc, dtrace, and
+ ldconfg
+
+Some build systems (ie. buildroot) provide host tools as part
+of the build and those paths are local to build. To address this
+just do a "which" against the passed in PROTOC=my/path/protoc
+and that can be used for the check version command.
+
+In addition, allow an ldconfig override on the install shared
+library builds since this might be cross compiling or being
+dumped into a chroot environment for something else.
+
+Signed-off-by: Charles Hardin <ckhardin@gmail.com>
+---
+ Makefile | 13 +++++++------
+ 1 file changed, 7 insertions(+), 6 deletions(-)
+
+diff --git a/Makefile b/Makefile
+index fc4924fc7d..f516a35343 100644
+--- a/Makefile
++++ b/Makefile
+@@ -240,6 +240,7 @@ prefix ?= /usr/local
+ 
+ PROTOC ?= protoc
+ DTRACE ?= dtrace
++LDCONFIG ?= ldconfig
+ CONFIG ?= opt
+ # Doing X ?= Y is the same as:
+ # ifeq ($(origin X), undefined)
+@@ -524,9 +525,9 @@ endif # HAS_PKG_CONFIG
+ 
+ PERFTOOLS_CHECK_CMD = $(CC) $(CPPFLAGS) $(CFLAGS) -o $(TMPOUT) test/build/perftools.c -lprofiler $(LDFLAGS)
+ 
+-PROTOC_CHECK_CMD = which protoc > /dev/null
+-PROTOC_CHECK_VERSION_CMD = protoc --version | grep -q libprotoc.3
+-DTRACE_CHECK_CMD = which dtrace > /dev/null
++PROTOC_CHECK_CMD = which $(PROTOC) > /dev/null
++PROTOC_CHECK_VERSION_CMD = $(PROTOC) --version | grep -q libprotoc.3
++DTRACE_CHECK_CMD = which $(DTRACE) > /dev/null
+ SYSTEMTAP_HEADERS_CHECK_CMD = $(CC) $(CPPFLAGS) $(CFLAGS) -o $(TMPOUT) test/build/systemtap.c $(LDFLAGS)
+ 
+ ifndef REQUIRE_CUSTOM_LIBRARIES_$(CONFIG)
+@@ -2914,7 +2915,7 @@ else ifneq ($(SYSTEM),Darwin)
+ endif
+ ifneq ($(SYSTEM),MINGW32)
+ ifneq ($(SYSTEM),Darwin)
+-	$(Q) ldconfig || true
++	$(Q) $(LDCONFIG) || true
+ endif
+ endif
+ 
+@@ -2967,7 +2968,7 @@ else ifneq ($(SYSTEM),Darwin)
+ endif
+ ifneq ($(SYSTEM),MINGW32)
+ ifneq ($(SYSTEM),Darwin)
+-	$(Q) ldconfig || true
++	$(Q) $(LDCONFIG) || true
+ endif
+ endif
+ 
+@@ -2984,7 +2985,7 @@ else ifneq ($(SYSTEM),Darwin)
+ endif
+ ifneq ($(SYSTEM),MINGW32)
+ ifneq ($(SYSTEM),Darwin)
+-	$(Q) ldconfig || true
++	$(Q) $(LDCONFIG) || true
+ endif
+ endif
+ 
diff --git a/package/grpc/Config.in b/package/grpc/Config.in
new file mode 100644
index 0000000000..d7096d0853
--- /dev/null
+++ b/package/grpc/Config.in
@@ -0,0 +1,19 @@ 
+config BR2_PACKAGE_GRPC
+	bool "grpc"
+	depends on BR2_INSTALL_LIBSTDCPP
+	depends on BR2_TOOLCHAIN_HAS_THREADS
+	select BR2_PACKAGE_C_ARES
+	select BR2_PACKAGE_GFLAGS
+	select BR2_PACKAGE_GTEST
+	select BR2_PACKAGE_GTEST_GMOCK
+	select BR2_PACKAGE_OPENSSL
+	select BR2_PACKAGE_PROTOBUF
+	select BR2_PACKAGE_ZLIB
+	help
+	  gRPC is Google's protocol buffer based implementation of a
+	  remote procedure call protocol.
+
+	  http://www.grpc.io
+
+comment "grpc needs a toolchain w/ C++, threads"
+	depends on !(BR2_INSTALL_LIBSTDCPP && BR2_TOOLCHAIN_HAS_THREADS)
diff --git a/package/grpc/grpc.hash b/package/grpc/grpc.hash
new file mode 100644
index 0000000000..9f8e6869a5
--- /dev/null
+++ b/package/grpc/grpc.hash
@@ -0,0 +1,2 @@ 
+# Locally computed
+sha256 0068a0b11795ac89ba8f5cc7332cd8cd2870a2ee0016126f014ce0bc3004e590  grpc-v1.11.1.tar.gz
diff --git a/package/grpc/grpc.mk b/package/grpc/grpc.mk
new file mode 100644
index 0000000000..738cd7f851
--- /dev/null
+++ b/package/grpc/grpc.mk
@@ -0,0 +1,101 @@ 
+################################################################################
+#
+# grpc
+#
+################################################################################
+
+GRPC_VERSION = v1.11.1
+GRPC_SITE = $(call github,grpc,grpc,$(GRPC_VERSION))
+GRPC_LICENSE = BSD-3-Clause
+GRPC_LICENSE_FILES = LICENSE
+
+# Need a host protoc grpc plugin during the compilation
+GRPC_DEPENDENCIES = host-grpc gflags gtest c-ares openssl protobuf zlib
+HOST_GRPC_DEPENDENCIES = host-c-ares host-protobuf host-openssl
+
+GRPC_INSTALL_STAGING = YES
+
+GRPC_CROSS_MAKE_OPTS_BASE = \
+	GRPC_CROSS_COMPILE="true" \
+	LDCONFIG=/bin/true \
+	HOST_CC="$(HOSTCC)" \
+	HOST_CXX="$(HOSTCXX)" \
+	HOST_LD="$(HOSTCC)" \
+	HOST_LDXX="$(HOSTCXX)" \
+	HOST_CPPFLAGS="$(HOST_CPPFLAGS)" \
+	HOST_CFLAGS="$(HOST_CFLAGS)" \
+	HOST_LDFLAGS="$(HOST_LDFLAGS)" \
+	CC="$(TARGET_CC)" \
+	CXX="$(TARGET_CXX)" \
+	LD="$(TARGET_CC)" \
+	LDXX="$(TARGET_CXX)" \
+	CFLAGS="$(TARGET_CFLAGS)" \
+	LDFLAGS="$(TARGET_LDFLAGS)" \
+	STRIP=/bin/true
+
+GRPC_MAKE_OPTS = \
+	$(GRPC_CROSS_MAKE_OPTS_BASE) \
+	PROTOC="$(HOST_DIR)/usr/bin/protoc"
+
+GRPC_INSTALL_TARGET_OPTS = \
+	$(GRPC_CROSS_MAKE_OPTS_BASE) \
+	prefix="$(TARGET_DIR)/usr"
+
+GRPC_INSTALL_STAGING_OPTS = \
+	$(GRPC_CROSS_MAKE_OPTS_BASE) \
+	prefix="$(STAGING_DIR)/usr"
+
+ifeq ($(BR2_SHARED_LIBS),y)
+GRPC_BUILD_TARGETS = shared plugins
+GRPC_STAGING_TARGETS = install-headers install-shared_c install-shared_cxx
+GRPC_INSTALL_TARGETS = install-shared_c install-shared_cxx
+else ifeq ($(BR2_STATIC_LIBS),y)
+GRPC_BUILD_TARGETS = static plugins
+GRPC_STAGING_TARGETS = install-headers install-static_c install-static_cxx
+GRPC_INSTALL_TARGETS = install-static_c install-static_cxx
+else
+GRPC_BUILD_TARGETS = static shared plugins
+GRPC_STAGING_TARGETS = install
+GRPC_INSTALL_TARGETS = install-shared_c install-shared_cxx
+endif
+
+define GRPC_BUILD_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) $(GRPC_MAKE_OPTS) -C $(@D) \
+		$(GRPC_BUILD_TARGETS)
+endef
+
+define GRPC_INSTALL_STAGING_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) $(GRPC_INSTALL_STAGING_OPTS) -C $(@D) \
+		$(GRPC_STAGING_TARGETS)
+endef
+
+define GRPC_INSTALL_TARGET_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) $(GRPC_INSTALL_TARGET_OPTS) -C $(@D) \
+		$(GRPC_INSTALL_TARGETS)
+endef
+
+HOST_GRPC_MAKE_OPTS = \
+	CC="$(HOSTCC)" \
+	CXX="$(HOSTCXX)" \
+	LD="$(HOSTCC)" \
+	LDXX="$(HOSTCXX)" \
+	CPPLAGS="$(HOST_CPPFLAGS)" \
+	CFLAGS="$(HOST_CFLAGS)" \
+	CXXLAGS="$(HOST_CXXFLAGS)" \
+	LDFLAGS="$(HOST_LDFLAGS)" \
+	STRIP=/bin/true \
+	PROTOC="$(HOST_DIR)/usr/bin/protoc" \
+	prefix="$(HOST_DIR)"
+
+define HOST_GRPC_BUILD_CMDS
+	$(HOST_MAKE_ENV) $(MAKE) $(HOST_GRPC_MAKE_OPTS) -C $(@D) \
+		plugins
+endef
+
+define HOST_GRPC_INSTALL_CMDS
+	$(HOST_MAKE_ENV) $(MAKE) $(HOST_GRPC_MAKE_OPTS) -C $(@D) \
+		install-plugins
+endef
+
+$(eval $(generic-package))
+$(eval $(host-generic-package))