Skip to content

Conversation

sgmonroy
Copy link
Contributor

@sgmonroy sgmonroy commented Nov 6, 2019

This patch works around some issues in rules_go/nogo from v0.19.0+
where it fails to exclude paths appropiately for packages that use cgo.

See issue below:
bazel-contrib/rules_go#2172


This change is Reviewable

Copy link
Contributor

@kormat kormat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 3 files reviewed, 1 unresolved discussion (waiting on @sgmonroy)

a discussion (no related file):
gazelle is throwing errors for me:

$ make bazel
...
DEBUG: /home/kormat/.cache/bazel/_bazel_kormat/5fc5be52f0a76618e694c19b288efbf5/external/bazel_gazelle/internal/go_repository.bzl:182:13: gazelle: gazelle: finding module path for import gol
ang.org/x/sys/windows: exit status 1: go: finding golang.org/x/sys/windows latest
go: finding golang.org/x/sys latest
can't load package: package golang.org/x/sys/windows: build constraints exclude all Go files in /home/kormat/.cache/bazel/_bazel_kormat/5fc5be52f0a76618e694c19b288efbf5/external/bazel_gazell
e_go_repository_cache/pkg/mod/golang.org/x/sys@v0.0.0-20191105231009-c1f44814a5cd/windows
DEBUG: /home/kormat/.cache/bazel/_bazel_kormat/5fc5be52f0a76618e694c19b288efbf5/external/bazel_gazelle/internal/go_repository.bzl:182:13: gazelle: gazelle: finding module path for import git
hub.com/scionproto/scion/go/lib/serrors: exit status 1: go: finding github.com/scionproto/scion/go/lib/serrors latest
go: finding github.com/scionproto/scion/go/lib latest
go: finding github.com/scionproto/scion/go latest
go: finding github.com/scionproto/scion v0.3.1
go: downloading github.com/scionproto/scion v0.3.1
can't load package: package github.com/scionproto/scion/go/lib/serrors: unknown import path "github.com/scionproto/scion/go/lib/serrors": cannot find module providing package github.com/scio
nproto/scion/go/lib/serrors
gazelle: finding module path for import fake/serrors: exit status 1: can't load package: package fake/serrors: unknown import path "fake/serrors": cannot find module providing package fake/s
errors
gazelle: finding module path for import github.com/scionproto/scion/go/lib/serrors: exit status 1: go: finding github.com/scionproto/scion/go/lib/serrors latest
go: finding github.com/scionproto/scion/go/lib latest
go: finding github.com/scionproto/scion/go latest
go: finding github.com/scionproto/scion v0.3.1
go: downloading github.com/scionproto/scion v0.3.1
can't load package: package github.com/scionproto/scion/go/lib/serrors: unknown import path "github.com/scionproto/scion/go/lib/serrors": cannot find module providing package github.com/scio
nproto/scion/go/lib/serrors

Copy link
Contributor

@kormat kormat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 3 of 3 files at r1.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @sgmonroy)

a discussion (no related file):

Previously, kormat (Stephen Shirley) wrote…

gazelle is throwing errors for me:

$ make bazel
...
DEBUG: /home/kormat/.cache/bazel/_bazel_kormat/5fc5be52f0a76618e694c19b288efbf5/external/bazel_gazelle/internal/go_repository.bzl:182:13: gazelle: gazelle: finding module path for import gol
ang.org/x/sys/windows: exit status 1: go: finding golang.org/x/sys/windows latest
go: finding golang.org/x/sys latest
can't load package: package golang.org/x/sys/windows: build constraints exclude all Go files in /home/kormat/.cache/bazel/_bazel_kormat/5fc5be52f0a76618e694c19b288efbf5/external/bazel_gazell
e_go_repository_cache/pkg/mod/golang.org/x/sys@v0.0.0-20191105231009-c1f44814a5cd/windows
DEBUG: /home/kormat/.cache/bazel/_bazel_kormat/5fc5be52f0a76618e694c19b288efbf5/external/bazel_gazelle/internal/go_repository.bzl:182:13: gazelle: gazelle: finding module path for import git
hub.com/scionproto/scion/go/lib/serrors: exit status 1: go: finding github.com/scionproto/scion/go/lib/serrors latest
go: finding github.com/scionproto/scion/go/lib latest
go: finding github.com/scionproto/scion/go latest
go: finding github.com/scionproto/scion v0.3.1
go: downloading github.com/scionproto/scion v0.3.1
can't load package: package github.com/scionproto/scion/go/lib/serrors: unknown import path "github.com/scionproto/scion/go/lib/serrors": cannot find module providing package github.com/scio
nproto/scion/go/lib/serrors
gazelle: finding module path for import fake/serrors: exit status 1: can't load package: package fake/serrors: unknown import path "fake/serrors": cannot find module providing package fake/s
errors
gazelle: finding module path for import github.com/scionproto/scion/go/lib/serrors: exit status 1: go: finding github.com/scionproto/scion/go/lib/serrors latest
go: finding github.com/scionproto/scion/go/lib latest
go: finding github.com/scionproto/scion/go latest
go: finding github.com/scionproto/scion v0.3.1
go: downloading github.com/scionproto/scion v0.3.1
can't load package: package github.com/scionproto/scion/go/lib/serrors: unknown import path "github.com/scionproto/scion/go/lib/serrors": cannot find module providing package github.com/scio
nproto/scion/go/lib/serrors

Nevermind, whatever that was, it went away when i did another make clean bazel. v0v.



go/lib/overlay/conn/BUILD.bazel, line 9 at r1 (raw file):

    visibility = ["//visibility:public"],
    deps = select({
        "@io_bazel_rules_go//go/platform:android": [

It's very weird to see an android target show up here.

Copy link
Contributor Author

@sgmonroy sgmonroy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @kormat)


go/lib/overlay/conn/BUILD.bazel, line 9 at r1 (raw file):

Previously, kormat (Stephen Shirley) wrote…

It's very weird to see an android target show up here.

Agree, but couldn't figure out a way to avoid that. For some reason gazelle wants to add it.
The source of it seems to be having the +build linux GO tag in the file and makes the whole select stuff happens and ultimately add the android target.
Maybe there is a way to restrict this somehow, I just didn't find it.

Copy link
Contributor

@kormat kormat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

Copy link
Contributor

@kormat kormat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @sgmonroy)


WORKSPACE, line 510 at r1 (raw file):

    importpath = "golang.org/x/ctx",
    sum = "",
    version = "latest",

This doesn't seem like a good idea. Is there a reason we can't ping to a specific version?

Copy link
Contributor Author

@sgmonroy sgmonroy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @kormat)


WORKSPACE, line 510 at r1 (raw file):

Previously, kormat (Stephen Shirley) wrote…

This doesn't seem like a good idea. Is there a reason we can't ping to a specific version?

this was added by gazelle when updating the repo

Copy link
Contributor

@kormat kormat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @sgmonroy)


WORKSPACE, line 510 at r1 (raw file):

Previously, sgmonroy (Sergio Gonzalez Monroy) wrote…

this was added by gazelle when updating the repo

Huh, i see. Let's pin to a specific version, and see if that works. Otherwise this seems likely to break at some point in the future.

Copy link
Contributor

@kormat kormat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @sgmonroy)


WORKSPACE, line 510 at r1 (raw file):

Previously, kormat (Stephen Shirley) wrote…

Huh, i see. Let's pin to a specific version, and see if that works. Otherwise this seems likely to break at some point in the future.

Ah, also bazel chokes on this:

$ bazel query 'somepath(//:scion, @org_golang_x_ctx//...)'
INFO: Call stack for the definition of repository 'org_golang_x_ctx' which is a go_repository (rule definition at /home/kormat/.cache/bazel/_bazel_kormat/5fc5be52f0a76618e694c19b288efbf5/external/bazel_gazelle/internal/go_repository.bzl:187:17):
 - /home/kormat/go/src/github.com/scionproto/scion/WORKSPACE:506:1
ERROR: An error occurred during the fetch of repository 'org_golang_x_ctx':
   if version is specified, sum must also be
ERROR: if version is specified, sum must also be
Loading: 1 packages loaded

Copy link
Collaborator

@lukedirtwalker lukedirtwalker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @kormat)


WORKSPACE, line 510 at r1 (raw file):

Previously, kormat (Stephen Shirley) wrote…

Ah, also bazel chokes on this:

$ bazel query 'somepath(//:scion, @org_golang_x_ctx//...)'
INFO: Call stack for the definition of repository 'org_golang_x_ctx' which is a go_repository (rule definition at /home/kormat/.cache/bazel/_bazel_kormat/5fc5be52f0a76618e694c19b288efbf5/external/bazel_gazelle/internal/go_repository.bzl:187:17):
 - /home/kormat/go/src/github.com/scionproto/scion/WORKSPACE:506:1
ERROR: An error occurred during the fetch of repository 'org_golang_x_ctx':
   if version is specified, sum must also be
ERROR: if version is specified, sum must also be
Loading: 1 packages loaded

@sgmonroy this isn't needed please delete this repository dependency. It builds without it.

This patch works around some issues in rules_go/nogo from v0.19.0+
where it fails to exclude paths appropiately for packages that use cgo.

See issue below:
bazel-contrib/rules_go#2172
@sgmonroy sgmonroy force-pushed the update-gazelle-rules_go branch from 71fdc4f to 5110a60 Compare November 13, 2019 07:39
Copy link
Contributor Author

@sgmonroy sgmonroy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 2 of 3 files reviewed, 1 unresolved discussion (waiting on @kormat and @lukedirtwalker)


WORKSPACE, line 510 at r1 (raw file):

Previously, lukedirtwalker (Lukas Vogel) wrote…

@sgmonroy this isn't needed please delete this repository dependency. It builds without it.

Done.

Copy link
Collaborator

@lukedirtwalker lukedirtwalker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 1 of 1 files at r2.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @kormat)

Copy link
Contributor

@kormat kormat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r2.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@sgmonroy sgmonroy merged commit f7eb075 into scionproto:master Nov 13, 2019
@sgmonroy sgmonroy deleted the update-gazelle-rules_go branch November 13, 2019 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants