Building the following example:
go_library(
name = "go_default_library",
srcs = [
"src.go",
],
cgo = True,
importpath = "github.com/myproject",
visibility = ["//visibility:public"],
)
go_binary(
name = "mybin",
visibility = ["//visibility:public"],
deps = [
":go_default_library",
],
pure = "off",
)
If cgo = True, then stdlib is built twice:
pure = True)I am failing to see where that info gets lost, as manually adding pure attributes to all cgo rules doesn't fix it somehow.
The issues seems to be that _cgo_codegen_impl depends on go.stdlib.libs.
Somehow the mode is not propagated, even though go.mode in _cgo_codegen_impl is correct.
The weirdest thing is that removing the dependency to go.stdlib.libs doesn't break anything and fixes the issue. Not why though (perhaps CGoCodeGen doesn't need it after all?)
Did you start seeing this before or after #1595? There was an issue earlier with mode flags like pure = True not propagating. Now, the cgo macro declares rules for every possible mode that would affect build times.
I'm planning to rewrite the cgo functionality at some point to avoid the need to declare extra rules. There are a few other projects I need to complete first though.
Not sure, I'll try to find some time to try it.
If you are to rewrite the CGo rules, perhaps it's better to wait for 0.17 or 0.18 when starlark rules can return cc providers and make use of https://docs.bazel.build/versions/master/skylark/lib/cc_common.html, WDYT ?
Yeah, I'd definitely like to use that functionality as soon as it's available. I'm not sure exactly when it's available in Bazel. I expect 0.17. In any case though, I'm probably not going to have bandwidth to work on it for a few weeks.
Most helpful comment
Yeah, I'd definitely like to use that functionality as soon as it's available. I'm not sure exactly when it's available in Bazel. I expect 0.17. In any case though, I'm probably not going to have bandwidth to work on it for a few weeks.