Cross Compiling gRPC for OpenWRT.

49 views
Skip to first unread message

karraka...@gmail.com

unread,
Jan 23, 2020, 11:20:17 PM1/23/20
to grpc.io
Hi Folks,

This is the first time to cross compile, of any software, gRPC for openwrt platform. I have referred many examples and posts. I have got the essence of it but not able to compile it successfully.

the binaries, include and libraries files are under

~/openwrt/staging_dir/toolchain-mips_24kc_gcc-7.3.0_musl/

Below are the ways I have tried to cross compile

1. There is an example in gRPC

~/grpc/test/distrib/cpp/run_distrib_test_raspberry_pi.sh
I have followed the above example and made changes in the toolchain.cmake file as below

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(devel_root ~/openwrt)
set(CMAKE_SYSROOT ${devel_root}/
staging_dir/toolchain-mips_24kc_gcc-7.3.0_musl/mips-openwrt-linux)

set(CMAKE_STAGING_PREFIX ${devel_root}/stage)

set(tool_root ${devel_root}/staging_dir/toolchain-mips_24kc_gcc-7.3.0_musl)
set(CMAKE_C_COMPILER ${tool_root}/bin/mips-openwrt-linux-gcc)
set(CMAKE_CXX_COMPILER ${tool_root}/bin/mips-openwrt-linux-g++)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

But this is of no use and this will always fails at protobuf and along with that will get the below error

undefined reference to `__atomic_fetch_add_8'
and now it sometimes show the below error as well

recipe for target 'grpc_ruby_plugin' failed


2. In few posts, I have seen make comand which is being used directly, such as

make HAS_PKG_CONFIG=false CC=arm-xilinx-linux-gnueabi-gcc CXX=arm-xilinx-linux-gnueabi-g++ LD=arm-xilinx-linux-gnueabi-gcc LDXX=arm-xilinx-linux-gnueabi-g++ AR=arm-xilinx-linux-gnueabi-ar CPPFLAGS=-I/home/rafael/mobi/ArmLibs/include  LDFLAGS=-L/home/rafael/mobi/ArmLibs/lib

instead here for example I would provide the whole path for CC , lets say

CC=~/openwrt/staging_dir/toolchain-mips_24kc_gcc-7.3.0_musl/bin/mips-openwrt-linux-gcc

In the same way, I would provide for CXX, LD, LDXX, AR, CPPFLAGS and LDFLAGS.

Even this runs into error.

Any help would be appreciated.

Thanks

Dominik

unread,
Jan 27, 2020, 3:44:05 AM1/27/20
to grpc.io
Hi,

this is a shell script (bash) showing how we basically compile gRPC with Make:

    if [[ -f Makefile ]] ; then
        make distclean
>/dev/null 2>&1
   
fi

   
export CXXFLAGS=""
   
if (( "$gpp_major_version" >= 8 )) ; then
        # some tweaks for never GCC versions
       
export CXXFLAGS="-Wno-error=class-memaccess -Wno-error=ignored-qualifiers -Wno-error=stringop-truncation -Wno-error=unused-function"
   
fi
   
# use c-ares library that is shipped with the gRPC sources:
   
export HAS_SYSTEM_CARES="false"
    # use protobuf library that is shipped with the gRPC sources
   
export HAS_SYSTEM_PROTOBUF="false"
    # use the protobuf compiler that is shipped with the gRPC sources:
    export HAS_PROTOC="false"

    make clean
    make CXX
="$gpp_path" \
         BUILDDIR
="$build_dir" \
         $options

  • $gpp_path shall contain the path to your compiler.
  • $build_dir shall contain the path where the build is being done.
  • $gpp_major_version shall contain the major version of GCC (get it via $gpp_path --version)
  • $options shall contain any oother options you need to pass to the build system

Reply all
Reply to author
Forward
0 new messages