cmd/go: "duplicate symbol" linker error when referencing v1 and v2 of the same module and that module contains CGO #53694
Labels
FrozenDueToAge
WaitingForInfo
Issue is not actionable because of missing required information, which needs to be provided.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
Output (slightly redacted to remove non-public information)What did you do?
Unfortunately, these are internal modules so I've had to obfuscate things and cannot provide a runnable example.
I'm attempting to build a module
A
that is referencing both v1 and v2 of another moduleC
.A
depends onC/v2
directly andC
indirectly via another internal moduleB
.C
contains CGO bindings to several native functions.C/v2
contains the same CGO bindings. We createdC/v2
because we needed to make breaking API changes andC
was already at a stable v1.x release.The minified dependency tree is as follows:
Notably,
nativecode_mac.a
is intentionally identical betweenC
andC/v2
.C/v2
was created due to a change in the Go API, not the underlying native code.What did you expect to see?
A successful build and a runnable binary.
What did you see instead?
Linker errors similar to this for each native function referenced in the CGO code
This seems to be an unsupported edge case at the intersection between SIV (
C
andC/v2
are completely separate modules) and CGO (there can only be 1 instance ofC::foo::bar(unsigned long long)
in the final compiled binary).We were able to upgrade past the problem internally because a newer release of
B
included updates to useC/v2
, but I'm reporting this because I believe that won't work for every project.The text was updated successfully, but these errors were encountered: