Skip to content

Target Linux in the Go package driver - #15000

Merged
copybara-service[bot] merged 2 commits into
masterfrom
test/cl988392080
Sep 25, 2026
Merged

copybara-service[bot] merged 2 commits into
masterfrom
test/cl988392080

Conversation

@copybara-service

Copy link
Copy Markdown

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

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 copybara-service Bot added the exported Issue was exported automatically label Sep 25, 2026
@copybara-service
copybara-service Bot force-pushed the test/cl988392080 branch 2 times, most recently from fbf7b41 to d1d01a3 Compare September 25, 2026 19:48
@copybara-service
copybara-service Bot merged commit 6042a8c into master Sep 25, 2026
7 of 10 checks passed
@copybara-service
copybara-service Bot deleted the test/cl988392080 branch September 25, 2026 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

exported Issue was exported automatically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants