v0.51.0-rc1
Pre-releaseBreaking 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 from GoSource by @dzbarsky in #4051
- gomock: support uber's
-typed
flag by @maratori in #4017 - Making gopackagesdriver correctly handle relative queries made from a subdirectory. by @waltercacau in #4002
- Cleanup GoArchiveData usage of as_tuple by @dzbarsky in #4032
- Cleanup get_mode by @dzbarsky in #4055
- Cleanup _merge_embed by @dzbarsky in #4048
- Remove mode_tags_equivalent by @dzbarsky in #4057
- Remove more hasattr/getattr calls in go_context by @dzbarsky in #4054
- Speedup get_mode some more by @dzbarsky in #4056
- Support GOOS=wasip1 by @rockwotj in #4045
- Remove as_list/as_iterable usage from go_path by @dzbarsky in #4059
- Remove usage of _flatten_possibly_transitioned_attr in common case by @dzbarsky in #4060
- Document the
suffixes
attribute ofgo_proto_compiler
by @leskin-in in #3970 - Simplify duplicate importmap handling by @dzbarsky in #4016
- More go_context speedups by @dzbarsky in #4058
- builder: work around change in filepath.EvalSymlinks behavior by @jayconrod in #4050
- Handle targets provided in deps as a result of GoSource.resolver by @dzbarsky in #4063
- make
go_reset_target
public by @tyler-french in #3965 - Cleanup coverdata handling in compilepkg by @dzbarsky in #4068
- gomock: allow passing extra flags to mockgen_tool by @TvdW in #4066
- Update nogo.rst by @tyler-french in #4071
- [context.bzl] add more helpful debug message to resolver issue by @tyler-french in #4072
- Forward
-testfilter
to nogo and fix failure in case of no srcs by @fmeum in #4075 - prepare rules_go release 0.50.0 by @tyler-french in #4064
- Do not report nogo diagnostics for cgo generated files by @fmeum in #4081
- Run nogo on internal and external tests libs, not testmain by @fmeum in #4082
- Only print type-checking error once in nogo by @fmeum in #4083
- prepare patch release 0.50.1 by @tyler-french in #4087
- Always omit -pie from cc_toolchain linker flags by @siddharthab in #3693
- Use -gcflags=--pgoprofile instead of -pgo when building stdlib by @JacobOaks in #4097
- make toolchains repo more reproducible by @malt3 in #4099
- feat(gpd): add overlay support for gopackagesdriver by @LWarrens in #4101
- Remove unneeded packages from stdlib by @dzbarsky in #4093
- Mark deps explicitly added with
//go get
as direct by @fmeum in #4027 - Update Go SDK to 1.23.1 by @fmeum in #4105
- fix(gpd): keep compiled files from stdlib packages in #4114
- fix(gpd): add missing condition in MoveTestFiles() in #4118
- feat(gpd): support of GOPACKAGESDRIVER_BAZEL_COMMON_FLAGS env variable in #4117
- feat(stdlib): update TAG_AFFECTS_STDLIB dict for Go versions 1.20..1.23 in #4122
- bzlmod.md: update style of code by @tyler-french in #4123
- fix(compile): add missing GOAMD64 and GOARM env values in goctx.env_for_path_mapping in #4121
- go_sdk: Add missing arguments to cross-platform SDKs by @fmeum in #4125
- Let the Publish to BCR app maintain the module version by @fmeum in #4126
- Fix
GoArchiveData
docs by @fmeum in #4130 - fix: fix slice init length by @cuishuang in #4133
- Make it easier to parse rules_go's .bzl files with Go Starlark by @EdSchouten in #4140
- Add support for spaces and newlines in runfiles paths by @fmeum in #4136
- feat: avoid cc toolchain selection (#4145) by @sallustfire in #4146
- Allow bazel test //... to run out-of-the-box by @eljobe in #4150
- Support .syso files in the
srcs
lists forgo_library
andgo_test
rules. by @eljobe in #4151 - fix: properly expand absolute path placeholder for link calls by @voxeljorge in #4144
- Speedup compilepkg args handling by @dzbarsky in #4074
- Improve runfiles docs with examples and more deprecations by @fmeum in #4163
- Fix
go_tool_binary
non-hermeticity and Go 1.19 incompatibility by @fmeum in #4167 - fix: tests respect --strip like binaries (#4103) by @ajwerner in #4164
- Raise minimum Bazel version to 6.5.0 by @fmeum in #4171
- chore: removed some unused vars by @hauserx in #4175
- Merge GoLibrary and GoSource providers by @dzbarsky in #4030
- gomock: fix for golang.org/x/tools >= v0.27.0 by @pjjw in #4173
- prepare rules_go release 0.51.0-rc1 by @tyler-french in #4176
- fix(go/tools/releaser) allow prereleases by @tyler-french in #4177
- fix(go/tools/release): fix urls to use bazel-contrib by @tyler-french in #4178
New Contributors
- @AlessandroPatti made their first contribution in #4009
- @dzbarsky made their first contribution in #4015
- @hofbi made their first contribution in #4036
- @albertocavalcante made their first contribution in #4042
- @maratori made their first contribution in #4017
- @waltercacau made their first contribution in #4002
- @rockwotj made their first contribution in #4045
- @leskin-in made their first contribution in #3970
- @TvdW made their first contribution in #4066
- @cuishuang made their first contribution in #4133
- @sallustfire made their first contribution in #4146
- @eljobe made their first contribution in #4150
- @voxeljorge made their first contribution in #4144
- @ajwerner made their first contribution in #4164
- @pjjw made their first contribution in #4173
Full Changelog: v0.50.1...v0.51.0-rc1