Releases: bazel-contrib/rules_go
v0.41.0
What's Changed
Starting this release, rules_go no longer ship with @go_googleapis
repo. Together with Gazelle v0.32.0, it means that all Go code importing generated code from Google APIs will depend on @org_golang_google_genproto
, which is resolved by Go modules. For proto files importing Google APIs proto and generating Go code, users need to:
- Add an
http_archive
rule to download Google APIs, e.g.,
http_archive(
name = "googleapis",
sha256 = "9d1a930e767c93c825398b8f8692eca3fe353b9aaadedfbcf1fca2282c85df88",
strip_prefix = "googleapis-64926d52febbf298cb82a8f472ade4a3969ba922",
urls = [
"https://github.com/googleapis/googleapis/archive/64926d52febbf298cb82a8f472ade4a3969ba922.zip",
],
)
load("@googleapis//:repository_rules.bzl", "switched_rules_by_language")
switched_rules_by_language(
name = "com_google_googleapis_imports",
)
Note that the version of Google APIs archive needs to be compatible with the pre-generated code in @org_golang_google_genproto
.
- Resolve the proto manually. If Gazelle is being used, directives like the following need to be added to a parent directory of the proto files:
# gazelle:resolve proto proto google/rpc/status.proto @googleapis//google/rpc:status_proto
# gazelle:resolve proto go google/rpc/status.proto @org_golang_google_genproto//googleapis/rpc/status
# gazelle:resolve proto google/longrunning/operations.proto @googleapis//google/longrunning:operations_proto
# gazelle:resolve proto go google/longrunning/operations.proto @org_golang_google_genproto//googleapis/longrunning
Other changes included in this release
- detect_sdk_version: Support 1.21's new VERSION file format by @evanj in #3600
- stdlib: Do not pass -static to cgo by @zecke in #3593
- Expand stdlib packages when queried by @JamyDev in #3606
- Fix stdlib file outputs pointing to processwrapper by @JamyDev in #3608
- Fix
go_sdk
extension failure for unnamed root module by @fmeum in #3612 - Adding Uber's hermetic cc toolchain for tests by @linzhp in #3609
- Implement functionality to skip tests via TESTBRIDGE_TEST_ONLY env by @yushan26 in #3618
Full Changelog: v0.40.1...v0.41.0
WORKSPACE
code
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "io_bazel_rules_go",
sha256 = "278b7ff5a826f3dc10f04feaf0b70d48b68748ccd512d7f98bf442077f043fe3",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.41.0/rules_go-v0.41.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.41.0/rules_go-v0.41.0.zip",
],
)
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
go_rules_dependencies()
go_register_toolchains(version = "1.20.5")
v0.40.1
WORKSPACE
code
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "io_bazel_rules_go",
sha256 = "51dc53293afe317d2696d4d6433a4c33feedb7748a9e352072e2ec3c0dafd2c6",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.40.1/rules_go-v0.40.1.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.40.1/rules_go-v0.40.1.zip",
],
)
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
go_rules_dependencies()
go_register_toolchains(version = "1.20.5")
Changes
This patch release cherry-picked two bug fixes related to Go package driver from master
v0.40.0
What's Changed
- Revert "Add automatic platform detection from inbound crosstool_top a… by @fmeum in #3468
- bzlmod: Add dedicated documentation by @fmeum in #3519
- Create TEST_SHARD_STATUS_FILE when sharding tests by @fmeum in #3547
- Move CI flags to .bazelrc and fix BwoB build by @fmeum in #3551
- Re-enable go_path_test on RBE by @sluongng in #3539
- nogo: provide usage doc by @sluongng in #3534
- respect global strip config by @malt3 in #3527
- stdliblist: return generated files by @grampelberg in #3552
- Fix formatting in nogo usage doc by @sluongng in #3557
- Fix
goexperiment.*
build tags by @lbcjbb in #3556 - Remove tests for
go_path
'slink
mode by @fmeum in #3565 - Fix tests with
--incompatible_disable_starlark_host_transitions
by @fmeum in #3560 - Create empty
.go
file in a random location by @fmeum in #3566 - gopackagesdriver: fix interface to work with golangci-lint (#3523) by @grampelberg in #3524
- Fix typo in load statement for bzlmod docs by @Sovietaced in #3570
- context: remove unused import by @sluongng in #3571
- docs: Mention
use_repo
automation by @fmeum in #3573 - Test basic-gazelle example with incompatible flags by @fmeum in #3575
- go_sdk extension: create
go_host_compatible_sdk
repository by @ylecornec in #3543 - docs: Mention that
gazelle:prefix
can be replaced bygo.mod
by @fmeum in #3577 - go_download_sdk: apply extraction workaround to zips on non-windows OSs by @jayconrod in #3563
- Fix
go_download_sdk
with Bazel dev versions by @fmeum in #3580 - Implement //nolint parsing similar to golangci-lint by @patrickmscott in #3562
New Contributors
- @bricedp made their first contribution in #3512
- @patrickmscott made their first contribution in #3528
- @grampelberg made their first contribution in #3552
- @Sovietaced made their first contribution in #3570
- @ylecornec made their first contribution in #3543
Full Changelog: v0.39.1...v0.40.0
WORKSPACE
code
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "io_bazel_rules_go",
sha256 = "bfc5ce70b9d1634ae54f4e7b495657a18a04e0d596785f672d35d5f505ab491a",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.40.0/rules_go-v0.40.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.40.0/rules_go-v0.40.0.zip",
],
)
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
go_rules_dependencies()
go_register_toolchains(version = "1.20.5")
v0.39.1
What's Changed
- Reland "Add new darwin CC toolchain for tests (#3460)" (#3502)
- bzlmod: Remove build_file_proto_mode attribute (#3506)
- go_register_toolchains: update sdk_kinds (#3511)
- Ignore pre-compiled stdlib only on 1.19 with experiments (#3508)
- bzlmod: Fix repo name used by gopackagesdriver (#3516)
- Pass gc_goopts to stdlib (#3518)
- Drop coverage linker flags from stdlib build (#3522)
- Fix macOS CI after --remote_download_minimal flip (#3530)
- Add defines for assembly build (#3528)
- go_tool_binary: set GOMAXPROCS to 1 (#3536)
Full Changelog: v0.39.0...v0.39.1
v0.39.0
WORKSPACE
code
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "io_bazel_rules_go",
sha256 = "6b65cb7917b4d1709f9410ffe00ecf3e160edf674b78c54a894471320862184f",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.39.0/rules_go-v0.39.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.39.0/rules_go-v0.39.0.zip",
],
)
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
go_rules_dependencies()
go_register_toolchains(version = "1.20.2")
What's Changed
- Make the toolchain's
go
binary available as a target by @fmeum in #3429 - add bazel test rule for excluded packages in popular_repos by @uberzzr in #3447
- change build test name from 'need_test' to 'build_only' by @uberzzr in #3449
- fix a grammer issue by @Longchuanzheng in #3451
- go: support "all:" prefix for "go:embed" directives by @malt3 in #3455
- Remove
filter_transition_label
workaround by @fmeum in #3438 - Extract generated code from BUILD.toolchains.bazel into a macro by @fmeum in #3439
- bzlmod: Prohibit undesirable SDK registrations in non-root modules by @fmeum in #3440
- update links to gazelle docs by @garymm in #3464
- bzlmod: Improve SDK registration by @fmeum in #3443
- Expand locations in
x_defs
values by @fmeum in #3473 - Make
//go
usable in scripts run withbazel run
by @fmeum in #3474 - Avoid repository rule restarts in go_sdk by @jfirebaugh in #3478
- bzlmod: Test BCR test module on all platforms by @fmeum in #3479
- Improve error when linkmode requires cgo by @fmeum in #3482
- Rename
error
script ingo_cross_binary
by @fmeum in #3481 - Only infer platforms from crosstool/cpu if at default by @fmeum in #3485
- Add missing darwin CPUs to apple matcher by @keith in #3461
- Canonicalize tags before transitioning by @fmeum in #3484
- Keep build tags that affect the stdlib build by @fmeum in #3488
- Quote
CC
if it contains whitespace by @fmeum in #3491 - Disable cgo by default with unsupported compilers by @fmeum in #3493
- Only install
runtime/cgo
withpure = False
by @fmeum in #3492 - Use
ctx.readdir
instead ofls
for SDK platform detection by @fmeum in #3497
New Contributors
- @uberzzr made their first contribution in #3447
- @Longchuanzheng made their first contribution in #3451
- @malt3 made their first contribution in #3455
- @tyler-french made their first contribution in #3495
Full Changelog: v0.38.0...v0.39.0
v0.38.1
Bug fixes
The go_googleapis upgrade in 0.38.0 is too disruptive. It changes the Go import paths of the proto packages, causing build failures in repos trying to upgrade to rules_go 0.38.0. Reverting the go_googleapis to the master of 2022-12-05 (#3432) for now to make rules_go upgrades easier.
WORKSPACE
code
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "io_bazel_rules_go",
sha256 = "dd926a88a564a9246713a9c00b35315f54cbd46b31a26d5d8fb264c07045f05d",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.38.1/rules_go-v0.38.1.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.38.1/rules_go-v0.38.1.zip",
],
)
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
go_rules_dependencies()
go_register_toolchains(version = "1.19.5")
Full Changelog: v0.38.0...v0.38.1
v0.38.0
Breaking changes
Starting this release, rules_go requires Bazel 5.3 and golang/x/tools at least 0.3.0. If you are using stardoc, you also need to upgrade it to 0.5.3 to recognize RunEnvironmentInfo
, which is used in this release.
Major new features
This is the first release to support Go 1.20. When on this version of Go, it is highly recommended to use Bazel 6 and set --experimental_output_directory_naming_scheme=diff_against_baseline
to prevent certain unnecessary rebuilds.
What's Changed
- preserve intermediate files if
-work
is specified by @motiejus in #3389 - Adapt
lcov_coverage_test
toexec.Command
change by @fmeum in #3392 - explicitly build relative path for Tool command in lcov_coverage_test by @matloob in #3399
- Add support for building with boringcrypto by @matloob in #3398
- Generalize
boringcrypto
toGOEXPERIMENT
support by @fmeum in #3401 - Replace
cfg = "host"
withcfg = "exec"
by @fmeum in #3404 - always produce .a files at the beginning of a build by @matloob in #3385
- Mark
nogo
targets asmanual
to keep top-level symlinks by @fmeum in #3410 - Refactoring the extld related logic by @linzhp in #3400
- Fix incompatible flags not applied to integration tests by @fmeum in #3415
- chore: remove experimental warning from bzlmod module by @alexeagle in #3418
- Add a clarifying error about dependency cycle found for internal tests by @yushan26 in #3422
- Do not use exec paths for rundir by @fmeum in #3414
- Upgrade org_golang_x_tools to 0.5.0 by @linzhp in #3356
- fix: Relative path of embedsrc by @bakjos in #3407
- Add support for env_inherit by @ttpathan in #3256
- Update stardoc to 0.5.3 by @fmeum in #3427
- Add
env
attribute togo_binary
by @fmeum in #3428
New Contributors
- @matloob made their first contribution in #3399
- @yushan26 made their first contribution in #3422
- @bakjos made their first contribution in #3407
- @ttpathan made their first contribution in #3256
Full Changelog: v0.37.0...v0.38.0
v0.37.0
Major New Features
- Support fetching packages for generated code in the Go Packages Driver
What's Changed
- bzlmod: Add missing
strip_prefix
field tosource.template.json
by @fmeum in #3359 - Declare toolchains in a separate repository by @jfirebaugh in #3348
- Delete legacy actions API by @fmeum in #3173
- go_path: support go:embed of generated files by @S-Chan in #3285
- Properly deprecate
bindata
,go_embed_data
, andgo_embed_data_deps
by @fmeum in #3362 - link.bzl: ignore duplicate dep on coverdata by @robfig in #3032
- feat(pkg-drv): add support for generated files by @JamyDev in #3354
- Remove unused variables in link action by @fmeum in #3367
- Reduce number of declared files in
emit_stdlib
by @fmeum in #3366 - Update docs regarding vendored proto files by @garymm in #3360
- go link: use external linker when in race mode by @motiejus in #3370
- Adding first example by @chrislovecnm in #3317
- fix(packagesdriver): bazelFlags should prefix the command by @JamyDev in #3371
- chore(gpd): export aspect utils for reusability by @JamyDev in #3373
- nogo: Add a _base key to be a default config for all Analyzers. by @DolceTriade in #3351
- Document that
Rlocation
can return relative paths by @fmeum in #3377 - Fix normalization check for
Rlocation
path by @fmeum in #3378 - fix(gpd): Write large target patterns to file by @JamyDev in #3372
- Make Go runfiles library repo mapping aware by @fmeum in #3347
New Contributors
- @jfirebaugh made their first contribution in #3348
- @S-Chan made their first contribution in #3285
- @garymm made their first contribution in #3360
- @motiejus made their first contribution in #3370
- @chrislovecnm made their first contribution in #3317
- @DolceTriade made their first contribution in #3351
Full Changelog: v0.36.0...v0.37.0
WORKSPACE
code
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "io_bazel_rules_go",
sha256 = "56d8c5a5c91e1af73eca71a6fab2ced959b67c86d12ba37feedb0a2dfea441a6",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.37.0/rules_go-v0.37.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.37.0/rules_go-v0.37.0.zip",
],
)
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
go_rules_dependencies()
go_register_toolchains(version = "1.19.3")
v0.36.0
Major new features
- The Go runfiles library developed by @phst at https://github.com/phst/runfiles is now available as
github.com/bazelbuild/rules_go/go/runfiles
(target@io_bazel_rules_go//go/runfiles
) and is now the official way to look up runfiles from Go. It will be made compatible with Bzlmod in a future release.
Note: For improved consistency with runfiles libraries in other languages, thePath
function present in https://github.com/phst/runfiles is calledRlocation
in rules_go. - Adding two new command line flags
--@io_bazel_rules_go//go/config:gc_goopts
and--@io_bazel_rules_go//go/config:gc_linkopts
to accept additional compiler and linker flags.
What's Changed
- bzlmod: Use register_toolchains by @fmeum in #3290
- Remove unused env_execute by @kmicklas in #3276
- Correctly forward InstrumentedFilesInfo from dependencies by @fmeum in #3294
- Parse Go SDK version out of
go version
instead ofVERSION
by @fmeum in #3296 - also write test stderr to json (xml) output file by @rickystewart in #3300
- Bzlmod: Pin Bazel version in CI by @fmeum in #3301
- Allow to select Go SDK version from declared SDKs by @ash2k in #3303
- Use top level VERSION file when it exists by @linzhp in #3309
- synchronize when writing to the JSON converter by @rickystewart in #3311
- update version manifest URL by @benjaminp in #3314
- Symlink "misc" into repository for local_sdk. by @adam-azarchs in #3313
- Ensure compatibility with incompatible flags close to flipping by @fmeum in #3319
- Add additional bzlmod requirements to allow grpc protobufs to work by @shs96c in #3320
- bzlmod: Update pinned Bazel version by @fmeum in #3321
- bzlmod: Set up automated BCR releases by @fmeum in #3324
- bzlmod: Add support for gogo proto compiler by @fmeum in #3323
- gopackagesdriver: move non-Go files to OtherFiles (Fixes #3326) by @michaelarusso in #3327
- bzlmod: Allow yanked versions in CI by @fmeum in #3329
- feat(pkg-drv): allow setting custom aspect and kinds by @JamyDev in #3328
- fix(packages-driver): allow defining additional aspects instead by @JamyDev in #3330
- Add support for parsing Go development versions by @zakcutner in #3333
- Match GOARCH ppc64 to @platforms//cpu:ppc as well. by @mahiuchun in #3336
- bzlmod: Update Publish to BCR app config by @fmeum in #3337
- gopackagesdriver: default to NotHandled:true for package queries by @ian-h-chamberlain in #3338
- fix(packagesdrv): resolve third party go packages by @JamyDev in #3332
- runfiles: port phst/runfiles to rules_go by @sluongng in #3205
- Adding gc_linopts to command line flag by @linzhp in #3342
- Move new runfiles library to
//go/runfiles
by @fmeum in #3341 - Rename
Path
toRlocation
in runfiles library by @fmeum in #3346 - Add 'gc_goopts' flag to command line to allow gc_goopts to propagate by @LWarrens in #3340
New Contributors
- @kmicklas made their first contribution in #3276
- @adam-azarchs made their first contribution in #3313
- @shs96c made their first contribution in #3320
- @michaelarusso made their first contribution in #3327
- @zakcutner made their first contribution in #3333
- @mahiuchun made their first contribution in #3336
- @LWarrens made their first contribution in #3340
Full Changelog: v0.35.0...v0.36.0
WORKSPACE
code
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "io_bazel_rules_go",
sha256 = "ae013bf35bd23234d1dea46b079f1e05ba74ac0321423830119d3e787ec73483",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.36.0/rules_go-v0.36.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.36.0/rules_go-v0.36.0.zip",
],
)
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
go_rules_dependencies()
go_register_toolchains(version = "1.19.3")
v0.35.0
What's Changed
- Add platform contraints for GOAMD64 by @fmeum in #3251
- bzlmod: Fix after breaking change to go_deps.module by @fmeum in #3254
- bzlmod: Check in io_bazel_rules_go -> rules_go patch for tests by @fmeum in #3262
- Export support files needed for using Go's WebAssembly (WASM) output. by @ralimi in #3266
- Add support for --@io_bazel_rules_go//go/toolchain:sdk_version flag. by @JamesMBartlett in #3260
- Add support for
go_binary
to gopackagesdriver. by @DrewMonroe in #3271 - migrating to rbe_preconfig by @aranguyen in #3272
- Add
go_cross_binary
rule for cross-compilation. by @JamesMBartlett in #3261 - delete duplicate return by @Abirdcfly in #3267
- bzlmod: Use repo_name attribute on module instead of patches by @fmeum in #3279
- Fix non_executable_test to work with
@//
labels by @Wyverald in #3281 - bzlmod: Bump version to 0.34.0 by @fmeum in #3280
- bzlmod: Add support for
go_proto_library
by @fmeum in #3283 - Bumping minimal Bazel version to 5.1.0 by @linzhp in #3286
- Getting architecture from JRE by @linzhp in #3282
- Collect coverage for other languages by @fmeum in #3287
New Contributors
- @ralimi made their first contribution in #3266
- @JamesMBartlett made their first contribution in #3260
- @DrewMonroe made their first contribution in #3271
- @aranguyen made their first contribution in #3272
- @Abirdcfly made their first contribution in #3267
Full Changelog: v0.34.0...v0.35.0
WORKSPACE
code
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "io_bazel_rules_go",
sha256 = "099a9fb96a376ccbbb7d291ed4ecbdfd42f6bc822ab77ae6f1b5cb9e914e94fa",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.35.0/rules_go-v0.35.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.35.0/rules_go-v0.35.0.zip",
],
)
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
go_rules_dependencies()
go_register_toolchains(version = "1.19.1")