Target Linux in the Go package driver - #15000
Merged
Merged
Conversation
rules_go's package driver filters files using Go's process build context [1], but builds packages with a separately selected Bazel platform [2]. On macOS the native default selects Darwin for gVisor's Linux packages; on any host GOOS or GOARCH overrides can leave file selection and the Bazel build on different targets. Default GOOS to Linux and derive GOARCH from the host CPU without requiring Go on PATH before Bazel provisions its SDK. Pass the matching Bazel platform last in the driver's build flags so GOOS and GOARCH select both sources and compiled output. Fail on unsupported host architectures and document the overrides for other targets. [1]: https://github.com/bazel-contrib/rules_go/blob/v0.57.0/go/tools/gopackagesdriver/build_context.go#L9-L17 [2]: https://github.com/bazel-contrib/rules_go/blob/v0.57.0/go/tools/gopackagesdriver/bazel_json_builder.go#L205-L217 Assisted-by: Codex
copybara-service
Bot
force-pushed
the
test/cl988392080
branch
2 times, most recently
from
September 25, 2026 19:48
fbf7b41 to
d1d01a3
Compare
PiperOrigin-RevId: 988463978
copybara-service
Bot
force-pushed
the
test/cl988392080
branch
from
September 25, 2026 20:35
d1d01a3 to
6042a8c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Target Linux in the Go package driver
rules_go's package driver filters files using Go's process build context 1, but builds packages with a separately selected Bazel platform 2. On macOS the native default selects Darwin for gVisor's Linux packages; on any host GOOS or GOARCH overrides can leave file selection and the Bazel build on different targets.
Default GOOS to Linux and derive GOARCH from the host CPU without requiring Go on PATH before Bazel provisions its SDK. Pass the matching Bazel platform last in the driver's build flags so GOOS and GOARCH select both sources and compiled output. Fail on unsupported host architectures and document the overrides for other targets.
Assisted-by: Codex
FUTURE_COPYBARA_INTEGRATE_REVIEW=#14987 from tamird:gopackagesdriver-linux 7c9156c