Skip to content

Conversation

@fmeum
Copy link
Member

@fmeum fmeum commented Aug 14, 2025

What type of PR is this?

Fix for compatibility with Go 1.25

What does this PR do? Why is it needed?

The pack command, which is no longer shipped as a prebuilt binary with Go 1.25, is now compiled from source together with the builder binary.

Conditional logic is avoided by always compiling pack from source, even on Go versions before 1.25. By enabling go build caching in go_tool_binary, the overhead compared to building just the builder binary is negligible.

Which issues(s) does this PR fix?

ref: golang/go#74080
fixes #4398

Other notes for review

…g/tool"

In go1.25 the "cmd/pack" command is no longer shipped with Go
distributions, which results is build failures that look like
```
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
2025-06-09 00:44:46 PDT
compilepkg: error running subcommand external/go_sdk/pkg/tool/linux_amd64/pack: fork/exec external/go_sdk/pkg/tool/linux_amd64/pack: no such file or directory
2025-06-09 00:44:46 PDT
ERROR: /home/testuser/.cache/bazel-single-base/external/io_nhooyr_websocket/BUILD.bazel:3:11: GoCompilePkg external/io_nhooyr_websocket/websocket.a failed: (Exit 1): builder failed: error executing GoCompilePkg command (from target @@io_nhooyr_websocket//:websocket) bazel-out/k8-opt-exec-ST-a828a81199fe/bin/external/go_sdk/builder_reset/builder compilepkg -sdk external/go_sdk -goroot bazel-out/k8-fastbuild/bin/external/io_bazel_rules_go/stdlib_ -installsuffix ... (remaining 63 arguments skipped)
```

Since the pack command is used to compile Go programs (in compilepkg.go)
we need to build it from source.

golang/go#74080

#4398
@fmeum fmeum force-pushed the fmeum/exec-pack branch 2 times, most recently from 20c89e2 to 2e7304d Compare August 14, 2025 08:38
@fmeum fmeum requested a review from Copilot August 14, 2025 08:39

This comment was marked as off-topic.

@fmeum fmeum changed the title Fmeum/exec pack Compile cmd/pack from source and update to Go 1.25 Aug 14, 2025
@fmeum fmeum marked this pull request as ready for review August 14, 2025 10:36
@fmeum fmeum requested review from dzbarsky, jayconrod and linzhp and removed request for dzbarsky August 14, 2025 10:36
@fmeum
Copy link
Member Author

fmeum commented Aug 14, 2025

CC @dzbarsky @r-hang

@r-hang By building this together with the builder, we can be sure that it is built for a matching platform.

Copy link
Contributor

@sluongng sluongng left a comment

Choose a reason for hiding this comment

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

I think the current approach is fine. What's a bit concerning to me is for folks who use the Bazel-managed gosdk for other tools (vscode, golangcilint, etc...). In those cases the gosdk won't have a cmd/pack tool to use and would still end up rebuilding one for the host? 🤔

I guess that's technically fine since building pack from source should be relatively fast.

@fmeum
Copy link
Member Author

fmeum commented Aug 14, 2025

In those cases the gosdk won't have a cmd/pack tool to use and would still end up rebuilding one for the host? 🤔

I don't feel bad for doing exactly what the vanilla Go SDK would do in that case :-D

Copy link
Contributor

@dzbarsky dzbarsky left a comment

Choose a reason for hiding this comment

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

Nice, doing this as part of the builder makes a lot of sense

Copy link
Contributor

@r-hang r-hang left a comment

Choose a reason for hiding this comment

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

nice! looks good to me. i'll close my PR.

@fmeum fmeum merged commit 4d0a821 into master Aug 14, 2025
4 checks passed
@fmeum fmeum deleted the fmeum/exec-pack branch August 14, 2025 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

go1.25: external/go_sdk/pkg/tool/linux_amd64/pack: no such file or directory

5 participants