All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vyacheslav Yurkov <uvv.mail@gmail.com>
To: openembedded-devel@lists.openembedded.org
Subject: [meta-oe][PATCH 2/2] grpc: fix cross-compilation of grpc applications
Date: Mon,  4 Oct 2021 22:21:31 +0200	[thread overview]
Message-ID: <03757aa00098229ff80af93f7bdc8ff3cb9f9bfa.1633378334.git.uvv.mail@gmail.com> (raw)
In-Reply-To: <cover.1633378334.git.uvv.mail@gmail.com>

Backport a patch from grpc/master to be able to build c++ applications
when gRPC_BUILD_GRPC_CPP_PLUGIN=OFF. The patch should be dropped on the
recipe upgrade

Signed-off-by: Vyacheslav Yurkov <uvv.mail@gmail.com>
---
 ...compilation-with-gRPC_BUILD_GRPC_CPP.patch | 55 +++++++++++++++++++
 meta-oe/recipes-devtools/grpc/grpc_1.38.1.bb  |  1 +
 2 files changed, 56 insertions(+)
 create mode 100644 meta-oe/recipes-devtools/grpc/grpc/0002-cmake-fix-cross-compilation-with-gRPC_BUILD_GRPC_CPP.patch

diff --git a/meta-oe/recipes-devtools/grpc/grpc/0002-cmake-fix-cross-compilation-with-gRPC_BUILD_GRPC_CPP.patch b/meta-oe/recipes-devtools/grpc/grpc/0002-cmake-fix-cross-compilation-with-gRPC_BUILD_GRPC_CPP.patch
new file mode 100644
index 000000000..ce660f5cc
--- /dev/null
+++ b/meta-oe/recipes-devtools/grpc/grpc/0002-cmake-fix-cross-compilation-with-gRPC_BUILD_GRPC_CPP.patch
@@ -0,0 +1,55 @@
+From 83a66aa45d63d79cbccc47a65998723a7d2d7637 Mon Sep 17 00:00:00 2001
+From: Thomas De Schampheleire <patrickdepinguin@gmail.com>
+Date: Wed, 23 Jun 2021 14:22:59 +0200
+Subject: [PATCH] cmake: fix cross-compilation with
+ gRPC_BUILD_GRPC_CPP_PLUGIN=OFF (#26292)
+
+* cmake: fix cross-compilation with gRPC_BUILD_GRPC_CPP_PLUGIN=OFF
+
+When cross-compiling gRPC, a _native_ version of 'grpc_cpp_plugin' is
+searched in the environment. For most use cases, a _cross_ version of this
+file is not needed and gRPC_BUILD_GRPC_CPP_PLUGIN can be set to OFF.
+
+However, when cross-building with -DgRPC_BUILD_GRPC_CPP_PLUGIN=OFF, there
+are some build errors, for example:
+
+make[3]: *** No rule to make target 'grpc_cpp_plugin', needed by 'gens/src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.cc'.  Stop.
+
+This is because there is still a hard dependency on 'grpc_cpp_plugin' for
+these targets, not taking into account the cross-compilation case.
+
+Fix by depending on the variable gRPC_CPP_PLUGIN, which is set correctly for
+either cross or native case.
+
+* regenerate projects
+---
+ CMakeLists.txt                    | 2 +-
+ templates/CMakeLists.txt.template | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index eeaf0b43c7..c60a64917a 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -319,7 +319,7 @@ function(protobuf_generate_grpc_cpp)
+            --plugin=protoc-gen-grpc=${_gRPC_CPP_PLUGIN}
+            ${_protobuf_include_path}
+            ${REL_FIL}
+-      DEPENDS ${ABS_FIL} ${_gRPC_PROTOBUF_PROTOC} grpc_cpp_plugin
++      DEPENDS ${ABS_FIL} ${_gRPC_PROTOBUF_PROTOC} ${_gRPC_CPP_PLUGIN}
+       WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+       COMMENT "Running gRPC C++ protocol buffer compiler on ${FIL}"
+       VERBATIM)
+diff --git a/templates/CMakeLists.txt.template b/templates/CMakeLists.txt.template
+index cef2534cbd..f0afe5108e 100644
+--- a/templates/CMakeLists.txt.template
++++ b/templates/CMakeLists.txt.template
+@@ -389,7 +389,7 @@
+              --plugin=protoc-gen-grpc=<%text>${_gRPC_CPP_PLUGIN}</%text>
+              <%text>${_protobuf_include_path}</%text>
+              <%text>${REL_FIL}</%text>
+-        DEPENDS <%text>${ABS_FIL}</%text> <%text>${_gRPC_PROTOBUF_PROTOC}</%text> grpc_cpp_plugin
++        DEPENDS <%text>${ABS_FIL}</%text> <%text>${_gRPC_PROTOBUF_PROTOC}</%text> <%text>${_gRPC_CPP_PLUGIN}</%text>
+         WORKING_DIRECTORY <%text>${CMAKE_CURRENT_SOURCE_DIR}</%text>
+         COMMENT "Running gRPC C++ protocol buffer compiler on <%text>${FIL}</%text>"
+         VERBATIM)
diff --git a/meta-oe/recipes-devtools/grpc/grpc_1.38.1.bb b/meta-oe/recipes-devtools/grpc/grpc_1.38.1.bb
index e2b86dad1..dfb44b819 100644
--- a/meta-oe/recipes-devtools/grpc/grpc_1.38.1.bb
+++ b/meta-oe/recipes-devtools/grpc/grpc_1.38.1.bb
@@ -23,6 +23,7 @@ S = "${WORKDIR}/git"
 SRCREV_grpc = "96b73272eadc01afb5fb45b92b408c47e4387274"
 BRANCH = "v1.38.x"
 SRC_URI = "git://github.com/grpc/grpc.git;protocol=https;name=grpc;branch=${BRANCH} \
+           file://0002-cmake-fix-cross-compilation-with-gRPC_BUILD_GRPC_CPP.patch \
            "
 # Fixes build with older compilers 4.8 especially on ubuntu 14.04
 CXXFLAGS:append:class-native = " -Wl,--no-as-needed"
-- 
2.28.0



      parent reply	other threads:[~2021-10-04 20:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-04 20:21 [meta-oe][PATCH 0/2] gRPC Pull Request Vyacheslav Yurkov
2021-10-04 20:21 ` [meta-oe][PATCH 1/2] grpc: fix cross-compilation of grpc applications Vyacheslav Yurkov
2021-10-04 20:21 ` Vyacheslav Yurkov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=03757aa00098229ff80af93f7bdc8ff3cb9f9bfa.1633378334.git.uvv.mail@gmail.com \
    --to=uvv.mail@gmail.com \
    --cc=openembedded-devel@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.