Cross Compile grpc libs for ARM

4 485 vues
Accéder directement au premier message non lu

rafael....@googlemail.com

non lue,
5 juil. 2015, 10:24:5905/07/2015
à grp...@googlegroups.com

Hello,

I would like to run a grpc server on a embedded linux ARM platform.

How can I compile the grpc libs for ARM on a Ubuntu machine?

Thanks

Rafael.

Nicolas Noble

non lue,
7 juil. 2015, 13:11:3907/07/2015
à rafael....@googlemail.com,grp...@googlegroups.com
Heya,

  Could you describe a bit more your environment ? There is some cross compilation support available, but it's primarily done on a per-platform basis. In general, you'll have to provide all the external dependencies yourself, the Makefile won't be able to cross compile the dependencies (aka, don't bother recursive cloning it). You'll need to provide zlib (unconditionally), protobuf (if you intend to compile the C++ bindings), and OpenSSL (if you intend to compile the secure version). You can then override all of the tools by specifying the usual cross compilation variables (CC, CXX, LD, STRIP, AR, ...). You'll also probably want to compile the individual targets instead of making "all". Again, it depends on the actual targets you're really interested in, which means I'd need to understand more what you're doing before helping you further :-)

--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/cdf1f2d2-d9ff-4d34-aeee-930fb045d197%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

rafael....@googlemail.com

non lue,
7 juil. 2015, 15:03:2507/07/2015
à grp...@googlegroups.com
Hi,

I'm working on a Xilinx Zynq device. It is a SoC with Arm Cortex A9 cores on it. I have a toolchain for embedded linux from Xilinx.
As i understood i need the libraries libgrpc++_unsecure, libgrpc, libgpr, libprotobuf, libpthread and libdl cross compiled for my platform.

I know that this libraries depends itself on protobuf, openssl and zlib. I think I could manage it to crosscompile them by myself or get them from buildroot.

But when I have them how can I connect the binaries of this libs to your makefile (https://github.com/grpc/grpc/blob/master/Makefile)?

What variables I need to override?

Thanks in advanced

Rafael.

Nicolas Noble

non lue,
7 juil. 2015, 16:22:3607/07/2015
à rafael....@googlemail.com,grp...@googlegroups.com
Yep, I know that board, it's a pretty powerful yet interesting device. You'll have lots of funs playing with it :-)

The Makefile will try to detect what's on your system, first using pkg-config, then using normal compilations of test softwares. I don't know exactly what Xilinx's toolchain looks like. If it has pkg-config, then you should be able to compile and install zlib / openssl / protobuf for that platform, and then cross compile grpc using the typical CC/CXX/CPPFLAGS/LD/LDXX variables. If it doesn't, things might be a bit more complicated. I'm going to describe the case where you don't have pkg-config for your plateform. First, compile your zlib/openssl/protobuf packages for your platform and install them somewhere sane. Then you should be able to build grpc:

make HAS_PKG_CONFIG=false CC=your-gcc CXX=your-g++ LD=your-gcc LDXX=your-g++ AR=your-ar CPPFLAGS=-I/path/to/packages/include LDFLAGS=-L/path/to/packages/lib static

Obviously, some assembly is required, and this is only a general guideline.

Is the Xilinx's toolchain you were talking about the one describe here: http://www.wiki.xilinx.com/Install+Xilinx+Tools ?


Rafael.

--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.

rafael....@googlemail.com

non lue,
12 juil. 2015, 15:41:4012/07/2015
à grp...@googlegroups.com
Hello Nicolas,

I have managed to cross compile all the needed libs and put them all together with the corresponding header files in a local folder ArmLibs. Then I have run make with the following optiions as suggested:

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/ArmLibs/include LDFLAGS=-L/home/rafael/ArmLibs/lib

Now I'm stuck again, because the Makefile doesn't recognize my already present libs and gives my a Dependency Check error like this:

DEPENDENCY ERROR

You are missing system dependencies that are essential to build grpc,
and the third_party directory doesn't have them:

  zlib
....

Do you have any suggestions for me how to solve the problem without changing the Makefile?

Regards

Rafael.

Nicolas Noble

non lue,
12 juil. 2015, 16:00:1612/07/2015
à Rafael Herrmann,grp...@googlegroups.com
Well, the error message should suggest you'd run make run_dep_checks to see exactly why it's failing. Could you do that and paste the output here ? Of course, you'll need all of your options on the command line as well :) just add "run_dep_checks" at the end of that command you were trying to run.

Also, by default, "make" will try building shared libraries. I don't think that's what you want, so once we figure why this is failing, please use the "static" target instead.

--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.

rafael....@googlemail.com

non lue,
12 juil. 2015, 16:47:4712/07/2015
à grp...@googlegroups.com
Hi Nicolas,

please find the result of run_dep_check below:

make run_dep_checks 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  DFLAGS=-L/home/rafael/mobi/ArmLibs/lib

arm-xilinx-linux-gnueabi-gcc -std=c89 -pedantic -I/home/rafael/mobi/ArmLibs/include -o /dev/null test/build/openssl-alpn.c -lssl -lcrypto  -g -fPIC -Llibs/opt -pthread  -ldl || true
In file included from /home/rafael/mobi/ArmLibs/include/openssl/x509.h:107:0,
                 from /home/rafael/mobi/ArmLibs/include/openssl/ssl.h:156,
                 from test/build/openssl-alpn.c:38:
/home/rafael/mobi/ArmLibs/include/openssl/sha.h:179:37: warning: ISO C90 does not support 'long long' [-Wlong-long]
 #   define SHA_LONG64 unsigned long long
                                     ^
/home/rafael/mobi/ArmLibs/include/openssl/sha.h:184:5: note: in expansion of macro 'SHA_LONG64'
     SHA_LONG64 h[8];
     ^
/home/rafael/mobi/ArmLibs/include/openssl/sha.h:179:37: warning: ISO C90 does not support 'long long' [-Wlong-long]
 #   define SHA_LONG64 unsigned long long
                                     ^
/home/rafael/mobi/ArmLibs/include/openssl/sha.h:185:5: note: in expansion of macro 'SHA_LONG64'
     SHA_LONG64 Nl, Nh;
     ^
/home/rafael/mobi/ArmLibs/include/openssl/sha.h:179:37: warning: ISO C90 does not support 'long long' [-Wlong-long]
 #   define SHA_LONG64 unsigned long long
                                     ^
/home/rafael/mobi/ArmLibs/include/openssl/sha.h:187:9: note: in expansion of macro 'SHA_LONG64'
         SHA_LONG64 d[SHA_LBLOCK];
         ^
/opt/Xilinx/SDK/2014.4/gnu/arm/lin/bin/../lib/gcc/arm-xilinx-linux-gnueabi/4.8.3/../../../../arm-xilinx-linux-gnueabi/bin/ld: cannot find -lssl
/opt/Xilinx/SDK/2014.4/gnu/arm/lin/bin/../lib/gcc/arm-xilinx-linux-gnueabi/4.8.3/../../../../arm-xilinx-linux-gnueabi/bin/ld: cannot find -lcrypto
collect2: error: ld returned 1 exit status
arm-xilinx-linux-gnueabi-gcc -std=c89 -pedantic -I/home/rafael/mobi/ArmLibs/include -o /dev/null test/build/openssl-npn.c -lssl -lcrypto  -g -fPIC -Llibs/opt -pthread  -ldl || true
In file included from /home/rafael/mobi/ArmLibs/include/openssl/x509.h:107:0,
                 from /home/rafael/mobi/ArmLibs/include/openssl/ssl.h:156,
                 from test/build/openssl-npn.c:40:
/home/rafael/mobi/ArmLibs/include/openssl/sha.h:179:37: warning: ISO C90 does not support 'long long' [-Wlong-long]
 #   define SHA_LONG64 unsigned long long
                                     ^
/home/rafael/mobi/ArmLibs/include/openssl/sha.h:184:5: note: in expansion of macro 'SHA_LONG64'
     SHA_LONG64 h[8];
     ^
/home/rafael/mobi/ArmLibs/include/openssl/sha.h:179:37: warning: ISO C90 does not support 'long long' [-Wlong-long]
 #   define SHA_LONG64 unsigned long long
                                     ^
/home/rafael/mobi/ArmLibs/include/openssl/sha.h:185:5: note: in expansion of macro 'SHA_LONG64'
     SHA_LONG64 Nl, Nh;
     ^
/home/rafael/mobi/ArmLibs/include/openssl/sha.h:179:37: warning: ISO C90 does not support 'long long' [-Wlong-long]
 #   define SHA_LONG64 unsigned long long
                                     ^
/home/rafael/mobi/ArmLibs/include/openssl/sha.h:187:9: note: in expansion of macro 'SHA_LONG64'
         SHA_LONG64 d[SHA_LBLOCK];
         ^
/opt/Xilinx/SDK/2014.4/gnu/arm/lin/bin/../lib/gcc/arm-xilinx-linux-gnueabi/4.8.3/../../../../arm-xilinx-linux-gnueabi/bin/ld: cannot find -lssl
/opt/Xilinx/SDK/2014.4/gnu/arm/lin/bin/../lib/gcc/arm-xilinx-linux-gnueabi/4.8.3/../../../../arm-xilinx-linux-gnueabi/bin/ld: cannot find -lcrypto
collect2: error: ld returned 1 exit status
arm-xilinx-linux-gnueabi-gcc -std=c89 -pedantic -I/home/rafael/mobi/ArmLibs/include -o /dev/null test/build/zlib.c -lz  -g -fPIC -Llibs/opt -pthread  || true
/opt/Xilinx/SDK/2014.4/gnu/arm/lin/bin/../lib/gcc/arm-xilinx-linux-gnueabi/4.8.3/../../../../arm-xilinx-linux-gnueabi/bin/ld: cannot find -lz
collect2: error: ld returned 1 exit status
arm-xilinx-linux-gnueabi-gcc -std=c89 -pedantic -I/home/rafael/mobi/ArmLibs/include -o /dev/null test/build/perftools.c -lprofiler  -g -fPIC -Llibs/opt -pthread  || true
test/build/perftools.c:34:33: fatal error: gperftools/profiler.h: No such file or directory
 #include <gperftools/profiler.h>
                                 ^
compilation terminated.
arm-xilinx-linux-gnueabi-g++ -std=c++0x -I/home/rafael/mobi/ArmLibs/include -o /dev/null test/build/protobuf.cc -lprotobuf  -g -fPIC -Llibs/opt -pthread  || true
/opt/Xilinx/SDK/2014.4/gnu/arm/lin/bin/../lib/gcc/arm-xilinx-linux-gnueabi/4.8.3/../../../../arm-xilinx-linux-gnueabi/bin/ld: cannot find -lprotobuf
collect2: error: ld returned 1 exit status
protoc --version | grep -q libprotoc.3 || true

rafael....@googlemail.com

non lue,
12 juil. 2015, 17:21:1912/07/2015
à grp...@googlegroups.com,rafael....@googlemail.com
Hi,

when I make the folder libs/opt/ by myself and copy all the libs inside that folder, I get a little bit further. The dependency check runs ok, (with some warnings like ..warning: ISO C90 does not support..). But when I run make the grpc include folders are not set correct. Maybe because I'm overriding that with my custom ones.:

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  DFLAGS=-L/home/rafael/mobi/ArmLibs/lib

[MAKE]    Generating libs/opt/pkgconfig/grpc.pc
[MAKE]    Generating libs/opt/pkgconfig/grpc_unsecure.pc
[MAKE]    Generating cache.mk
[C]       Compiling src/core/support/alloc.c
src/core/support/alloc.c:34:32: fatal error: grpc/support/alloc.h: No such file or directory
 #include <grpc/support/alloc.h>
                                ^
compilation terminated.
make: *** [objs/opt/src/core/support/alloc.o] Fehler 1

Nicolas Noble

non lue,
12 juil. 2015, 18:39:0112/07/2015
à Rafael Herrmann,grp...@googlegroups.com
It's LDFLAGS btw, not DFLAGS.

Try this instead:

CPPFLAGS=-I/home/rafael/mobi/ArmLibs/include LDFLAGS=-L/home/rafael/mobi/ArmLibs/lib 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 and LDFLAGS must be defined as environment variables instead of command line arguments, as we're adding to them.

--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.

rafael....@googlemail.com

non lue,
14 juil. 2015, 03:04:0714/07/2015
à grp...@googlegroups.com,rafael....@googlemail.com
Hi Nicolas,

It worked! At leased I have now the static libs. During making the shared libs the Makefile stopped, but I just need the static ones.

Thanks for your help!

Regards

Rafael.

Nicolas Noble

non lue,
14 juil. 2015, 03:09:4714/07/2015
à rafael....@googlemail.com,grp...@googlegroups.com

Good to hear :-) let us know if you are successful in using it!


--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.

aaron....@gmail.com

non lue,
1 déc. 2015, 12:17:5601/12/2015
à grpc.io,rafael....@googlemail.com
I am looking to port the gRPC libraries to a UNIX-like OS on ARM hardware.  I have had previous success with Protocol Buffers 2.7.3 and other packages using the ./configure mechanism.  This OS provides zlib and openSSL, although openSSL most likely does not have native ALPN support.

I am open to building the unsecured version initially.

My questions are:
1) how to build the unsecure version without openSSL?
2) do I need to copy any zlib objects to grpc path or is it sufficient that my sourced build path has it?
3) what is failing with the build below?
4) how to build static vs shared libraries?

Below is the command I use with make and the response:
$ make HAS_EMBEDDED_OPENSSL_ALPN=false CFLAGS="$CFLAGS $MAKEFLAGS -I/my_target_library_path" CPPFLAGS="$CPPFLAGS -I/my_target_library_path" LDFLAGS="$LDFLAGS -L/my_target_library_object_path" HAS_PKG_CONFIG=false CC="my_C_compiler" CXX="my_CPP_compiler" LD=my_C_target_linker LDXX=my_CPP_target_linker AR=my_target_ar
[MAKE]    Generating ~/grpc/libs/opt/pkgconfig/grpc.pc
[MAKE]    Generating ~/grpc/libs/opt/pkgconfig/grpc_unsecure.pc
[MAKE]    Generating cache.mk
[MAKE]    Generating ~/grpc/libs/opt/pkgconfig/gpr.pc
[C]       Compiling src/core/profiling/basic_timers.c
cc: Can't specify -P, -C, -E, -c or -S with -o and have multiple files
make: *** [~/grpc/objs/opt/src/core/profiling/basic_timers.o] Error 1

When I include run_dep_checks then the openSSL has issues because libdl is part of libc.  I have not included the tools for gperftools, protobuf, or zookeeper so those also show issue, but no error is reported for zlib.c test.

Thank you for any help or guidance.
Aaron

embedd...@gmail.com

non lue,
21 juil. 2016, 03:40:2021/07/2016
à grpc.io,rafael....@googlemail.com,aaron....@gmail.com
Hi Rafael.
I also need to compile grpc with un_secure.
do you have idea now?



在 2015年12月2日星期三 UTC+8上午1:17:56,aaron....@gmail.com写道:
Répondre à tous
Répondre à l'auteur
Transférer
Le message a été supprimé
0 nouveau message