Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go_local_sdk: more strict SDK platform detection #2765

Merged
merged 1 commit into from Dec 21, 2020

Conversation

prattmic
Copy link
Contributor

@prattmic prattmic commented Dec 21, 2020

We determine the "SDK platform" by looking at the goos_goarch
subdirectory of pkg/tool. If the goroot has actually built the toolchain
for multiple platforms, then we just pick the first one and potentially
fail cryptically later.

Ideally, we would simply register toolchains for all of the host
platforms we find, but that is likely a much larger change. Until then,
provide a much clearer error message that we don't like finding multiple
platforms.

Fixes #2764

What type of PR is this?

Bug fix

What does this PR do? Why is it needed?

When pointing a go_local_sdk to a toolchain with multiple platforms this improves the error from a cryptic "no matching toolchains found for types @io_bazel_rules_go//go:toolchain" to "Error in fail: Could not detect SDK platform: found multiple platforms ["darwin_amd64", "linux_amd64"] in /usr/local/google/home/mpratt/src/go/pkg/tool".

This will make it more clear that the user should delete the extra platforms. Though ideally they could either specify the platform in go_local_sdk or we could register all of the platforms.

Which issues(s) does this PR fix?

Fixes #2764

Other notes for review

We determine the "SDK platform" by looking at the goos_goarch
subdirectory of pkg/tool. If the goroot has actually built the toolchain
for multiple platforms, then we just pick the first one and potentially
fail cryptically later.

Ideally, we would simply register toolchains for all of the host
platforms we find, but that is likely a much larger change. Until then,
provide a much clearer error message that we don't like finding multiple
platforms.

Fixes bazelbuild#2764
Copy link
Contributor

@jayconrod jayconrod left a comment

Choose a reason for hiding this comment

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

Looks good. Thanks for fixing this.

@jayconrod jayconrod merged commit a322b06 into bazelbuild:master Dec 21, 2020
jayconrod pushed a commit that referenced this pull request Dec 23, 2020
We determine the "SDK platform" by looking at the goos_goarch
subdirectory of pkg/tool. If the goroot has actually built the toolchain
for multiple platforms, then we just pick the first one and potentially
fail cryptically later.

Ideally, we would simply register toolchains for all of the host
platforms we find, but that is likely a much larger change. Until then,
provide a much clearer error message that we don't like finding multiple
platforms.

Fixes #2764
jayconrod pushed a commit that referenced this pull request Dec 23, 2020
We determine the "SDK platform" by looking at the goos_goarch
subdirectory of pkg/tool. If the goroot has actually built the toolchain
for multiple platforms, then we just pick the first one and potentially
fail cryptically later.

Ideally, we would simply register toolchains for all of the host
platforms we find, but that is likely a much larger change. Until then,
provide a much clearer error message that we don't like finding multiple
platforms.

Fixes #2764
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

go_local_sdk not working with local Go source tree
2 participants