-
-
Notifications
You must be signed in to change notification settings - Fork 662
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make C++ toolchain optional #3390
Make C++ toolchain optional #3390
Conversation
Can you also include a test to confirm we don't regress on this? Thanks! |
@illicitonion Is it possible that you based your commit on a rather old version of |
5da15de
to
264ad0c
Compare
a7cf9e9
to
982ada2
Compare
@illicitonion This should be unblocked as soon as Bazel 6.1 is the minimum supported version of rules_go: bazelbuild/bazel@ac47e10 |
Amazing, thanks! |
Bazel 6.1 has been released. Any chance this PR could be merged? |
We still support Bazel 5.4.0 though. @illicitonion Would you be interested in picking this up again and using |
Sure, happy to pick this up again! It looks like |
@illicitonion There isn't and adding a second step would be a breaking change. How about adding this feature for Bzlmod only? Then we can look into whether we can support WORKSPACE as a follow-up. |
0232f96
to
09c9158
Compare
@fmeum I think we're good to go on this, PTAL! (Sorry for the horrors of the fake |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, only a few stylistic comments
59e4347
to
f36882b
Compare
@linzhp Could you test this? |
f36882b
to
f08151c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested these changes at Uber and everything passes
Currently, if you transition a go_binary, you must have a C++ toolchain for it even if it's building in pure mode without cgo. By making this toolchain optional, we push the error from a toolchain-resolution-time error to an analysis-time error only if a toolchain is both _needed_ and not found.
Also switch from @bazel_tools//tools/cpp:current_cc_toolchain to @bazel_tools//tools/cpp:optional_current_cc_toolchain because otherwise we still get a hard error if the toolchain can't be found.
f08151c
to
ae43602
Compare
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [io_bazel_rules_go](https://togithub.com/bazelbuild/rules_go) | http_archive | patch | `v0.44.1` -> `v0.44.2` | --- ### Release Notes <details> <summary>bazelbuild/rules_go (io_bazel_rules_go)</summary> ### [`v0.44.2`](https://togithub.com/bazelbuild/rules_go/releases/tag/v0.44.2) [Compare Source](https://togithub.com/bazelbuild/rules_go/compare/v0.44.1...v0.44.2) #### `WORKSPACE` code load("@​bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( name = "io_bazel_rules_go", sha256 = "7c76d6236b28ff695aa28cf35f95de317a9472fd1fb14ac797c9bf684f09b37c", urls = [ "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.44.2/rules_go-v0.44.2.zip", "https://github.com/bazelbuild/rules_go/releases/download/v0.44.2/rules_go-v0.44.2.zip", ], ) load("@​io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") go_rules_dependencies() go_register_toolchains(version = "1.21.5") #### What's Changed - Make C++ toolchain optional by [@​illicitonion](https://togithub.com/illicitonion) in [https://github.com/bazelbuild/rules_go/pull/3390](https://togithub.com/bazelbuild/rules_go/pull/3390) - Fix a race detected only if a test times out by [@​patrickmscott](https://togithub.com/patrickmscott) in [https://github.com/bazelbuild/rules_go/pull/3808](https://togithub.com/bazelbuild/rules_go/pull/3808) - registering timeout handler synchronously by [@​linzhp](https://togithub.com/linzhp) in [https://github.com/bazelbuild/rules_go/pull/3810](https://togithub.com/bazelbuild/rules_go/pull/3810) - patch release 0.44.2 by [@​tyler-french](https://togithub.com/tyler-french) in [https://github.com/bazelbuild/rules_go/pull/3811](https://togithub.com/bazelbuild/rules_go/pull/3811) **Full Changelog**: bazel-contrib/rules_go@v0.44.1...v0.44.2 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://togithub.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://togithub.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi4xMDAuMCIsInVwZGF0ZWRJblZlciI6IjM2LjEwMC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> Co-authored-by: Self-hosted Renovate Bot <361546+cgrindel-self-hosted-renovate[bot]@users.noreply.github.enterprise.com>
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [io_bazel_rules_go](https://togithub.com/bazelbuild/rules_go) | http_archive | patch | `v0.44.1` -> `v0.44.2` | --- > [!WARNING] > Some dependencies could not be looked up. Check the Dependency Dashboard for more information. --- ### Release Notes <details> <summary>bazelbuild/rules_go (io_bazel_rules_go)</summary> ### [`v0.44.2`](https://togithub.com/bazelbuild/rules_go/releases/tag/v0.44.2) [Compare Source](https://togithub.com/bazelbuild/rules_go/compare/v0.44.1...v0.44.2) #### `WORKSPACE` code load("@​bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( name = "io_bazel_rules_go", sha256 = "7c76d6236b28ff695aa28cf35f95de317a9472fd1fb14ac797c9bf684f09b37c", urls = [ "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.44.2/rules_go-v0.44.2.zip", "https://github.com/bazelbuild/rules_go/releases/download/v0.44.2/rules_go-v0.44.2.zip", ], ) load("@​io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") go_rules_dependencies() go_register_toolchains(version = "1.21.5") #### What's Changed - Make C++ toolchain optional by [@​illicitonion](https://togithub.com/illicitonion) in [https://github.com/bazelbuild/rules_go/pull/3390](https://togithub.com/bazelbuild/rules_go/pull/3390) - Fix a race detected only if a test times out by [@​patrickmscott](https://togithub.com/patrickmscott) in [https://github.com/bazelbuild/rules_go/pull/3808](https://togithub.com/bazelbuild/rules_go/pull/3808) - registering timeout handler synchronously by [@​linzhp](https://togithub.com/linzhp) in [https://github.com/bazelbuild/rules_go/pull/3810](https://togithub.com/bazelbuild/rules_go/pull/3810) - patch release 0.44.2 by [@​tyler-french](https://togithub.com/tyler-french) in [https://github.com/bazelbuild/rules_go/pull/3811](https://togithub.com/bazelbuild/rules_go/pull/3811) **Full Changelog**: bazel-contrib/rules_go@v0.44.1...v0.44.2 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/ride-app/driver-service). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xMDMuMSIsInVwZGF0ZWRJblZlciI6IjM3LjEwMy4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [io_bazel_rules_go](https://togithub.com/bazelbuild/rules_go) | http_archive | patch | `v0.44.1` -> `v0.44.2` | --- > [!WARNING] > Some dependencies could not be looked up. Check the Dependency Dashboard for more information. --- ### Release Notes <details> <summary>bazelbuild/rules_go (io_bazel_rules_go)</summary> ### [`v0.44.2`](https://togithub.com/bazelbuild/rules_go/releases/tag/v0.44.2) [Compare Source](https://togithub.com/bazelbuild/rules_go/compare/v0.44.1...v0.44.2) #### `WORKSPACE` code load("@​bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( name = "io_bazel_rules_go", sha256 = "7c76d6236b28ff695aa28cf35f95de317a9472fd1fb14ac797c9bf684f09b37c", urls = [ "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.44.2/rules_go-v0.44.2.zip", "https://github.com/bazelbuild/rules_go/releases/download/v0.44.2/rules_go-v0.44.2.zip", ], ) load("@​io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") go_rules_dependencies() go_register_toolchains(version = "1.21.5") #### What's Changed - Make C++ toolchain optional by [@​illicitonion](https://togithub.com/illicitonion) in [https://github.com/bazelbuild/rules_go/pull/3390](https://togithub.com/bazelbuild/rules_go/pull/3390) - Fix a race detected only if a test times out by [@​patrickmscott](https://togithub.com/patrickmscott) in [https://github.com/bazelbuild/rules_go/pull/3808](https://togithub.com/bazelbuild/rules_go/pull/3808) - registering timeout handler synchronously by [@​linzhp](https://togithub.com/linzhp) in [https://github.com/bazelbuild/rules_go/pull/3810](https://togithub.com/bazelbuild/rules_go/pull/3810) - patch release 0.44.2 by [@​tyler-french](https://togithub.com/tyler-french) in [https://github.com/bazelbuild/rules_go/pull/3811](https://togithub.com/bazelbuild/rules_go/pull/3811) **Full Changelog**: bazel-contrib/rules_go@v0.44.1...v0.44.2 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/kreempuff/rules_unreal_engine). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xMDMuMSIsInVwZGF0ZWRJblZlciI6IjM3LjEwMy4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [io_bazel_rules_go](https://togithub.com/bazelbuild/rules_go) | http_archive | patch | `v0.44.1` -> `v0.44.2` | --- ### Release Notes <details> <summary>bazelbuild/rules_go (io_bazel_rules_go)</summary> ### [`v0.44.2`](https://togithub.com/bazelbuild/rules_go/releases/tag/v0.44.2) [Compare Source](https://togithub.com/bazelbuild/rules_go/compare/v0.44.1...v0.44.2) #### `WORKSPACE` code load("@​bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( name = "io_bazel_rules_go", sha256 = "7c76d6236b28ff695aa28cf35f95de317a9472fd1fb14ac797c9bf684f09b37c", urls = [ "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.44.2/rules_go-v0.44.2.zip", "https://github.com/bazelbuild/rules_go/releases/download/v0.44.2/rules_go-v0.44.2.zip", ], ) load("@​io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") go_rules_dependencies() go_register_toolchains(version = "1.21.5") #### What's Changed - Make C++ toolchain optional by [@​illicitonion](https://togithub.com/illicitonion) in [https://github.com/bazelbuild/rules_go/pull/3390](https://togithub.com/bazelbuild/rules_go/pull/3390) - Fix a race detected only if a test times out by [@​patrickmscott](https://togithub.com/patrickmscott) in [https://github.com/bazelbuild/rules_go/pull/3808](https://togithub.com/bazelbuild/rules_go/pull/3808) - registering timeout handler synchronously by [@​linzhp](https://togithub.com/linzhp) in [https://github.com/bazelbuild/rules_go/pull/3810](https://togithub.com/bazelbuild/rules_go/pull/3810) - patch release 0.44.2 by [@​tyler-french](https://togithub.com/tyler-french) in [https://github.com/bazelbuild/rules_go/pull/3811](https://togithub.com/bazelbuild/rules_go/pull/3811) **Full Changelog**: bazel-contrib/rules_go@v0.44.1...v0.44.2 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://togithub.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://togithub.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi4xMDAuMCIsInVwZGF0ZWRJblZlciI6IjM2LjEwMC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> Co-authored-by: Self-hosted Renovate Bot <361546+cgrindel-self-hosted-renovate[bot]@users.noreply.github.enterprise.com>
What type of PR is this?
Bug fix
What does this PR do? Why is it needed?
Currently, if you transition a go_binary, you must have a C++ toolchain
for it even if it's building in pure mode without cgo.
By making this toolchain optional, we push the error from a
toolchain-resolution-time error to an analysis-time error only if a
toolchain is both needed and not found.
This showed up in testing bazel-contrib/bazel-lib#289