Building GRPC via Bazel without BoringSSL

927 views
Skip to first unread message

priy...@gmail.com

unread,
Mar 3, 2020, 6:30:35 PM3/3/20
to grpc.io
Hello,

I am trying to compile GRPC without BoringSSL. Looks like this is supported via cmake. Is there a way to also support it via Bazel? My current understanding is that the Bazel build unconditionally depends on @boringssl//:ssl.

We are using Bazel to build a custom binary that links in aws-cpp-sdk and grpc. It seems like aws-cpp-sdk wants openssl while grpc seems to want boringssl. We are currently exploring defining a fake `boringssl` local_repository which has a single target (`@boringssl//:ssl` which points to system provided openssl). Would love to know if this is likely to be a fool's errand.

Regards!

Richard Belleville

unread,
Mar 3, 2020, 6:55:19 PM3/3/20
to grpc.io

"We are currently exploring defining a fake `boringssl` local_repository which has a single target (`@boringssl//:ssl` which points to system provided openssl)"

This actually sounds ideal to me. Compare what the protobuf repo does about Python headers. If you come up with a robust repository rule to pull in the system openssl, consider making it available as an example. I imagine it will be useful to many besides yourself.

Nicolas Noble

unread,
Mar 4, 2020, 4:15:35 PM3/4/20
to Richard Belleville, grpc.io
The trick here is that there's no official Bazel BUILD file for OpenSSL. There's still ways to build OpenSSL using bazel, but I find it a bit iffy:


--
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 view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/e8d97291-f292-444a-85c5-10eb94883bf4%40googlegroups.com.

priy...@gmail.com

unread,
Mar 11, 2020, 10:47:30 PM3/11/20
to grpc.io
To close the loop, the following "hack" worked for us. We ended up defining the following repository before grpc in our WORKSPACE file.

new_local_repository(
    name = "boringssl",
    path = "/usr/lib/x86_64-linux-gnu",
    build_file_content = """
cc_library(
  name = "ssl",
  linkopts = ["-lssl", "-lcrypto"],
  visibility = ["//visibility:public"],
)
""",
)

To unsubscribe from this group and stop receiving emails from it, send an email to grp...@googlegroups.com.

Ben Landrum

unread,
Apr 27, 2021, 4:08:17 PM4/27/21
to grpc.io
The trick above works, although I set the path to the OpenSSL header directory on my system (/usr/include/openssl), so that the target can provide the headers as well as the libraries.

native.new_local_repository(
    name = "boringssl",
    path = "/usr/include/openssl",


    build_file_content = """
cc_library(
    name = "ssl",

    hdrs = glob(["*"]),
    copts = ["-lcrypto", "-lssl"],
)
""",
)

In lieu of an official OpenSSL Bazel build, could workarounds like this be officially supported and mentioned in the build instructions?

Reply all
Reply to author
Forward
0 new messages