-
Notifications
You must be signed in to change notification settings - Fork 633
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
cgo: declare rules for each supported mode, select in aspect #1595
Conversation
go_binary and go_test allow developers to set mode attributes that affect build tags, such as goos, goarch, race, and msan. These attributes are propagated with an aspected over "deps" and "embed" edges. Each rule the aspect visits must return a GoLibrary provider. Unfortunately, our cgo implementation declares cc_library, objc_library, and cc_binary rules that depend on sources generated by _cgo_codegen. _cgo_codegen performs source filtering using build tags. The native rules can't depend on a platform-specific GoSource provider created by the aspect. This change introduces separate _cgo_codegen and cc_library rules for each platform. A new rule, _cgo_select_embed produces GoLibrary and GoSource providers. The resolve function called by the aspect can produce a GoSource for alternate platforms. This change increases load and analysis time by about 15% (measured by building tests/integration/popular_repos, cold starting Bazel but with a warm disk cache). However, this is necessary to build golang.org/x/sys/unix in alternate modes. Fixes bazelbuild#1592
@ianthehat PTAL. I think this is the only way to do this without being able to perform C/C++/ObjC compile / link actions inside |
Note that bazel master is now exposing the |
@steeve We get I'm not sure if they've exposed a way to create C/C++ compile / link actions. That would be really useful because we wouldn't need to use |
I meant being able to generate |
Since this commit: bazelbuild/bazel@95a40be |
Running this commit rebased on master didn't appear to solve the In my case we're invoking the protoc rules, have a copy of sys in vendor, and using -race during bazel test. (in case that context helps at all) |
go_binary and go_test allow developers to set mode attributes that affect build tags, such as goos, goarch, race, and msan. These attributes are propagated with an aspected over "deps" and "embed" edges. Each rule the aspect visits must return a GoLibrary provider. Unfortunately, our cgo implementation declares cc_library, objc_library, and cc_binary rules that depend on sources generated by _cgo_codegen. _cgo_codegen performs source filtering using build tags. The native rules can't depend on a platform-specific GoSource provider created by the aspect. This change introduces separate _cgo_codegen and cc_library rules for each platform. A new rule, _cgo_select_embed produces GoLibrary and GoSource providers. The resolve function called by the aspect can produce a GoSource for alternate platforms. This change increases load and analysis time by about 15% (measured by building tests/integration/popular_repos, cold starting Bazel but with a warm disk cache). However, this is necessary to build golang.org/x/sys/unix in alternate modes. Fixes #1592
go_binary and go_test allow developers to set mode attributes that
affect build tags, such as goos, goarch, race, and msan. These
attributes are propagated with an aspected over "deps" and "embed"
edges. Each rule the aspect visits must return a GoLibrary provider.
Unfortunately, our cgo implementation declares cc_library,
objc_library, and cc_binary rules that depend on sources generated by
_cgo_codegen. _cgo_codegen performs source filtering using build
tags. The native rules can't depend on a platform-specific GoSource
provider created by the aspect.
This change introduces separate _cgo_codegen and cc_library rules for
each platform. A new rule, _cgo_select_embed produces GoLibrary and
GoSource providers. The resolve function called by the aspect can
produce a GoSource for alternate platforms.
This change increases load and analysis time by about 15% (measured by
building tests/integration/popular_repos, cold starting Bazel but with
a warm disk cache). However, this is necessary to build
golang.org/x/sys/unix in alternate modes.
Fixes #1592