TL;DR: we believe this is due to multiple versions of the same package being included in the build. Only one will actually get linked, which means that a dependent library may be compiled against one version and linked against another.
The main way to work around this is to ensure there are no duplicate libraries unless they use importmap attribute to ensure unique names.
It’d be nice if cmd/link could detect this scenario somehow and issue an appropriate warning, rather than panicking, which will continue to lead to new issues being filed here. I’m not sure how or if that is possible, but reopening this issue for that. Since you understand the issue, do you by chance have a minimal reproduction?
It may be difficult for cmd/link to detect this without a change in the package format. Each .a file produced by the compiler would need to be stamped with a unique id, and it would need to include the ids of the other .a files it was compiled against. The linker would need to verify these ids.
It's the responsibility of the build system (go build or Bazel rules_go in this case) to prevent this situation from happening, so while adding verification to cmd/link would be valuable, I'm not sure it justifies the additional complexity.
go build prevents this from happening by passing -importmap or -importcfg to the compiler for vendored packages, which I think is the only case where this would come up.
rules_go should prevent this from happening by verifying that no two libraries passed to the linker have the same import path. At the moment, rules_go requires you to set importmap attributes on go_library rules manually if you need duplicate packages. That could be automated with Gazelle though.
What version of Go are you using (
Does this issue reproduce with the latest release?
What operating system and processor architecture are you using (
Ubuntu 17.10 linux_amd64
What did you do?
I'm compiling my project with bazel by just running
bazel build node/agent/unsullied.
The code is too complicated. I'm working to make a minimum example.
What did you expect to see?
bazel build succeed.
What did you see instead?
At the last step, GoLink crashed.
The text was updated successfully, but these errors were encountered: