Releases: bazel-contrib/rules_go
v0.51.0-rc1
Breaking changes
In order to reduce CPU and memory usage in the analysis phase and to improve the maintainability of the codebase, this release contains a number of breaking changes.
As the bulk of these changes are to the Go context API, users of the go_*
rules should not be affected (with a very minor exception below).
The maintainers would like to give a special thanks to @dzbarsky for numerous contributions to this release!
Changes to rules
- Support for inferring an importpath for libraries named
go_default_library
has been removed. Modern versions of Gazelle do not generate this target name, please ensure you are up to date. (c8a7ebca3)
Changes to the Go context API and behavior
-
Converted SDK files to depsets (
go.sdk.tools
,go.sdk.headers
,go.sdk.libs
,go.sdk.srcs
). To migrate, either callto_list()
on those properties or, preferably, use them asdepset
s in your downstream actions. To remain compatible with older versions, consider a conditional conversion such asdepset_or_list if type(depset_or_list) == type([]) else depset_or_list.to_list()
(3994841a) -
go.sdk_files
has been removed and can be replaced withdepset(direct = [go.sdk.go], transitive = [go.sdk.srcs, go.sdk.headers, go.sdk.libs, go.sdk.tools])
(which is adepset
). Wherever possible, try to use only the subset of those files that's actually needed. -
GoSource
andGoLibrary
providers have been merged and renamed toGoInfo
. The previous names are now aliases, but can result in errors about duplicate providers when both are returned from the same rule.go.new_library
andgo.library_to_source
are now deprecated. To migrate, usego.new_go_info
. To remain compatible with older versions that require both providers, consider checking whetherGoSource != GoLibrary
. (564f8204) -
Some fields on the Go context object are marked deprecated.
go_context
will still add them to the context object, unless it is invoked withinclude_deprecated_properties = False
. This default will be flipped in the future and eventually this codepath will be removed. (aa96a1174) You can migrate as follows:go.root
->go.env["GOROOT"]
go.go
->go.sdk.go
go.sdk_root
->go.sdk.root_file
go.sdk_tools
->go.sdk.tools
go.package_list
->go.sdk.package_list
go.tags
->go.mode.tags
go.stamp
->go.mode.stamp
go.cover_format
->go.mode.cover_format
go.pgoprofile
->go.mode.pgoprofile
-
Removed
get_nogo
from the Go context object (0f88f8c8) -
Removed
exe_extension
andshared_extension
from the Go context object. (c419453a) -
Removed
GoSource.cc_info
. If you need to access theCcInfo
from a Go target, you will need to apply the_go_cc_aspect
fromgo/private/rules/binary.bzl
. Please let us know if it's needed and we can move it to public API. (a01ba7c72) -
go_binary
andgo_test
targets no longer exposeGoInfo
,GoSource
orGoLibrary
providers. If you need a dedicated provider to attach an aspect to, please let us know. (2d2266) -
The Go context's
mode
property is now aGoConfigInfo
provider instead of a bare struct.go.mode.link
has been renamed togo.mode.linkmode
(5933f872) -
If you are relying on
go_context
to read an_stdlib
attribute from yourattr
s, please ensure the attribute is not transitioned, as it will no longer handle a list value. (9214edcd126) -
go_context
now accepts keyword arguments for the following fields:go_context_data
,importpath
,importmap
,embed
,importpath_aliases
. If these properties are omitted, the function will continue to fall back to reading them fromattr
. Consider passing these explicitly to improve code clarity and analysis phase performance. (6749a3819, f3029e2a8)
Changes to providers
GoSource
-
Removed
cgo_deps
, usecdeps
instead (56d415d) -
Removed
orig_srcs
(520bee50) -
Removed
cgo_exports
(86c3f3ae97) -
Converted
cover
to adepset
(692d008c96) -
deps
is now a list ofGoArchive
s instead ofTarget
s (a32f3e1)
GoArchive
- Removed
mode
, usesource.mode
instead (bfd99a663)
GoArchiveData
- Removed
data_files
, use withrunfiles
instead, which is arunfiles
object (60f55c91ce)
CgoContextInfo
- Converted
cc_toolchain_files
to adepset
(3994841)
WORKSPACE
code
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "io_bazel_rules_go",
sha256 = "fcafde4bc064dc4e2b37b910e1aa61853a6e654e1927671eaca4853678f071d7",
urls = [
"https://mirror.bazel.build/github.com/bazel-contrib/rules_go/releases/download/v0.51.0-rc1/rules_go-v0.51.0-rc1.zip",
"https://github.com/bazel-contrib/rules_go/releases/download/v0.51.0-rc1/rules_go-v0.51.0-rc1.zip",
],
)
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
go_rules_dependencies()
go_register_toolchains(version = "1.23.3")
What's Changed
- Lazy expand absolute path to avoid including them in the output by @AlessandroPatti in #4009
- Stop splitting sources in emit_archive by @dzbarsky in #4015
- Remove split_srcs by @dzbarsky in #4019
- Remove orig_src_map by @dzbarsky in #4025
- Simplify how we emit GoStdLib by @dzbarsky in #4026
- Cleanup GoArchiveData runfiles handling by @dzbarsky in #4024
- Use depset for SDK files by @dzbarsky in #4014
- Tweak how we pass GOEXPERIMENT to actions by @dzbarsky in #4022
- Remove get_nogo from context by @dzbarsky in #4029
- Remove mode from GoArchive by @dzbarsky in #4028
- Remove cgo_deps from GoSource provider by @dzbarsky in #4031
- Cleanup binary extension computation by @dzbarsky in #4033
- add docs for
go_deps.gazelle_default_attributes
by @tyler-french in #4021 - Tweak nogo archive handling by @dzbarsky in #4023
- Prefer rfind to rpartition in go_context by @dzbarsky in #4035
- Add qnx and osx platforms by @hofbi in #4036
- Move PATH env-var computation to GoContextInfo by @dzbarsky in #4037
- Turn source.cover into a depset by @dzbarsky in #4039
- Create shallower runfiles by @dzbarsky in #4040
- docs: add missing anchor to Bazel toolchains definition by @albertocavalcante in #4042
- Cleanup compilepkg flags handling by @dzbarsky in #4043
- GoSource can store dependent archives instead of full deps by @dzbarsky in #4041
- Remove some fields from Go context by @dzbarsky in #4034
- Optimize CcInfo computation by @dzbarsky in #4020
- Remove GoSource/GoLibrary from test/binary rules by @dzbarsky in #4044
- Remove orig_srcs by @dzbarsky in #4038
- Cleanup infer_importpath by @dzbarsky in #4047
- Cleanup importpath/importmap handling in go_context by @dzbarsky in #4052
- Remove cgo_exports ...
v0.50.1
WORKSPACE
code
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "io_bazel_rules_go",
sha256 = "f4a9314518ca6acfa16cc4ab43b0b8ce1e4ea64b81c38d8a3772883f153346b8",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.50.1/rules_go-v0.50.1.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.50.1/rules_go-v0.50.1.zip",
],
)
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
go_rules_dependencies()
go_register_toolchains(version = "1.23.0")
Fixes Included:
Full Changelog: v0.50.0...v0.50.1
v0.50.0
WORKSPACE
code
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "io_bazel_rules_go",
sha256 = "67b4d1f517ba73e0a92eb2f57d821f2ddc21f5bc2bd7a231573f11bd8758192e",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.50.0/rules_go-v0.50.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.50.0/rules_go-v0.50.0.zip",
],
)
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
go_rules_dependencies()
go_register_toolchains(version = "1.23.0")
What's Changed
- Break reliance on GOROOT_FINAL by @JacobOaks in #3984
- Migrate to macos_arm64 by @meteorcloudy in #3990
- Support matching release candidate toolchain versions by @JacobOaks in #3998
- rm crosstool by @sluongng in #3986
- fix(timeout.go): remove redundant leaked go func in RegisterTimeoutHandler by @Roytangrb in #4004
- Run nogo in a separate validation action by @fmeum in #3995
New Contributors
- @JacobOaks made their first contribution in #3984
- @Roytangrb made their first contribution in #4004
Full Changelog: release-0.49...release-0.50
v0.49.0
WORKSPACE
code
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "io_bazel_rules_go",
sha256 = "d93ef02f1e72c82d8bb3d5169519b36167b33cf68c252525e3b9d3d5dd143de7",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.49.0/rules_go-v0.49.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.49.0/rules_go-v0.49.0.zip",
],
)
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
go_rules_dependencies()
go_register_toolchains(version = "1.22.5")
What's Changed
- Add support for path mapping by @fmeum in #3915
- Introduce rules_go_unsupported_feature by @cramertj in #3955
- Automatically run
bazel mod tidy
in@rules_go//go
by @fmeum in #3927 - Fix revive warning in testmain.go files by @EdSchouten in #3958
- Revert "feat(mode): add
purego
tag whenpure
(#3901)" by @fmeum in #3961 - prepare patch release 0.48.1 by @tyler-french in #3963
- Fix broken link to https://bazel.build/concepts/dependencies#data-dependencies by @alexbozhenko in #3960
- docs: Discourage use
go_sdk.host()
in bzlmod.md (see #713) by @vorburger in #3968 - Add linux/ppc64le to GOARCH constraints by @c16a in #3975
- gopackagesdriver: Make kind query regexes anchored by @jscissr in #3978
- Add a full
fs.FS
implementation torunfiles
by @fmeum in #3969 - update readmes for latest release by @tyler-french in #3988
- prepare release 0.49.0 by @tyler-french in #3989
New Contributors
- @cramertj made their first contribution in #3955
- @alexbozhenko made their first contribution in #3960
- @vorburger made their first contribution in #3968
- @c16a made their first contribution in #3975
- @jscissr made their first contribution in #3978
Full Changelog: v0.48.0...v0.49.0
v0.48.1
WORKSPACE
code
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "io_bazel_rules_go",
sha256 = "b2038e2de2cace18f032249cb4bb0048abf583a36369fa98f687af1b3f880b26",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.48.1/rules_go-v0.48.1.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.48.1/rules_go-v0.48.1.zip",
],
)
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
go_rules_dependencies()
go_register_toolchains(version = "1.22.4")
Full Changelog: v0.48.0...v0.48.1
v0.48.0
Important Changes!
--incompatible_enable_proto_toolchain_resolution
is now supported in rules_go
. This means that protoc should now be supplied as a toolchain. protoc
can be registered using https://github.com/aspect-build/toolchains_protoc, or a local proto toolchain can be added.
rules_proto
6.0.0 is required to use Go proto rules.
WORKSPACE
code
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "io_bazel_rules_go",
sha256 = "33acc4ae0f70502db4b893c9fc1dd7a9bf998c23e7ff2c4517741d4049a976f8",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.48.0/rules_go-v0.48.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.48.0/rules_go-v0.48.0.zip",
],
)
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
go_rules_dependencies()
go_register_toolchains(version = "1.22.3")
What's Changed
- Update docs to cover new FilePath ReplaceDirective Support by @stefanpenner in #3931
- go_test: use different mnemonic for compilation by @sluongng in #3936
- Add go.work support to the documentation by @stefanpenner in #3932
- feat(mode): add
purego
tag whenpure
by @mattyclarkson in #3901 - generate_test_main: Move timeout handling back to bzltestutil by @DolceTriade in #3939
- Add support for
--incompatible_enable_proto_toolchain_resolution
by @fmeum in #3919 - Add exec_compatible_with to @go_sdk//:builder by @EdSchouten in #3943
- prepare v0.48.0 release by @tyler-french in #3946
New Contributors
- @stefanpenner made their first contribution in #3931
Full Changelog: v0.47.1...v0.48.0
v0.47.1
WORKSPACE
code
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "io_bazel_rules_go",
sha256 = "f74c98d6df55217a36859c74b460e774abc0410a47cc100d822be34d5f990f16",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.47.1/rules_go-v0.47.1.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.47.1/rules_go-v0.47.1.zip",
],
)
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
go_rules_dependencies()
go_register_toolchains(version = "1.22.2")
What's Changed
- bzltestutil: restore timeout signal handler by @sluongng in #3929
- feat: support syso files in srcs. by @connyay in #3763
- prepare patch release 0.47.1 by @tyler-french in #3933
New Contributors
Full Changelog: v0.47.0...v0.47.1
v0.47.0
WORKSPACE
code
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "io_bazel_rules_go",
sha256 = "af47f30e9cbd70ae34e49866e201b3f77069abb111183f2c0297e7e74ba6bbc0",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.47.0/rules_go-v0.47.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.47.0/rules_go-v0.47.0.zip",
],
)
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
go_rules_dependencies()
go_register_toolchains(version = "1.22.2")
What's Changed
- Add Bazel version matrix to BCR
presubmit.yml
by @fmeum in #3861 - Update toolchains_llvm URL and hash by @fmeum in #3864
- pass correct (non
"main"
) importpath to nogo formain
package by @Strum355 in #3863 - Make exec cfg check for
//go
stricter by @fmeum in #3867 - Fixes the Bazel CI error by @sgowroji in #3869
- [go_library] add .x file to declared output files in DefaultInfo by @tyler-french in #3866
- Remove Latin-1 workaround on Bazel 6.4.0+ by @mattyclarkson in #3872
- fix sdk download for common execution platforms by @scaiper in #3874
- Bump Go version to 1.21.8 by @fmeum in #3880
- Update README.rst to point to correct GH release tags by @dcarney in #3881
- Update bzlmod.md fix typo by @mmrath in #3882
- Cleanup temp dirs in GoToolchainBinaryBuild by @hauserx in #3885
- gopackagesdriver: move and simplify test by @jayconrod in #3856
- Support Go version schema change since 1.21 by @baizhenyu in #3891
- gopackagesdriver: fix version check with Bazel development versions by @jayconrod in #3893
- Revert "improving logging for subcommand failure (#3824)" by @linzhp in #3892
- Replace instances of to_json() method with json.encode(..) by @c-mita in #3896
- add nogo parsing support for nogo explanations by @andyscott in #3899
- [nogo] match regexp againts relative paths by @scaiper in #3898
- Add
bazel_features
transitive.bzl
s tobzl_library
targets by @fmeum in #3903 - Add //go/private:polyfill_bazel_features.bzl to sources. by @spags-lacework in #3908
- Reformat with buildifier by @fmeum in #3910
- GoLink action. Use -extar if cc_toolchain provides ar path by @OparinE in #3916
- Mark
go_sdk
extension asreproducible
by @fmeum in #3911 - Don't ignore the return value of runfiles.merge_all() by @EdSchouten in #3918
- Use Gazelle's
go_env
in@rules_go//go
by @fmeum in #3909 - Setting test.timeout according to TEST_TIMEOUT by @linzhp in #3920
- prepare rules_go v 0.47 by @tyler-french in #3923
New Contributors
- @Strum355 made their first contribution in #3863
- @sgowroji made their first contribution in #3869
- @mattyclarkson made their first contribution in #3872
- @scaiper made their first contribution in #3874
- @dcarney made their first contribution in #3881
- @mmrath made their first contribution in #3882
- @hauserx made their first contribution in #3885
- @baizhenyu made their first contribution in #3891
- @c-mita made their first contribution in #3896
- @spags-lacework made their first contribution in #3908
- @OparinE made their first contribution in #3916
Full Changelog: v0.46.0...v0.47.0
v0.46.0
WORKSPACE
code
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "io_bazel_rules_go",
sha256 = "80a98277ad1311dacd837f9b16db62887702e9f1d1c4c9f796d0121a46c8e184",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.46.0/rules_go-v0.46.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.46.0/rules_go-v0.46.0.zip",
],
)
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
go_rules_dependencies()
go_register_toolchains(version = "1.22.0")
What's Changed
- Support custom
GOARM
architecture levels via platform constraints by @LINKIWI in #3837 - Emit nogo facts into a separate archive by @fmeum in #3789
- go_test: ensure external source compilation has data by @sluongng in #3848
- Fix invocation of assembler for go1.22 by @jquirke in #3756
- nogo: Create a go_register_nogo wrapper for WORKSPACE users. by @DolceTriade in #3842
- prepare minor release 0.46 by @tyler-french in #3854
New Contributors
Full Changelog: v0.45.1...v0.46.0
v0.45.1
WORKSPACE
code
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "io_bazel_rules_go",
sha256 = "6734a719993b1ba4ebe9806e853864395a8d3968ad27f9dd759c196b3eb3abe8",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.45.1/rules_go-v0.45.1.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.45.1/rules_go-v0.45.1.zip",
],
)
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
go_rules_dependencies()
go_register_toolchains(version = "1.21.6")
What's Changed
- Disable
layering_check
feature in CGo tests by @fmeum in #3829 - Print stack traces without panicking on test timeout by @fmeum in #3833
- Fix regression in empty
.go
file filtering for nogo by @fmeum in #3832 - release patch version 0.45.1 by @tyler-french in #3836
Full Changelog: v0.45.0...v0.45.1