You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
P1I'll work on this now. (Assignee required)platform: appletype: bugz-team-AppleDeprecated. Send to rules_apple, or label team-Rules-CPP + platform:apple
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.
diff --git a/go/private/rules/cgo.bzl b/go/private/rules/cgo.bzl
index 631facc..9c34200 100644
--- a/go/private/rules/cgo.bzl
+++ b/go/private/rules/cgo.bzl
@@ -207,6 +207,8 @@ def _cgo_codegen_impl(ctx):
have_cc = len(source.cxx) + len(source.objc) + len(ctx.attr.deps) > 0
if not have_cc:
linkopts = [o for o in linkopts if o not in ("-lstdc++", "-lc++")]
+ else:
+ linkopts.append("-lc++")
tool_args.add_all(["-objdir", out_dir])
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 -lc++ to all link actions.
Adding Go's linking action to the link_libc++ feature would get the darwin toolchain back to where it was. I am not super familiar with the go rules, is there a c++-link-* equivalent for go (go-link-executable etc.)?
I don't fully understand @trybka's comment, but that may also be another way forward.
@katre@mhlopko I released a change yesterday in rules_go which gathers flags from cc_common instead of CcToolchainInfo. I believe we are no longer accessing the deprecated fields of CcToolchainInfo. I built Bazel at 19a401c and ran the rules_go tests at 0.16.0, 0.15.5, and 0.14.3 (the newly released versions) on macOS. Everything passes.
Hopefully, it should be safe to roll this change forward.
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.
@jayconrod After testing the rollfoward, I see this error:
Information about the C++ toolchain API is not accessible anymore through ctx.fragments.cpp (see --incompatible_disable_legacy_cpp_toolchain_skylark_api on http://docs.bazel.build/versions/master/skylark/backward-compatibility.html#disable-legacy-c-configuration-api for migration notes). Use CcToolchainInfo instead.
P1I'll work on this now. (Assignee required)platform: appletype: bugz-team-AppleDeprecated. Send to rules_apple, or label team-Rules-CPP + platform:apple
Activity
katre commentedon Oct 1, 2018
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).
aragos commentedon Oct 1, 2018
From a colleague who took a look:
jayconrod commentedon Oct 1, 2018
I reproduced this and poked around a bit. I can confirm what @aragos said: the only flags I'm getting from
mostly_static_link_optionsare:trybka commentedon Oct 1, 2018
mostly_static_link_optionsfall into the legacy CROSSTOOL fields, I think:https://docs.bazel.build/versions/master/skylark/backward-compatibility.html#disable-legacy-c-toolchain-api
There are potentially other link flags that are missing at this point?
tburgin commentedon Oct 1, 2018
Looks like we may need to add another action here: https://github.com/bazelbuild/bazel/blob/master/tools/osx/crosstool/CROSSTOOL.tpl#L174-L178
tburgin commentedon Oct 1, 2018
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.
tburgin commentedon Oct 1, 2018
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.
jayconrod commentedon Oct 1, 2018
@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.
tburgin commentedon Oct 1, 2018
Gotcha, I am really only familiar with darwin ;) The darwin toolchain prior to 19a401c was unconditionally adding
-lc++to all link actions.Adding Go's linking action to the
link_libc++feature would get the darwin toolchain back to where it was. I am not super familiar with the go rules, is there ac++-link-*equivalent for go (go-link-executableetc.)?I don't fully understand @trybka's comment, but that may also be another way forward.
21 remaining items
Automated rollback of commit 19a401c.
Automated rollback of commit 19a401c.
hlopko commentedon Oct 6, 2018
Thanks John!
Automated rollback of commit 19a401c.
Automated rollback of commit 19a401c.
jayconrod commentedon Oct 17, 2018
@katre @mhlopko I released a change yesterday in rules_go which gathers flags from
cc_commoninstead ofCcToolchainInfo. I believe we are no longer accessing the deprecated fields ofCcToolchainInfo. I built Bazel at19a401cand ran the rules_go tests at0.16.0,0.15.5, and0.14.3(the newly released versions) on macOS. Everything passes.Hopefully, it should be safe to roll this change forward.
hlopko commentedon Oct 18, 2018
Awesome! thanks!
katre commentedon Oct 18, 2018
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.
katre commentedon Oct 18, 2018
Actually, wait, I was thinking of a different change in rules_go. :)
I will roll this forward with tests regardless.
macos_bundle: Make "apple_product_type.kernel_extension" produce a va…
katre commentedon Oct 18, 2018
@jayconrod After testing the rollfoward, I see this error:
(From https://buildkite.com/bazel/bazel-with-downstream-projects-bazel/builds/514#916b75fd-9952-47dc-b399-b4f89dad8799).
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:
Automated rollback of commit 19a401c.
Automated rollback of commit 19a401c.
Automated rollback of commit 19a401c.
macos_bundle: Make "apple_product_type.kernel_extension" produce a va…