building with bazel and host Go toolchain

1,346 views
Skip to first unread message

Dmitry Vyukov

unread,
Dec 18, 2020, 10:59:02 AM12/18/20
to gviso...@googlegroups.com
Hello,

I would like to build runsc with bazel but with host Go toolchain for
some experiments.
I need to use bazel because of --instrumentation_filter flag, so the
go branch won't work.

I've found this:
https://github.com/bazelbuild/rules_go/blob/master/go/toolchains.rst#using-the-installed-go-sdk
but all my attempts to fit it into tools/bazeldefs/go.bzl fail with errors.

Is it possible? Could you please provide a patch that does it.

TIA

Michael Pratt

unread,
Dec 21, 2020, 11:21:56 AM12/21/20
to Dmitry Vyukov, gVisor Development
Typically, this is a simple matter of editing WORKSPACE to contain
go_local_sdk pointing at the local GOROOT you wish to use, like so:
https://github.com/google/gvisor/commit/0ab5b8a6b74713cab0ad634fb3331f0aa0890b6c

For some reason this doesn't work for me on my typical Go dev tree
(fails with "ERROR: While resolving toolchains for target
//runsc:runsc: no matching toolchains found for types
@io_bazel_rules_go//go:toolchain"). However, it does work fine on a
clean clone, so try that if you have issues. I suspect this may be a
rules_go bug.

It also seems to be broken with HEAD Go (linker errors like "pack:
open bazel-out/host/bin/external/org_golang_x_tools/internal/event/label/label.x:
no such file or directory"), but works fine with tag go1.15.6. This is
also likely a rules_go issue with recent linker changes in 1.16.
> --
> You received this message because you are subscribed to the Google Groups "gVisor Development [Public]" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to gvisor-dev+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/gvisor-dev/CACT4Y%2BYDLHkTc5C6PANnPiqquTwstLMbB0NV7dwNgpJqokbw2g%40mail.gmail.com.

Michael Pratt

unread,
Dec 21, 2020, 4:34:01 PM12/21/20
to Dmitry Vyukov, gVisor Development
For completeness, the two bugs I encountered:

Existing Go tree doesn't work:
https://github.com/bazelbuild/rules_go/issues/2764 (can't have more
that one goos_goarch dir in pkg/tool)
Go 1.16 is broken: https://github.com/bazelbuild/rules_go/issues/2762

Dmitry Vyukov

unread,
Jan 11, 2021, 12:32:46 PM1/11/21
to Michael Pratt, gVisor Development
Thanks, but currently all builds fail for me.
I am on commit 0c99ab70905fa4eaf8bc7b0ca846e12d7bbc6e39 without any
local changes.
On 2 different machines I am getting:

gvisor💻 bazel build runsc
Extracting Bazel installation...
Starting local Bazel server and connecting to it...
INFO: Repository io_bazel_rules_go instantiated at:
/usr/local/google/home/dvyukov/src/gvisor/WORKSPACE:35:13: in <toplevel>
Repository rule http_archive defined at:
/usr/local/google/home/dvyukov/.cache/bazel/_bazel_dvyukov/42571c499bb753a6e5c4fdf61e6007b2/external/bazel_tools/tools/build_defs/repo/http.bzl:336:31:
in <toplevel>
WARNING: Download from
https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.24.10/rules_go-v0.24.10.tar.gz
failed: class com.google.devtools.build.lib.bazel.repository.downloader.UnrecoverableHttpException
Checksum was 8e9434015ff8f3d6962cb8f016230ea7acc1ac402b760a8d66ff54dc11673ca6
but wanted a515569b4903776eae90ac2696b34ee1dd45600cf9dfd7d16475e2df32867521
WARNING: Download from
https://github.com/bazelbuild/rules_go/releases/download/v0.24.10/rules_go-v0.24.10.tar.gz
failed: class com.google.devtools.build.lib.bazel.repository.downloader.UnrecoverableHttpException
Checksum was 8e9434015ff8f3d6962cb8f016230ea7acc1ac402b760a8d66ff54dc11673ca6
but wanted a515569b4903776eae90ac2696b34ee1dd45600cf9dfd7d16475e2df32867521
ERROR: An error occurred during the fetch of repository 'io_bazel_rules_go':
Traceback (most recent call last):
File "/usr/local/google/home/dvyukov/.cache/bazel/_bazel_dvyukov/42571c499bb753a6e5c4fdf61e6007b2/external/bazel_tools/tools/build_defs/repo/http.bzl",
line 111, column 45, in _http_archive_impl
download_info = ctx.download_and_extract(
Error in download_and_extract: java.io.IOException: Error downloading
[https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.24.10/rules_go-v0.24.10.tar.gz,
https://github.com/bazelbuild/rules_go/releases/download/v0.24.10/rules_go-v0.24.10.tar.gz]
to /usr/local/google/home/dvyukov/.cache/bazel/_bazel_dvyukov/42571c499bb753a6e5c4fdf61e6007b2/external/io_bazel_rules_go/temp16445274802951162372/rules_go-v0.24.10.tar.gz:
Checksum was 8e9434015ff8f3d6962cb8f016230ea7acc1ac402b760a8d66ff54dc11673ca6
but wanted a515569b4903776eae90ac2696b34ee1dd45600cf9dfd7d16475e2df32867521
ERROR: no such package '@io_bazel_rules_go//go': java.io.IOException:
Error downloading
[https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.24.10/rules_go-v0.24.10.tar.gz,
https://github.com/bazelbuild/rules_go/releases/download/v0.24.10/rules_go-v0.24.10.tar.gz]
to /usr/local/google/home/dvyukov/.cache/bazel/_bazel_dvyukov/42571c499bb753a6e5c4fdf61e6007b2/external/io_bazel_rules_go/temp16445274802951162372/rules_go-v0.24.10.tar.gz:
Checksum was 8e9434015ff8f3d6962cb8f016230ea7acc1ac402b760a8d66ff54dc11673ca6
but wanted a515569b4903776eae90ac2696b34ee1dd45600cf9dfd7d16475e2df32867521
INFO: Elapsed time: 7.161s
INFO: 0 processes.

Adin Scannell

unread,
Jan 11, 2021, 12:37:39 PM1/11/21
to Dmitry Vyukov, Michael Pratt, gVisor Development
On Mon, Jan 11, 2021 at 9:32 AM 'Dmitry Vyukov' via gVisor Development [Public] <gviso...@googlegroups.com> wrote:
Thanks, but currently all builds fail for me.
I am on commit 0c99ab70905fa4eaf8bc7b0ca846e12d7bbc6e39 without any
local changes.
On 2 different machines I am getting:

I've posted a change to fix this, but I need to understand how this was merged in the first place. (The broken change passed on continuous integration commits, so there must be some kind of broken caching happening.)

--
You received this message because you are subscribed to the Google Groups "gVisor Development [Public]" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gvisor-dev+...@googlegroups.com.

Dmitry Vyukov

unread,
Jan 12, 2021, 7:28:43 AM1/12/21
to Adin Scannell, Michael Pratt, gVisor Development
On Mon, Jan 11, 2021 at 6:37 PM Adin Scannell <asca...@google.com> wrote:
>
> On Mon, Jan 11, 2021 at 9:32 AM 'Dmitry Vyukov' via gVisor Development [Public] <gviso...@googlegroups.com> wrote:
>>
>> Thanks, but currently all builds fail for me.
>> I am on commit 0c99ab70905fa4eaf8bc7b0ca846e12d7bbc6e39 without any
>> local changes.
>> On 2 different machines I am getting:
>
> I've posted a change to fix this, but I need to understand how this was merged in the first place. (The broken change passed on continuous integration commits, so there must be some kind of broken caching happening.)


FTR, building with a local toolchain now works for me on commit
a20da708291e2e5bdece5176dce61c1b4b10b7d9.
Reply all
Reply to author
Forward
0 new messages