Add a build setting to disable architecture-specific binary output paths. #2249
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.
This is another attempt to fix #1239 (
go_binary
output paths containing architecture-specific components). See #1257 for a previous approach that wasn't accepted.This time I'm using the "Starlark build settings" feature of newer Bazels (https://docs.bazel.build/versions/1.0.0/skylark/config.html), which lets us cleanly plumb the setting from a command-line flag to
GoContext
. The end result:In addition to being set by a flag, Bazel has an in-development mechanism ("configuration transitions") for overriding this on a per-target basis, and having it propagate through the dependency graph. So a target that built a deployable container image could use this to ensure its contained binaries have consistent paths regardless of whether they're written in C++ or Go.
Note: Bazel's option parser doesn't accept flags for build settings defined in external repositories (bazelbuild/bazel#10039). The fix is bazelbuild/bazel#10052 and it should hopefully land in v1.2.