From 528dad8c7252a322b41a1413945b9b17febb5105 Mon Sep 17 00:00:00 2001 From: Jeff Grafton Date: Thu, 4 Jan 2018 17:05:56 -0800 Subject: [PATCH] [dev.cryptoboring] misc/boring: update README for Bazel Change-Id: I77e9f68f38dbeb4e22b9557aaad9eb92b7baf9cb Reviewed-on: https://go-review.googlesource.com/86278 Reviewed-by: Russ Cox --- misc/boring/README.md | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/misc/boring/README.md b/misc/boring/README.md index 698b6617f9..405e36c9b5 100644 --- a/misc/boring/README.md +++ b/misc/boring/README.md @@ -68,15 +68,31 @@ and should need no other modifications. ## Building from Bazel -Using an alternate toolchain from Bazel is not as clean as it might be. -Today, as of Bazel 0.5.3 and the bazelbuild/rules_go tag 0.5.3, -it is necessary to define a `go-boringcrypto.bzl` file that duplicates -some of the rules_go internal guts and then invoke its `go_repositories` rule -instead of the standard one. - -See https://gist.github.com/rsc/6f63d54886c9c50fa924597d7355bc93 for a minimal example. - -Note that in the example that the Bazel `WORKSPACE` file still refers to the release as "go1.8.3" not "go1.8.3b2". +Starting from [bazelbuild/rules_go](https://github.com/bazelbuild/rules_go) +tag 0.7.1, simply download the BoringCrypto-enabled Go SDK using +`go_download_sdk()` before calling `go_register_toolchains()`. + +For example, to use Go 1.9.3 with BoringCrypto on Linux, use the following lines +in `WORKSPACE`: +```python +load("@io_bazel_rules_go//go:def.bzl", "go_rules_dependencies", "go_download_sdk", "go_register_toolchains") + +go_rules_dependencies() + +go_download_sdk( + name = "go_sdk", + sdks = { + "linux_amd64": ("go1.9.3b4.linux-amd64.tar.gz", "db1997b2454a2f27669b849d2d2cafb247a55128d53da678f06cb409310d6660"), + }, + urls = ["https://storage.googleapis.com/go-boringcrypto/{}"], +) + +go_register_toolchains() +``` + +**Note**: you must *not* enable `pure` mode, since cgo must be enabled. To +ensure that binaries are linked with BoringCrypto, you can set `pure = "off"` on +all relevant `go_binary` rules. ## Caveat -- 2.50.0