Skip to contentSkip to conversation

New package: gRPC, Google's remote procedue calss protocol.

PATCH New Mark Fine 2 participants 4 messages Sep 17, 2018 – Sep 18, 2018

lore
Share & tools
lore

Mark Fine

author
#0 lore raw

PATCH 1/1 New package: gRPC, Google's remote procedue calss protocol.

Introduces support for gRPC, Google's remote procedure call protocol. Includes a patch for supporting cross compilation. Also patches the c-ares package for host support.

---
 package/c-ares/c-ares.mk                    |  1 +
 package/grpc/0001-fixup-cross-compile.patch | 20 +++++++
 package/grpc/Config.in                      | 19 +++++++
 package/grpc/grpc.mk                        | 85 +++++++++++++++++++++++++++++
 4 files changed, 125 insertions(+)
 create mode 100644 package/grpc/0001-fixup-cross-compile.patch
 create mode 100644 package/grpc/Config.in
 create mode 100644 package/grpc/grpc.mk
package/c-ares/c-ares.mk +1 -0
index 67254244a1..76e9687b37 100644
@@ -15,3 +15,4 @@ C_ARES_LICENSE = MIT
 C_ARES_LICENSE_FILES = ares_mkquery.c
 
 $(eval $(autotools-package))
+$(eval $(host-autotools-package))
package/grpc/0001-fixup-cross-compile.patch new file +20 -0
new file mode 100644
index 0000000000..eaf262a95a
@@ -0,0 +1,20 @@
+diff -ur grpc_custom-v1.12.0/Makefile grpc_custom-v1.12.0.new/Makefile
+--- grpc_custom-v1.12.0/Makefile        2018-05-15 17:10:37.000000000 +0000
++++ grpc_custom-v1.12.0.new/Makefile    2018-08-30 20:28:31.357410038 +0000
+@@ -439,11 +439,11 @@
+ DEFINES += $(EXTRA_DEFINES)
+ LDLIBS += $(EXTRA_LDLIBS)
+
+-HOST_CPPFLAGS = $(CPPFLAGS)
+-HOST_CFLAGS = $(CFLAGS)
+-HOST_CXXFLAGS = $(CXXFLAGS)
+-HOST_LDFLAGS = $(LDFLAGS)
+-HOST_LDLIBS = $(LDLIBS)
++HOST_CPPFLAGS += $(CPPFLAGS)
++HOST_CFLAGS += $(CFLAGS)
++HOST_CXXFLAGS += $(CXXFLAGS)
++HOST_LDFLAGS += $(LDFLAGS)
++HOST_LDLIBS += $(LDLIBS)
+
+ # These are automatically computed variables.
+ # There shouldn't be any need to change anything from now on.
package/grpc/Config.in new file +19 -0
new file mode 100644
index 0000000000..237a9d5a15
@@ -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)
\ No newline at end of file
package/grpc/grpc.mk new file +85 -0

85 lines not on this page · raw message

Signature · 1 line
2.14.3 (Apple Git-98)
#1 lore raw

PATCH 1/1 New package: gRPC, Google's remote procedue calss protocol.

Hello Mark,

Thanks for this contribution! I believe I should mention that there was a previous attempt at adding a package for "grpc":

https://patchwork.ozlabs.org/patch/917779/
https://patchwork.ozlabs.org/patch/917778/

Perhaps there are some useful things to re-use from this previous contribution.

Quoted 5 lines · Mark Fine

Introduces support for gRPC, Google's remote procedure call protocol. Includes a patch for supporting cross compilation. Also patches the c-ares package for host support.

The commit title should be just:

grpc: new package

Quoted 2 lines
---
 package/c-ares/c-ares.mk                    |  1 +

This change should be a separate patch, coming before the patch adding grpc.

package/grpc/0001-fixup-cross-compile.patch

Quoted 5 lines
package/grpc/0001-fixup-cross-compile.patch new file +0 -0
new file mode 100644
index 0000000000..eaf262a95a

All patches need to have a description and Signed-off-by. Also, since the upstream project is using Git, we want the patches to be Git-formatted (i.e be generated by 'git format-patch').

Quoted 8 lines

+ # These are automatically computed variables.
+ # There shouldn't be any need to change anything from now on.

package/grpc/Config.in new file +0 -0
new file mode 100644
index 0000000000..237a9d5a15

package/grpc/Config.in line 7

Quoted 7 lines
package/grpc/Config.in new file +7 -0
@@ -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

Due to this select, you also need to replicate the following dependencies:

depends on BR2_USE_WCHAR
depends on BR2_USE_MMU

package/grpc/Config.in line 10

Quoted 3 lines
package/grpc/Config.in new file +3 -0
+	select BR2_PACKAGE_GTEST_GMOCK
+	select BR2_PACKAGE_OPENSSL
+	select BR2_PACKAGE_PROTOBUF

Due to this select, you also need to replicate the following dependencies:

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

package/grpc/Config.in line 19

Quoted 9 lines
package/grpc/Config.in new file +9 -0
+	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)

Make sure to update this comment with the new dependencies. Also, I personally prefer:

	depends on !A || !B || !C

instead of

	depends on !(A && B && C)
Quoted 1 line

\ No newline at end of file

Please make sure the file ends with a newline.

Quoted 6 lines
package/grpc/grpc.mk new file +0 -0
new file mode 100644
index 0000000000..a74dece713

package/grpc/grpc.mk line 9

Quoted 9 lines
package/grpc/grpc.mk new file +9 -0
@@ -0,0 +1,85 @@
+################################################################################
+#
+# grpc
+#
+################################################################################
+
+GRPC_VERSION = v1.14.0
+GRPC_SITE = https://github.com/grpc/grpc.git
+GRPC_SITE_METHOD = git

Please use the tarball at
https://github.com/grpc/grpc/archive/v1.15.0.tar.gz instead.

See
https://buildroot.org/downloads/manual/manual.html#github-download-url
for more details about this.

Quoted 6 lines
package/grpc/grpc.mk new file +6 -0
+GRPC_LICENSE = BSD-3-Clause
+GRPC_LICENSE_FILES = LICENSE
+
+GRPC_DEPENDENCIES = host-grpc gflags gtest c-ares openssl protobuf zlib
+HOST_GRPC_DEPENDENCIES = host-c-ares host-protobuf host-openssl
+

package/grpc/grpc.mk line 25

Quoted 10 lines
package/grpc/grpc.mk new file +10 -0
+GRPC_INSTALL_STAGING = YES
+
+GRPC_MAKE_ENV = \
+	CC="$(TARGET_CC)" \
+	CXX="$(TARGET_CXX)" \
+	LD="$(TARGET_CC)" \
+	LDXX="$(TARGET_CXX)" \
+	STRIP="$(TARGET_STRIP)" \
+	PROTOC="$(HOST_DIR)/bin/protoc" \
+	PATH="$(HOST_DIR)/bin:$(PATH)" \

Use BR_PATH instead.

package/grpc/grpc.mk line 29

Quoted 4 lines
package/grpc/grpc.mk new file +4 -0
+	GRPC_CROSS_COMPILE=true \
+	GRPC_CROSS_LDOPTS="$(TARGET_LDFLAGS)" \
+	GRPC_CROSS_AROPTS="$(LTO_PLUGIN)" \
+	HAS_PKG_CONFIG=false \

Why ?

package/grpc/grpc.mk line 30

Quoted 1 line
package/grpc/grpc.mk new file +1 -0
+	PROTOBUF_CONFIG_OPTS="--host=$(GNU_TARGET_NAME) --with-protoc=$(HOST_DIR)/bin/protoc" \

Seems weird, is grpc going to build its own protobuf ?

package/grpc/grpc.mk line 41

Quoted 11 lines
package/grpc/grpc.mk new file +11 -0
+	HOST_CC="$(HOSTCC)" \
+	HOST_CXX="$(HOSTCXX)" \
+	HOST_LD="$(HOSTCC)" \
+	HOST_LDXX="$(HOSTCXX)" \
+	HOST_CPPFLAGS="$(HOST_CPPFLAGS)" \
+	HOST_CFLAGS="$(HOST_CFLAGS)" \
+	HOST_CXXFLAGS="$(HOST_CXXFLAGS)" \
+	HOST_LDFLAGS="$(HOST_LDFLAGS)"
+
+GRPC_MAKE_OPTS = \
+	LD_LIBRARY_PATH="$(STAGING_DIR)/usr/lib" \

This looks very bad. LD_LIBRARY_PATH will be used by the dynamic loader on your build machine to look for libraries... and you point it to libraries built for the target. Not good at all.

package/grpc/grpc.mk line 48

Quoted 7 lines
package/grpc/grpc.mk new file +7 -0
+	PROTOC="$(HOST_DIR)/bin/protoc"
+
+GRPC_INSTALL_TARGET_OPTS = \
+	prefix="$(TARGET_DIR)/usr"
+
+GRPC_INSTALL_STAGING_OPTS = \
+	prefix="$(STAGING_DIR)/usr"

These two variables are not needed, just use the value directly in the install staging/target commands.

Quoted 13 lines
package/grpc/grpc.mk new file +13 -0
+
+define GRPC_BUILD_CMDS
+	$(GRPC_MAKE_ENV) $(MAKE) $(GRPC_MAKE_OPTS) -C $(@D) \
+		shared
+endef
+
+define GRPC_INSTALL_STAGING_CMDS
+	$(GRPC_MAKE_ENV) $(MAKE) $(GRPC_INSTALL_STAGING_OPTS) -C $(@D) \
+		install-headers install-shared_c install-shared_cxx
+endef
+
+define GRPC_INSTALL_TARGET_CMDS
+	$(GRPC_MAKE_ENV) $(MAKE) $(GRPC_INSTALL_TARGET_OPTS) -C $(@D) \

package/grpc/grpc.mk line 71

Quoted 10 lines
package/grpc/grpc.mk new file +10 -0
+		install-shared_c install-shared_cxx
+endef
+
+HOST_GRPC_MAKE_ENV = \
+	$(HOST_MAKE_ENV) \
+	CFLAGS="$(HOST_CFLAGS)" \
+	LDFLAGS="$(HOST_LDFLAGS)"
+
+HOST_GRPC_MAKE_OPTS = \
+	LD_LIBRARY_PATH="$(HOST_DIR)/usr/lib" \

This also shouldn't be needed.

package/grpc/grpc.mk line 72

Quoted 1 line
package/grpc/grpc.mk new file +1 -0
+	prefix="$(HOST_DIR)/usr"

Use just $(HOST_DIR), not $(HOST_DIR)/usr

Could you rework your patch according to those comments? Perhaps the previous attempt at adding grpc will provide some hints/help on how to improve things.

Do not hesitate to let us know if you need more explanation about those comments. You are the second person trying to add grpc to Buildroot, so we definitely want to add it :-)

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
author
#2 lore raw

PATCH 1/1 New package: gRPC, Google's remote procedue calss protocol.

Hi Thomas,

Thanks for the feedback! Our patch started out based on the earlier referenced patch from Charles Hardin - we tried to incorporate your comments on that patch, as well as resolve cross compiling issues we ran into on our embedded ARM device with the grpc Makefile:

https://groups.google.com/d/msg/grpc-io/41-i08zBG5k/sEKuYHsEAwAJ

I'll re-work the patch per your comments. See more comments and questions in-line:

Quoted 117 lines · Thomas Petazzoni

Hello Mark,

Thanks for this contribution! I believe I should mention that there was a previous attempt at adding a package for "grpc":

https://patchwork.ozlabs.org/patch/917779/
https://patchwork.ozlabs.org/patch/917778/

Perhaps there are some useful things to re-use from this previous contribution.

Quoted 5 lines · Mark Fine

Introduces support for gRPC, Google's remote procedure call protocol. Includes a patch for supporting cross compilation. Also patches the c-ares package for host support.

The commit title should be just:

grpc: new package

Quoted 2 lines
---
 package/c-ares/c-ares.mk                    |  1 +

This change should be a separate patch, coming before the patch adding grpc.

Review

Quoted 1 line
(quoted diff) +0 -0

b/package/grpc/0001-fixup-cross-compile.patch

package/grpc/0001-fixup-cross-compile.patch

Quoted 4 lines

new file mode 100644
index 0000000000..eaf262a95a

package/grpc/0001-fixup-cross-compile.patch new file +0 -0

All patches need to have a description and Signed-off-by. Also, since the upstream project is using Git, we want the patches to be Git-formatted (i.e be generated by 'git format-patch').

Quoted 8 lines

+ # These are automatically computed variables.
+ # There shouldn't be any need to change anything from now on.

package/grpc/Config.in new file +0 -0
new file mode 100644
index 0000000000..237a9d5a15

package/grpc/Config.in line 7

Quoted 7 lines
package/grpc/Config.in new file +7 -0
@@ -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

Due to this select, you also need to replicate the following dependencies:

depends on BR2_USE_WCHAR
depends on BR2_USE_MMU

package/grpc/Config.in line 10

Quoted 3 lines
package/grpc/Config.in new file +3 -0
+     select BR2_PACKAGE_GTEST_GMOCK
+     select BR2_PACKAGE_OPENSSL
+     select BR2_PACKAGE_PROTOBUF

Due to this select, you also need to replicate the following dependencies:

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

package/grpc/Config.in line 19

Quoted 9 lines
package/grpc/Config.in new file +9 -0
+     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)

Make sure to update this comment with the new dependencies. Also, I personally prefer:

        depends on !A || !B || !C

instead of

        depends on !(A && B && C)
Quoted 1 line

\ No newline at end of file

Please make sure the file ends with a newline.

package/grpc/grpc.mk line 1

Quoted 7 lines
package/grpc/grpc.mk new file +1 -0
new file mode 100644
index 0000000000..a74dece713
@@ -0,0 +1,85 @@
+###########################################################

#####################

package/grpc/grpc.mk

Quoted 4 lines
package/grpc/grpc.mk new file +4 -0
+#
+# grpc
+#
+###########################################################

#####################

package/grpc/grpc.mk line 9

Quoted 4 lines
package/grpc/grpc.mk new file +4 -0
+
+GRPC_VERSION = v1.14.0
+GRPC_SITE = https://github.com/grpc/grpc.git
+GRPC_SITE_METHOD = git

Please use the tarball at
https://github.com/grpc/grpc/archive/v1.15.0.tar.gz instead.

Quoted 4 lines

See
https://buildroot.org/downloads/manual/manual.html#github-download-url
for more details about this.

Initially, I tried to use tarballs off of git and a locally calculated hash file, but had issues with BR finding and downloading the tarballs. Will try again.

Quoted 20 lines
Quoted 7 lines
package/grpc/grpc.mk new file +6 -0
+GRPC_LICENSE = BSD-3-Clause
+GRPC_LICENSE_FILES = LICENSE
+
+GRPC_DEPENDENCIES = host-grpc gflags gtest c-ares openssl protobuf zlib
+HOST_GRPC_DEPENDENCIES = host-c-ares host-protobuf host-openssl
+

package/grpc/grpc.mk line 25

Quoted 10 lines
package/grpc/grpc.mk new file +10 -0
+GRPC_INSTALL_STAGING = YES
+
+GRPC_MAKE_ENV = \
+     CC="$(TARGET_CC)" \
+     CXX="$(TARGET_CXX)" \
+     LD="$(TARGET_CC)" \
+     LDXX="$(TARGET_CXX)" \
+     STRIP="$(TARGET_STRIP)" \
+     PROTOC="$(HOST_DIR)/bin/protoc" \
+     PATH="$(HOST_DIR)/bin:$(PATH)" \

Use BR_PATH instead.

Quoted 7 lines

package/grpc/grpc.mk line 29

Quoted 4 lines
package/grpc/grpc.mk new file +4 -0
+     GRPC_CROSS_COMPILE=true \
+     GRPC_CROSS_LDOPTS="$(TARGET_LDFLAGS)" \
+     GRPC_CROSS_AROPTS="$(LTO_PLUGIN)" \
+     HAS_PKG_CONFIG=false \

Why ?

I believe this was added per the Makefile:

# The steps for cross-compiling are as follows:
# First, clone and make install of grpc using the native compilers for the host. # Also, install protoc (e.g., from a package like apt-get)
# Then clone a fresh grpc for the actual cross-compiled build
# Set the environment variable GRPC_CROSS_COMPILE to true
# Set CC, CXX, LD, LDXX, AR, and STRIP to the cross-compiling binaries # Also set PROTOBUF_CONFIG_OPTS to indicate cross-compilation to protobuf (e.g., # PROTOBUF_CONFIG_OPTS="--host=arm-linux --with-protoc=/usr/local/bin/protoc" ) # Set HAS_PKG_CONFIG=false

Quoted 4 lines

package/grpc/grpc.mk line 30

Quoted 1 line
package/grpc/grpc.mk new file +1 -0
+     PROTOBUF_CONFIG_OPTS="--host=$(GNU_TARGET_NAME)

--with-protoc=$(HOST_DIR)/bin/protoc" \

Seems weird, is grpc going to build its own protobuf ?

I believe this uses the host built protobuf compiler picked up from host-protobuf.

Quoted 7 lines
Quoted 7 lines
package/grpc/grpc.mk new file +7 -0
+     HOST_CC="$(HOSTCC)" \
+     HOST_CXX="$(HOSTCXX)" \
+     HOST_LD="$(HOSTCC)" \
+     HOST_LDXX="$(HOSTCXX)" \
+     HOST_CPPFLAGS="$(HOST_CPPFLAGS)" \
+     HOST_CFLAGS="$(HOST_CFLAGS)" \
+     HOST_CXXFLAGS="$(HOST_CXXFLAGS)" \
Quoted 8 lines

package/grpc/grpc.mk line 41

Quoted 4 lines
package/grpc/grpc.mk new file +4 -0
+     HOST_LDFLAGS="$(HOST_LDFLAGS)"
+
+GRPC_MAKE_OPTS = \
+     LD_LIBRARY_PATH="$(STAGING_DIR)/usr/lib" \

This looks very bad. LD_LIBRARY_PATH will be used by the dynamic loader on your build machine to look for libraries... and you point it to libraries built for the target. Not good at all.

Will try removing this.

Quoted 41 lines

package/grpc/grpc.mk line 48

Quoted 7 lines
package/grpc/grpc.mk new file +7 -0
+     PROTOC="$(HOST_DIR)/bin/protoc"
+
+GRPC_INSTALL_TARGET_OPTS = \
+     prefix="$(TARGET_DIR)/usr"
+
+GRPC_INSTALL_STAGING_OPTS = \
+     prefix="$(STAGING_DIR)/usr"

These two variables are not needed, just use the value directly in the install staging/target commands.

Quoted 13 lines
package/grpc/grpc.mk new file +13 -0
+
+define GRPC_BUILD_CMDS
+     $(GRPC_MAKE_ENV) $(MAKE) $(GRPC_MAKE_OPTS) -C $(@D) \
+             shared
+endef
+
+define GRPC_INSTALL_STAGING_CMDS
+     $(GRPC_MAKE_ENV) $(MAKE) $(GRPC_INSTALL_STAGING_OPTS) -C $(@D) \
+             install-headers install-shared_c install-shared_cxx
+endef
+
+define GRPC_INSTALL_TARGET_CMDS
+     $(GRPC_MAKE_ENV) $(MAKE) $(GRPC_INSTALL_TARGET_OPTS) -C $(@D) \

package/grpc/grpc.mk line 71

Quoted 10 lines
package/grpc/grpc.mk new file +10 -0
+             install-shared_c install-shared_cxx
+endef
+
+HOST_GRPC_MAKE_ENV = \
+     $(HOST_MAKE_ENV) \
+     CFLAGS="$(HOST_CFLAGS)" \
+     LDFLAGS="$(HOST_LDFLAGS)"
+
+HOST_GRPC_MAKE_OPTS = \
+     LD_LIBRARY_PATH="$(HOST_DIR)/usr/lib" \

This also shouldn't be needed.

package/grpc/grpc.mk line 72

Quoted 1 line
package/grpc/grpc.mk new file +1 -0
+     prefix="$(HOST_DIR)/usr"

Use just $(HOST_DIR), not $(HOST_DIR)/usr

Quoted 8 lines

Could you rework your patch according to those comments? Perhaps the previous attempt at adding grpc will provide some hints/help on how to improve things.

Do not hesitate to let us know if you need more explanation about those comments. You are the second person trying to add grpc to Buildroot, so we definitely want to add it :-)

Yes, we'd love to have this get into upstream! Thanks for your response!

Mark

Quoted 8 lines

Thanks!

Thomas
--
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20180918/fefaf98a/attachment.html>

#3 lore raw

PATCH 1/1 New package: gRPC, Google's remote procedue calss protocol.

Hello Mark,

Quoted 7 lines · Mark Fine
Quoted 3 lines

See
https://buildroot.org/downloads/manual/manual.html#github-download-url
for more details about this.

Initially, I tried to use tarballs off of git and a locally calculated hash file, but had issues with BR finding and downloading the tarballs. Will try again.

OK, let me know if you run into specific issues.

Quoted 29 lines
Quoted 19 lines
Quoted 6 lines
package/grpc/grpc.mk new file +6 -0
+GRPC_LICENSE = BSD-3-Clause
+GRPC_LICENSE_FILES = LICENSE
+
+GRPC_DEPENDENCIES = host-grpc gflags gtest c-ares openssl protobuf zlib
+HOST_GRPC_DEPENDENCIES = host-c-ares host-protobuf host-openssl
+

package/grpc/grpc.mk line 25

Quoted 10 lines
package/grpc/grpc.mk new file +10 -0
+GRPC_INSTALL_STAGING = YES
+
+GRPC_MAKE_ENV = \
+     CC="$(TARGET_CC)" \
+     CXX="$(TARGET_CXX)" \
+     LD="$(TARGET_CC)" \
+     LDXX="$(TARGET_CXX)" \
+     STRIP="$(TARGET_STRIP)" \
+     PROTOC="$(HOST_DIR)/bin/protoc" \
+     PATH="$(HOST_DIR)/bin:$(PATH)" \  

Use BR_PATH instead.

Quoted 7 lines

package/grpc/grpc.mk line 29

Quoted 4 lines
package/grpc/grpc.mk new file +4 -0
+     GRPC_CROSS_COMPILE=true \
+     GRPC_CROSS_LDOPTS="$(TARGET_LDFLAGS)" \
+     GRPC_CROSS_AROPTS="$(LTO_PLUGIN)" \
+     HAS_PKG_CONFIG=false \  

Why ?

I believe this was added per the Makefile:

Quoted 9 lines

# The steps for cross-compiling are as follows:
# First, clone and make install of grpc using the native compilers for the host. # Also, install protoc (e.g., from a package like apt-get)
# Then clone a fresh grpc for the actual cross-compiled build
# Set the environment variable GRPC_CROSS_COMPILE to true
# Set CC, CXX, LD, LDXX, AR, and STRIP to the cross-compiling binaries # Also set PROTOBUF_CONFIG_OPTS to indicate cross-compilation to protobuf (e.g., # PROTOBUF_CONFIG_OPTS="--host=arm-linux --with-protoc=/usr/local/bin/protoc" ) # Set HAS_PKG_CONFIG=false

Looks weird. Perhaps it's simply to make sure the system-provided pkg-config doesn't get used. But in Buildroot, we provide in $(HOST_DIR)/bin, a special pkg-config that returns results that are valid when cross-compiling.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

+ PROTOBUF_CONFIG_OPTS="--host=$(GNU_TARGET_NAME)

--with-protoc=$(HOST_DIR)/bin/protoc" \

Seems weird, is grpc going to build its own protobuf ?

I believe this uses the host built protobuf compiler picked up from host-protobuf.

But why --host=$(GNU_TARGET_NAME) is needed ?

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com