-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Change in macOS CROSSTOOL breaks rules_go #6283
Comments
CC @jayconrod for rules_go. This looks to be bazel-internal, but please let me know if you have any ideas. Specifically, I'd like to know if this is a release blocker for 0.19.0 (#6116). |
From a colleague who took a look:
|
I reproduced this and poked around a bit. I can confirm what @aragos said: the only flags I'm getting from
|
There are potentially other link flags that are missing at this point? |
Looks like we may need to add another action here: https://github.com/bazelbuild/bazel/blob/master/tools/osx/crosstool/CROSSTOOL.tpl#L174-L178 |
Actually there is already special handling for the c++ linking flags in the go_rules. The rules know if there is c++ source, adding the linker flag here seems like a good fit.
The failing tests passes with this patch. Running all go_rules tests now. |
Running on macOS all tests pass with the ^^ patch. One downside to changing the go rules is all platforms are effected and should be thoroughly tested. |
@tburgin I'm not sure rules_go can figure that out in general. The C++ standard library name varies by toolchain, and there are even multiple implementations that can be used with the same compiler. It would be better for that flag to come from the toolchain. I'm not entirely comfortable with the code above because I don't have a full list of C++ library names. We needed that hack though for Go programs that run in containers where libstdc++.so isn't available. |
Gotcha, I am really only familiar with darwin ;) The darwin toolchain prior to 19a401c was unconditionally adding I don't fully understand @trybka's comment, but that may also be another way forward. |
@tburgin I'm unfortunately not that familiar with CROSSTOOL and features therein. The Go linker logic is primarily within https://github.com/bazelbuild/rules_go/blob/master/go/private/actions/link.bzl. Go linking happens in two stages: internal linking (with the Go linker) and external linker (with the system linker, typically whatever Not sure if that helps. rules_go is still using |
Yeah, makes sense. I will take a look tomorrow. |
This issue manifested with rules_go, but wouldn't any set of rules that tries to use the linker from a CC toolchain run into something similar? We need to make sure this is solved for all Starlark C++ API users, not just for rules_go. |
@katre Only rules that do not align with these actions: https://github.com/bazelbuild/bazel/blob/master/tools/osx/crosstool/CROSSTOOL.tpl#L174-L178 |
I see, thanks for clarifying. |
Hi all, @trybka is right, go rules are using legacy Skylark API to the C++ toolchain that doesn't get flags from To whom it helps, changes to the internal go rules for this happened in cl/210533647 and cl/213225869. I'll gladly help, just let me know. Last commit to the API that is relevant here was released in Bazel 0.17.1 (b9c7269) so you should be able to use the complete API with current Bazel. |
@katre I'd prefer the fix on the go rules side, and if not viable, rolling back 19a401c is the only option. Legacy Skylark C++ API didn't change, and that it doesn't get the flags from |
I agree that having rules_go upgrade to the latest API is good, but if we go that route, rules_go will need to complete that and release it before we can release 0.19.0, or else their users will be unable to build on macOS. Can we fix this on the Bazel side to give rules_go and their users a grace period to make this transition smoother? |
Sure, by rolling back 19a401c. Let me create a rollback. |
@jayconrod If we can roll this back for 0.19.0, can rules_go be updated to the latest C++ api by the time we cut 0.20.0? |
Is there any kind of existing infrastructure that would have detected this breakage in a timely manner, ideally before the change is even submitted? If so, are there docs on how to set it up? If not, can resources be added to such an effort? It seems like we keep hitting similar issues again and again because there is not enough testing coverage for the multitude of scenarios where changes can break, wasting too many engineering hours. I would expect a post mortem from the Bazel team after this is resolved (or at least a retrospective), because the current integration testing situation is frankly untenable for rule maintainers. |
The CI system tests downstream projects with the latest bazel built from HEAD nightly: https://buildkite.com/bazel/bazel-with-downstream-projects-bazel It looks like rules_go has been red on this for at least 5 days (I can't see history further back). However, as you can see, a lot of projects are red. I know the Green Team (@buchgr is sheriff this week) is working to stabilize the system. |
Yup, green team was supposed to catch this in O(days), but with rules_go it took us (well, not even us, it was John who investigated the failure) 11 days. This is not acceptable and we'll make sure it doesn't happen again. |
Awesome! Look into bazelbuild/rules_swift@88ac6c3#diff-1394f96b7e9b2b96f5e8eff729be2e55 for backwards compatible implementation. Feel free to hardcode action names (you cannot load skylark files conditionally). |
*** Reason for rollback *** Breaks external go_rules (#6283) *** Original change description *** macos_bundle: Make "apple_product_type.kernel_extension" produce a valid kext. PiperOrigin-RevId: 215447343
Last night's test of rules_go is clean (https://buildkite.com/bazel/bazel-with-downstream-projects-bazel/builds/475#b0c7777f-2466-489a-b8f6-1937a2e61b03), so I am closing this and will cherrypick 20bfdc6 into #6116. |
*** Reason for rollback *** Breaks external go_rules (#6283) *** Original change description *** macos_bundle: Make "apple_product_type.kernel_extension" produce a valid kext. PiperOrigin-RevId: 215447343
*** Reason for rollback *** Breaks external go_rules (#6283) *** Original change description *** macos_bundle: Make "apple_product_type.kernel_extension" produce a valid kext. PiperOrigin-RevId: 215447343
*** Reason for rollback *** Breaks external go_rules (#6283) *** Original change description *** macos_bundle: Make "apple_product_type.kernel_extension" produce a valid kext. PiperOrigin-RevId: 215447343
Thanks John! |
*** Reason for rollback *** Breaks external go_rules (#6283) *** Original change description *** macos_bundle: Make "apple_product_type.kernel_extension" produce a valid kext. PiperOrigin-RevId: 215447343
*** Reason for rollback *** Breaks external go_rules (#6283) *** Original change description *** macos_bundle: Make "apple_product_type.kernel_extension" produce a valid kext. PiperOrigin-RevId: 215447343
@katre @mhlopko I released a change yesterday in rules_go which gathers flags from Hopefully, it should be safe to roll this change forward. |
Awesome! thanks! |
I think we still need to make sure downstream projects of rules_go update before I can roll forward the change. I'll take care of coordinating and testing that, I have a list of projects available. |
Actually, wait, I was thinking of a different change in rules_go. :) I will roll this forward with tests regardless. |
…lid kext. This is the rollback of commit 20bfdc6, which in turn rolled back the original commit 19a401c. This was originally rolled back because breaks external go_rules (#6283) This is now safe as rules_go has been updated and released. PiperOrigin-RevId: 217694011 Change-Id: Ib452a98dc0a0882aa15ec9608d13e54f2bd83c28
@jayconrod After testing the rollfoward, I see this error:
Does this mean we do need to update projects to use the latest rules_go release before this CL goes in? Affected projects in Bazel CI:
|
*** Reason for rollback *** Breaks external go_rules (#6283) *** Original change description *** macos_bundle: Make "apple_product_type.kernel_extension" produce a valid kext. PiperOrigin-RevId: 215447343
*** Reason for rollback *** Breaks external go_rules (#6283) *** Original change description *** macos_bundle: Make "apple_product_type.kernel_extension" produce a valid kext. PiperOrigin-RevId: 215447343
*** Reason for rollback *** Breaks external go_rules (#6283) *** Original change description *** macos_bundle: Make "apple_product_type.kernel_extension" produce a valid kext. PiperOrigin-RevId: 215447343
…lid kext. This is the rollback of commit 20bfdc6, which in turn rolled back the original commit 19a401c. This was originally rolled back because breaks external go_rules (bazelbuild#6283) This is now safe as rules_go has been updated and released. PiperOrigin-RevId: 217694011 Change-Id: Ib452a98dc0a0882aa15ec9608d13e54f2bd83c28
…lid kext. This is the rollback of commit 20bfdc6, which in turn rolled back the original commit 19a401c. This was originally rolled back because breaks external go_rules (#6283) This is now safe as rules_go has been updated and released. Full downstream test run: https://buildkite.com/bazel/bazel-with-downstream-projects-bazel/builds/551 PiperOrigin-RevId: 219678937
The commit 19a401c has caused an error during the build for rules_go. Logs are available here: https://buildkite.com/bazel/bazel-with-downstream-projects-bazel/builds/472#f9e3ac01-fa0a-4903-b10d-09a2f5550c88
Commit 19a401c was identified by bisecting the Bazel source.
The text was updated successfully, but these errors were encountered: