Skip to content

Commit

Permalink
[dev.cryptoboring] misc/boring: update README for Bazel
Browse files Browse the repository at this point in the history
Change-Id: I77e9f68f38dbeb4e22b9557aaad9eb92b7baf9cb
Reviewed-on: https://go-review.googlesource.com/86278
Reviewed-by: Russ Cox <rsc@golang.org>
  • Loading branch information
ixdy authored and rsc committed Feb 9, 2018
1 parent c3d83ee commit 528dad8
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions misc/boring/README.md
Expand Up @@ -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

Expand Down

0 comments on commit 528dad8

Please sign in to comment.