aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2023-06-15Merge remote-tracking branch 'aosp/upstream-master' into merge_rules_go am: ↵HEADandroid-14.0.0_r37android-14.0.0_r36android-14.0.0_r35android-14.0.0_r34android-14.0.0_r33android-14.0.0_r32android-14.0.0_r31android-14.0.0_r30android-14.0.0_r29android-14.0.0_r28mastermainandroid14-qpr2-s5-releaseandroid14-qpr2-s4-releaseandroid14-qpr2-s3-releaseandroid14-qpr2-s2-releaseandroid14-qpr2-s1-releaseandroid14-qpr2-releaseSpandan Das
49dcd02124 am: 711a453236 am: 6cf433ad1b am: de80525bba am: 96939a977e am: 780ccd3956 Original change: https://android-review.googlesource.com/c/platform/external/bazelbuild-rules_go/+/2625353 Change-Id: Id4ca3195d832eca77b29b2896b89027d847bb72d Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-06-15Merge remote-tracking branch 'aosp/upstream-master' into merge_rules_go am: ↵Spandan Das
49dcd02124 am: 711a453236 am: 6cf433ad1b am: de80525bba am: 96939a977e Original change: https://android-review.googlesource.com/c/platform/external/bazelbuild-rules_go/+/2625353 Change-Id: I32bead2047a7ae618c2688c609a950bc2055edf4 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-06-15Merge remote-tracking branch 'aosp/upstream-master' into merge_rules_go am: ↵Spandan Das
49dcd02124 am: 711a453236 am: 6cf433ad1b am: de80525bba Original change: https://android-review.googlesource.com/c/platform/external/bazelbuild-rules_go/+/2625353 Change-Id: I7004a94c375c5e52d9a4c49147ceefb8c95fed92 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-06-14Merge remote-tracking branch 'aosp/upstream-master' into merge_rules_go am: ↵Spandan Das
49dcd02124 am: 711a453236 am: 6cf433ad1b Original change: https://android-review.googlesource.com/c/platform/external/bazelbuild-rules_go/+/2625353 Change-Id: Idebe5ece264c411614cce92bcce1993eaff330b2 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-06-14Merge remote-tracking branch 'aosp/upstream-master' into merge_rules_go am: ↵Spandan Das
49dcd02124 am: 711a453236 Original change: https://android-review.googlesource.com/c/platform/external/bazelbuild-rules_go/+/2625353 Change-Id: Id7ea409a5954ab0efd0e8fe6c30ccfe507d9bf95 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-06-14Merge remote-tracking branch 'aosp/upstream-master' into merge_rules_go am: ↵platform-tools-34.0.5platform-tools-34.0.4Spandan Das
49dcd02124 Original change: https://android-review.googlesource.com/c/platform/external/bazelbuild-rules_go/+/2625353 Change-Id: I9f9788cf0500a3062862c617370cef7b915bbbc1 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-06-14Merge remote-tracking branch 'aosp/upstream-master' into merge_rules_goSpandan Das
Create two more files - LICENSE which is a symlink to LICENSE.txt - OWNERS Test: N/A Change-Id: If65c9397956c6d37c2cf65902b92f1b5c8a51dee
2023-06-07Implement //nolint parsing similar to golangci-lint (#3562)Patrick Scott
* Implement //nolint parsing similar to golangci-lint Look for nolint comments and collect the ranges of where they apply. If a node immediately follows a range with the same column, expand the range to include the node. Add tests that verify errors are filtered out. * Use a map instead of custom Linters type Inline the new report function and add some comments about nolint ranges. * Add separate tests for various filters Include a failing test that shows the column issue. Will work on a fix. * Use ast.CommentMap to associate comments to nodes This is better than the logic used by golangci-lint in that it does not incorrectly attribute an inline comment with the next line if it contains an ast.Node with a matching column (see inline_column test). * Address PR feedback Use table driven tests and `CombinedOutput`. --------- Co-authored-by: Patrick Scott <patrick.scott@observeinc.com>
2023-06-05Fix `go_download_sdk` with Bazel dev versions (#3580)Fabian Meumertzheim
The version check introduced in the previous commit did not take into account that dev versions of Bazel report an empty version string.
2023-06-02go_download_sdk: apply extraction workaround to zips on non-windows OSs (#3563)Jay Conrod
* go_download_sdk: apply extraction workaround to zips on non-windows OSs The Go distribution contains at least one test file with an invalid unicode name. Bazel cannot extract the distribution archive on some operating systems and file systems; Darwin with AFS at least is affected. For .tar.gz files, we workaround the failure in ctx.download_and_extract by using the native system tar. This PR applies a similar workaround for .zip files on non-Windows OSs. Windows itself is not affected (ctx.download_and_extract works), so the workaround is not applied there. This is only really needed when you have a Darwin host and a Windows executor (don't ask). For #2771 * use rename_files; rewrite comment * version check
2023-06-01Initial empty repositorymain-16kInna Palant
2023-06-01docs: Mention that `gazelle:prefix` can be replaced by `go.mod` (#3577)Fabian Meumertzheim
2023-05-31go_sdk extension: create `go_host_compatible_sdk` repository (#3543)Yves-Stan Le Cornec
See issue 1469 on https://github.com/bazelbuild/bazel-gazelle Co-authored-by: Fabian Meumertzheim <fabian@meumertzhe.im>
2023-05-30Test basic-gazelle example with incompatible flags (#3575)Fabian Meumertzheim
Also update the version of Gazelle used by the example to get rid of a usage of `cfg = "host"`.
2023-05-30docs: Mention `use_repo` automation (#3573)Fabian Meumertzheim
* docs: Mention `use_repo` automation * Update bzlmod.md
2023-05-25context: remove unused import (#3571)Son Luong Ngoc
This was never used.
2023-05-25Fix typo in load statement (#3570)Jason Parraga
2023-05-24gopackagesdriver: fix interface to work with golangci-lint (#3523) (#3524)Thomas Rampelberg
Unlike gopls which uses `file=` queries exclusively, golangci-lint uses the more generic `go list` query syntax. This change allow for file paths not prefixed with `file=` to be queried correctly. Additionally, some bugs have been fixed up: - Packages with different IDs and identical import paths work now. - WKT for protobufs are no longer skipped when the proto wrapper is used.` Change-Id: Ie1fc571f52cf5f6d1ff94b0aea2c05c06bb4be4e Co-authored-by: Thomas Rampelberg <thomas.rampelberg@airbnb.com>
2023-05-20Create empty `.go` file in a random location (#3566)Fabian Meumertzheim
Isolating the empty `.go` files generated for targets without sources and removing them after a build turned out not to solve issues with concurrent unsandboxed builds causing races. Instead, just generate the file in a temporary location, which for a truly empty file does not result in (non-hermetic) source file paths being included in the archive. Along the way fix a potential source of non-hermeticity in `go_bazel_test`.
2023-05-19Fix tests with `--incompatible_disable_starlark_host_transitions` (#3560)Fabian Meumertzheim
2023-05-19Remove tests for `go_path`'s `link` mode (#3565)Fabian Meumertzheim
`link` mode produces non-hermetically dangling symlinks by design, which means that it is broken with remote caching or execution and cannot be guaranteed to work in other situations. In the feature, we may be able to support it again based on `ctx.declare_symlink` and improved unresolved symlink support with remote caching and execution.
2023-05-17Fix `goexperiment.*` build tags (#3556)JB
The environment variable `GOEXPERIMENT` must be defined at the execution of the builder. Without that, the default build context `build.Default` used in the builder to filter files using build constraints will not be able to filter on a `goexperiment.x` build tag. Fixes #3555
2023-05-15Fix formatting in nogo usage doc (#3557)Son Luong Ngoc
2023-05-10stdliblist: return generated files (#3552)Thomas Rampelberg
The stdlib json currently is not populated with generated files. When CGO is being used, this means that the file list returned does not actually compile. This change adds `-compiled=true` to go list's output which results in the full set required to compile stdlib. Fixes #3523 Change-Id: Ic06243e7a5de68946d87ff9734156c522bfd8662 Co-authored-by: Thomas Rampelberg <thomas.rampelberg@airbnb.com>
2023-05-05respect global strip config (#3527)Malte Poll
2023-05-05nogo: provide usage doc (#3534)Son Luong Ngoc
* nogo: provide usage doc Explain basic usage of nogo to new user. Also provide a quick comparison between `nogo` and other popular linters such as golangci-lint * re-word and format with 'fmt 90'
2023-05-04Re-enable go_path_test on RBE (#3539)Son Luong Ngoc
Validating why this would fail on RBE
2023-05-02Move CI flags to .bazelrc and fix BwoB buildFabian Meumertzheim
This simplifies the CI config and also ensures that the recent BwoB flip in CI is disabled in all runs.
2023-04-26Create TEST_SHARD_STATUS_FILE when sharding tests (#3547)Fabian Meumertzheim
Bazel claims to check that this file has been touched when sharding tests. It currently doesn't, but that will change soon.
2023-04-21bzlmod: Add dedicated documentation (#3519)Fabian Meumertzheim
Co-authored-by: Steven E. Harris <seh@panix.com>
2023-04-19Revert "Add automatic platform detection from inbound crosstool_top and cpu ↵Fabian Meumertzheim
(#2859)" (#3468) This reverts commit 026db6df5ad760e9002f627bdb4f6b695c04d76a. Bazel is migrating to platforms and toolchains resolution, but this logic frequently reset platforms back based on the value of the legacy `--cpu` and `--crosstool_top` flags. Instead, users of rules that still rely on these flags should use the `platform_mappings` file.
2023-04-19go_tool_binary: set GOMAXPROCS to 1 (#3536)Son Luong Ngoc
On darwin, in repositories with many transitions configured such as rules_go.git, the action GoToolchainBinaryBuild could be run multiple times in parallel by Bazel. Each of these actions would execute a command like this in a sandbox: ``` $GO build -o $OUTPUT -trimpath \ go/tools/builders/ar.go \ go/tools/builders/asm.go \ go/tools/builders/builder.go \ go/tools/builders/cgo2.go \ go/tools/builders/compilepkg.go \ go/tools/builders/cover.go \ go/tools/builders/edit.go \ go/tools/builders/embedcfg.go \ go/tools/builders/env.go \ go/tools/builders/filter.go \ go/tools/builders/filter_buildid.go \ go/tools/builders/flags.go \ go/tools/builders/generate_nogo_main.go \ go/tools/builders/generate_test_main.go \ go/tools/builders/importcfg.go \ go/tools/builders/link.go \ go/tools/builders/pack.go \ go/tools/builders/read.go \ go/tools/builders/replicate.go \ go/tools/builders/stdlib.go \ go/tools/builders/stdliblist.go \ go/tools/builders/path.go ``` Then, each `go build` process would execute multiple `go tools compile` command up to the number of max Go routines it is set to. The default max number of Go routines for each `go build` process is the number of core on the machine executing the action. On a local build, this means that we could have up to n x n number of goroutines running in parallel when combining the asynchronousity of both Bazel and `go build`. After upgrading to Go 1.20.x, we observed that such parallelism could get a local MacOS machine run into a deadlock on the OS-level, halting spawn of new processes such as `git config`, or new Chrome tab browser. Typical sampling of a `go build` process stuck in deadlock would result in the following call graphs: ``` 2430 Thread_44978 DispatchQueue_1: com.apple.main-thread (serial) + 2430 ??? (in <unknown binary>) [0x1358] + 2430 runtime.asmcgocall.abi0 (in go) + 124 [0x100b702ac] + 2430 runtime.syscall6.abi0 (in go) + 56 [0x100b71a98] + 2430 __wait4_nocancel (in libsystem_kernel.dylib) + 8 [0x1a17a04f4] 2430 Thread_44999 + 2430 runtime.asmcgocall.abi0 (in go) + 201 [0x100b702f9] + 2430 runtime.pthread_cond_timedwait_relative_np_trampoline.abi0 (in go) + 28 [0x100b717ec] + 2430 _pthread_cond_wait (in libsystem_pthread.dylib) + 1276 [0x1a17d45a0] + 2430 __psynch_cvwait (in libsystem_kernel.dylib) + 8 [0x1a1797710] 2430 Thread_45038 + 2430 runtime.kevent_trampoline.abi0 (in go) + 40 [0x100b71518] + 2430 kevent (in libsystem_kernel.dylib) + 8 [0x1a179a060] ``` We could not reproduce outside of Bazel (using bash & to parallelize `go build`). We also could not reproduce this issue with Go 1.19 releases. Let's apply a rudimentry workaround by limitting the concurrency of `go build` process by setting it's max Go routines to 1. This should make this and future race conditions happen a lot less on all platforms. By doing this, we rely more on Bazel and less on Go runtime to saturate our CPU resources. This change should not affect remote execution as the default ResourceSet for each action is set at 1 CPU and 250MB RAM.
2023-04-18Fix Ubuntu CI after `--remote_download_toplevel` flip in Bazel CI (#3537)Fabian Meumertzheim
Fixes failures such as: https://buildkite.com/bazel/rules-go-golang/builds/5066#01878f4b-c637-4080-b1df-47ff2e0e5f63/276-300 caused by bazelbuild/continuous-integration#1585.
2023-04-13Add defines for assembly build (#3528)Patrick Scott
* Add defines for assembly build Fixes https://github.com/bazelbuild/rules_go/issues/1894 by adding GOOS_ GOARCH_ and GOOS_GOARCH_ defines for building assembly. * Return a copy of args * Use build.Default variables for os and arch Add a compilation test that uses another architecture with conditional inclusion of an assembly function. This mimics a real library that fails to build under rules_go. --------- Co-authored-by: Patrick Scott <patrick.scott@observeinc.com>
2023-04-13Fix macOS CI after `--remote_download_minimal` flip (#3530)Fabian Meumertzheim
This was flipped in bazelbuild/continuous-integration#1579, but breaks //tests/core/cgo:versioned_dylib_test.
2023-04-11prepare patch release 0.39.1 (#3517)Tyler French
2023-04-07Drop coverage linker flags from stdlib build (#3522)Fabian Meumertzheim
We never compile CGo with coverage instrumentation and the stdlib contains no user-provided C/C++ code, so linking coverage runtimes is never needed.
2023-04-07go/toolchains.rst: Remove reference to deprecated go_rule (#3486)Evan Jones
The definition of the go_rule function in now prints the following message: The go_rule function has been removed. Use rule directly instead. Remove reference to go_rule from the go_context documentation. Co-authored-by: Zhongpeng Lin <zplin@uber.com>
2023-04-05bzlmod: Raise Go SDK version to 1.19.8Fabian Meumertzheim
https://groups.google.com/g/golang-announce/c/Xdv6JL9ENs8
2023-04-04Pass gc_goopts to stdlib (#3518)Zhongpeng Lin
2023-04-03bzlmod: Fix repo name used by gopackagesdriver (#3516)Fabian Meumertzheim
* Reference `rulesGoRepositoryName` (sourced from environment variable) instead of hard-coding `@io_bazel_rules_go` repo name. * gopackagesdriver: Inject rules_go repo name via x_defs This ensures that we always specify the correct repo name when invoking the aspect, even with Bzlmod (where users usually refer to rules_go as `@rules_go`, not `@io_bazel_rules_go`, but could choose any apparent repository name for it). --------- Co-authored-by: Brice <33697112+bricedp@users.noreply.github.com>
2023-04-03Ignore pre-compiled stdlib only on 1.19 with experiments (#3508)Zhongpeng Lin
2023-04-02go_register_toolchains: update sdk_kinds (#3511)Son Luong Ngoc
* go_register_toolchains: update sdk_kinds After 89e3296c36b789e8623e1178a59506547a98419e, we have renamed _go_download_sdk to go_download_sdk_rule so that we could re-use the implementation inside the Bazel Module Extension setup. Update go_register_toolchains to pick up this change. * Update sdk.bzl
2023-04-02Fix use of `//go` with Bzlmod by removing dependency on `@org_golang_x_sys` ↵Brice
(#3512) * Fix use of `//go` by exposing `@org_golang_x_sys` when using Bzlmod Running `bazel run //go` (or `bazel run @rules_go//go` from another module) fails when using Bzlmod because the `@org_golang_x_sys` repository is not visible. Without Bzlmod, the repository is loaded through a WORKSPACE dependency and the error does not happen. Two-step minimal reproduction from root of this repo: 1. `touch WORKSPACE.bzlmod` 2. `bazel run --enable_bzlmod //go` Here's the error that produces: ```shell $ bazel run --enable_bzlmod //go DEBUG: gazelle@0.27.0/MODULE.bazel:7:6: WARNING: The bazel_gazelle Bazel module is still highly experimental and subject to change at any time. Only use it to try out bzlmod for now. WARNING: For repository 'com_google_protobuf', the root module requires module version protobuf@3.19.2, but got protobuf@3.19.6 in the resolved dependency graph. ERROR: /Users/brice/Documents/Code/rules_go/go/tools/go_bin_runner/BUILD.bazel:11:11: no such package '@[unknown repo 'org_golang_x_sys' requested from @]//unix': The repository '@[unknown repo 'org_golang_x_sys' requested from @]' could not be resolved: No repository visible as '@org_golang_x_sys' from main repository and referenced by '//go/tools/go_bin_runner:go_bin_runner_lib' ERROR: Analysis of target '//go:go' failed; build aborted: INFO: Elapsed time: 3.043s INFO: 0 processes. FAILED: Build did NOT complete successfully (45 packages loaded, 865 targets configured) currently loading: go/platform ERROR: Build failed. Not running target ``` Here's the point in the BUILD file where this repository is being referenced: https://github.com/bazelbuild/rules_go/blob/e558f56df9995f571e49de336c3831d407d9ff70/go/tools/go_bin_runner/BUILD.bazel#L25 * Remove `process_unix.go` and use `process.go` for all platforms. Eliminates dependency on `@org_golang_x_sys`. * Add Bzlmod test for //go --------- Co-authored-by: Fabian Meumertzheim <fabian@meumertzhe.im>
2023-03-31bzlmod: Remove `build_file_proto_mode` attribute (#3506)Fabian Meumertzheim
By updating gazelle to a version that maintains a central registry of gazelle overrides, specifying `build_file_proto_mode` on `github.com/gogo/protobuf` is no longer necessary. This will allow us to get rid of the rules_go exception after the next rules_go release.
2023-03-29Reland "Add new darwin CC toolchain for tests (#3460)" (#3502)Fabian Meumertzheim
This relands cd9817098856f6b993937c2dd794a69850cd90ea, which was reverted by commit 4660427960cde81412031f93a2c2fb9fc6fcffa2. The Xcode toolchain is now only enabled in tests.
2023-03-29Use `go_default_sdk` in `.bcr/presubmit.yml` (#3501)Fabian Meumertzheim
Context: https://github.com/bazelbuild/bazel-central-registry/pull/547
2023-03-29update README.md to reflect new version (#3500)Tyler French
2023-03-28Revert "Add new darwin CC toolchain for tests (#3460)" (#3499)Zhongpeng Lin
This reverts commit cd9817098856f6b993937c2dd794a69850cd90ea.
2023-03-28Use `ctx.readdir` instead of `ls` for SDK platform detection (#3497)Fabian Meumertzheim