1

I'm trying to port gRPC example cpp helloworld in yocto 2.2 (morty) for armv5e .Host system is ubuntu 18.04. I have written a recipe hello_1.4.3.bb.

DESCRIPTION = "Working example for grpc"
AUTHOR = "self"
LICENSE = "Apache-2.0"
HOMEPAGE = "www.com"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"


inherit autotools-brokensep pkgconfig cmake perlnative
DEPENDS = "grpc golang protobuf3 c-ares zlib openssl"
RDEPENDS_${PN} = "protobuf3"
#DEPENDS_append_class-target = " gtest grpc-native "
#DEPENDS_append_class-nativesdk = " grpc-native "


SRCREV = "29a2a533c98aa21f05c8f598ef2b47321508d5da"
BRANCH = "v1.4.x"
SRC_URI = "gitsm://github.com/grpc/grpc.git;protocol=https;name=grpc;branch=${BRANCH}"

CXXFLAGS_append_class-native ="-march=armv5e"
#CXXFLAGS_append_class-native = " -Wl,--no-as-needed"

PR = "r0"

S = "${WORKDIR}/git"
BBCLASSEXTEND = "native nativesdk"
TARGET_CXX_ARCH += "${LDFLAGS}" 

EXTRA_OECMAKE = "-DgRPC_INSTALL=ON \
     -DgRPC_BUILD_TESTS=OFF \
     -DRUN_HAVE_STD_REGEX=1 \
     -DRUN_HAVE_POSIX_REGEX=0 \
     -DRUN_HAVE_STEADY_CLOCK=0 \
     -DTHREADS_PTHREAD_ARG=2 \
     -DCMAKE_CROSSCOMPILING=ON \
     -DCMAKE_FIND_DEBUG_MODE=ON \
     -DBUILD_DEPS=ON \
     -DHAVE_STD_REGEX=ON \
     -DRUN_HAVE_STD_REGEX=1 \
     "
do_configure_prepend() {
  cd ${WORKDIR}/git
  git submodule update --init --recursive
}

do_compile() {

      cd ${S}/examples/cpp/helloworld
      make 
       
}

do_install() {
    install -d ${D}${bindir}
    install -m 0755 ${S}/build/greeter_client ${D}${bindir}
    install -m 0755 ${S}/build/greeter_server ${D}${bindir}
}


FILES_${PN} += "${bindir}/*"
RDEPENDS_${PN} += "libstdc++"


INSANE_SKIP_${PN} = "already-stripped rpaths"

I keep getting error

g++: error: unrecognized command line option ‘-marm’; did you mean ‘-mabm’? | : recipe for target 'helloworld.pb.o' failed make: *** [helloworld.pb.o] Error 1 WARNING: exit code 2 from a shell command.

Every layer i have imported from morty branch since the poky is on morty and i cant upgrade to master due to dependencies. Im really new to yocto.

I have tried to build grpc from grpc git but it gave too many errors so i went ahead with the grpc recipe from meta-iot-cloud (morty) and built the grpc. Im using the Makefile from the gRPC example folder grpc/examples/cpp/helloworld/ to compile the example code. This is the Makefile

demzys
  • 23
  • 6
  • It seems from that error message that your compiler doesn't know how to generate output that will run on ARM. Are you on an Intel system? In that case you need to install an ARM cross-compiler. – MadScientist May 24 '23 at 15:49

1 Answers1

3

I notice that many configurations could be improved in your recipe. I think the offending line is:

TARGET_CXX_ARCH += "${LDFLAGS}" 

LDFLAGS will then be used for all compilation steps which is incorrect. You can remove this line.

I also suggest the following modifications:

  • your recipe shouldn't inherit the native class since it's not intended to be run on the host machine
  • you should use the gitsm:// fetcher instead of do_configure_prepend to fetch submodules
  • you are inheriting conflicting classes (cmake, autotools). You don't need them to call make alone.
  • you should properly fix issues rather than using INSANE_SKIP
  • those EXTRA_OECMAKE seem copied from grpc's recipe. They may not apply to the helloworld example
  • you don't seem to be DEPENDing on grpc-native

Here's a suggestion but I don't expect it to work without some fixing:

DESCRIPTION = "Working example for grpc"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"

DEPENDS = "grpc golang protobuf3 c-ares zlib openssl"
RDEPENDS_${PN} += "libstdc++"

SRCREV = "29a2a533c98aa21f05c8f598ef2b47321508d5da"
BRANCH = "v1.4.x"
SRC_URI = "gitsm://github.com/grpc/grpc.git;protocol=https;branch=${BRANCH}"

S = "${WORKDIR}/git/cpp/helloworld"

EXTRA_OEMAKE = "-DRUN_HAVE_STD_REGEX=1 \
     -DRUN_HAVE_POSIX_REGEX=0 \
     -DRUN_HAVE_STEADY_CLOCK=0 \
     -DTHREADS_PTHREAD_ARG=2 \
     -DBUILD_DEPS=ON \
     -DHAVE_STD_REGEX=ON \
     -DRUN_HAVE_STD_REGEX=1 \
     "

FILES_${PN} += "${bindir}/*"

do_compile() {
    oe_runmake
} 

do_install() {
    install -d ${D}${bindir}
    install -m 0755 ${S}/build/greeter_client ${D}${bindir}
    install -m 0755 ${S}/build/greeter_server ${D}${bindir}
}
deribaucourt
  • 424
  • 8
  • Hi @deribaucourt. Thanks for suggestion. I tried the suggestions but there seem to be no binaries greeter_client and greeter_server . Is do_compile() not required to run the make file inside ${WORKDIR}/git/cpp/helloworld/ ? – demzys May 24 '23 at 10:32
  • 1
    I thought it was implied by default. Try this one then which makes use of Yocto's make arguments: ` do_compile() { oe_runmake } ` – deribaucourt May 24 '23 at 13:16