How to setup grpc to build with bazel

532 views
Skip to first unread message

eric.n...@gmail.com

unread,
Nov 21, 2015, 4:22:46 PM11/21/15
to grpc.io
I'm trying to get grpc to build with bazel, but because the grpc repository doesn't have documentation (that I can find) about building with bazel I've been bumbling my way through it.

The issue that I'm currently running into is that when building the grpc code gcc is not passed in include paths that would allow it to find the openssl headers except through a quoted include, but grpc uses angle includes, and thus cannot find the header files.


Example compile command from 'bazel build -s @grpc//:grpc'

(cd /private/var/tmp/_bazel_endobson/5ca22e6652ef4ccc0328a9666152d294/gist && \
  exec env - \
    PATH=/Users/endobson/bin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/texbin:/Users/endobson/bin:/opt/local/bin:/opt/local/sbin:/Users/endobson/proj/racket/plt/racket/bin:/Applications/google-cloud-sdk/bin:/Users/endobson/proj/racket/plt/racket/bin:/Applications/google-cloud-sdk/bin \
    TMPDIR=/var/folders/w1/9bnm3lvj5kj4j57fxwqn0w200000gn/T/ \
  external/bazel_tools/tools/cpp/osx_gcc_wrapper.sh '-D_FORTIFY_SOURCE=1' -fstack-protector -fcolor-diagnostics -Wall -Wthread-safety -Wself-assign -fno-omit-frame-pointer -iquote external/grpc -iquote bazel-out/local_darwin-fastbuild/genfiles/external/grpc -iquote . -iquote bazel-out/local_darwin-fastbuild/genfiles -iquote external/bazel_tools -iquote bazel-out/local_darwin-fastbuild/genfiles/external/bazel_tools -iquote external/zlib-repo -iquote bazel-out/local_darwin-fastbuild/genfiles/external/zlib-repo -isystem external/grpc/include -isystem bazel-out/local_darwin-fastbuild/genfiles/external/grpc/include -isystem external/grpc -isystem bazel-out/local_darwin-fastbuild/genfiles/external/grpc -isystem external/bazel_tools/tools/cpp/gcc3 -no-canonical-prefixes -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' '-frandom-seed=bazel-out/local_darwin-fastbuild/bin/external/grpc/_objs/grpc/external/grpc/src/core/census/initialize.pic.o' -MD -MF bazel-out/local_darwin-fastbuild/bin/external/grpc/_objs/grpc/external/grpc/src/core/census/initialize.pic.d -fPIC -c external/grpc/src/core/census/initialize.c -o bazel-out/local_darwin-fastbuild/bin/external/grpc/_objs/grpc/external/grpc/src/core/census/initialize.pic.o)

Error message from gcc:

In file included from external/grpc/src/core/surface/secure_channel_create.c:49:
In file included from external/grpc/src/core/security/credentials.h:43:
In file included from external/grpc/src/core/security/json_token.h:38:
In file included from bazel-out/local_darwin-fastbuild/genfiles/openssl/rsa.h:62:
In file included from bazel-out/local_darwin-fastbuild/genfiles/openssl/asn1.h:65:
In file included from bazel-out/local_darwin-fastbuild/genfiles/openssl/bio.h:69:
In file included from bazel-out/local_darwin-fastbuild/genfiles/openssl/crypto.h:139:
bazel-out/local_darwin-fastbuild/genfiles/openssl/symhacks.h:58:10: error: 'openssl/e_os2.h' file not found with <angled> include; use "quotes" instead
#include <openssl/e_os2.h>
         ^~~~~~~~~~~~~~~~~
         "openssl/e_os2.h"

Does anyone know how to fix this, or have a working repository that builds grpc through bazel that I can crib from?

eric.n...@gmail.com

unread,
Nov 21, 2015, 9:07:08 PM11/21/15
to grpc.io, eric.n...@gmail.com
I figured out how to pass in the -isystem, it seems that the documentation on bazel includes attribute was wrong (https://github.com/bazelbuild/bazel/issues/637).
Reply all
Reply to author
Forward
0 new messages