I did some debugging on this, and it seems like the go linker is not passing the libicu objects to the external linker. I.e., when I add these two arguments to the linker command above, linking succeeds: "bazel-out/k8-fastbuild/bin/external/icu4c/libicu-base.a", "bazel-out/k8-fastbuild/bin/external/icu4c/libicudata.a" (and these are present when using Go 1.22).
Thanks for the root cause analysis! I followed up on https://github.com/golang/go/issues/66456 as this is a breaking change coming from upstream. I'll wait for recommendations from the Go team on how to handle this.
What version of rules_go are you using?
v0.48.0
What version of gazelle are you using?
v0.37.0
What version of Bazel are you using?
7.2.0
Does this issue reproduce with the latest releases of all the above?
Probably
What operating system and processor architecture are you using?
linux amd64
Any other potentially useful information about your toolchain?
This issue occurs when linking packages that use CGO w/ >= Go 1.23rc1.
What did you do?
main.go:
BUILD.bazel:
When using Go version 1.23rc1, run
bazel build :cgotest
What did you expect to see?
Pass.
What did you see instead?
I did some debugging on this, and it seems like the go linker is not passing the libicu objects to the external linker. I.e., when I add these two arguments to the linker command above, linking succeeds:
"bazel-out/k8-fastbuild/bin/external/icu4c/libicu-base.a", "bazel-out/k8-fastbuild/bin/external/icu4c/libicudata.a"
(and these are present when using Go 1.22).I believe this is because of https://go-review.googlesource.com/c/go/+/584655, which changes the cgo command to accept linker flags via command-line arg rather than env variable, while rules_go is still passing them as environment variables.