Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
Bug fix
What does this PR do? Why is it needed?
This PR makes rules_go gets the host architecture repository_ctx, which in turn get it from JVM. This is because Bazel determines default host platform from its JVM https://github.com/bazelbuild/bazel/blob/a380a157f658cc392f66f86b6aba340c461dc408/src/main/java/com/google/devtools/build/lib/bazel/repository/LocalConfigPlatformFunction.java#L63 and https://github.com/bazelbuild/bazel/blob/577cfbc8a2b0841cd67a918febe9e3c5fcb3882e/src/main/java/com/google/devtools/build/lib/util/CPU.java#L56
If rules_go determines the host platform by calling
uname
, we may run into an interesting situation when users accidentally runs an ARM64 version of Bazel binary, with comes with ARM64 JVM, in a terminal with Rosetta translation:Leading to:
Which issues(s) does this PR fix?
Fixes #3086
Other notes for review
Linux and Windows shouldn't have this problem, but getting arch from repository_ctx is much simpler than their current implementation. So I change all of them together. I don't have access to all these OS/Arch combination to verify. So I just optimistically assume that they would work. We can always override the arch names as needed in the future.