You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 module C. A depends on C/v2 directly and C indirectly via another internal module B. C contains CGO bindings to several native functions. C/v2 contains the same CGO bindings. We created C/v2 because we needed to make breaking API changes and C was already at a stable v1.x release.
The minified dependency tree is as follows:
/-> C/v2 \
A -> nativecode_mac.a
\-> B -> C /
Notably, nativecode_mac.a is intentionally identical between C and C/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
/Users/dbourque/sdk/go1.18.3/pkg/tool/darwin_amd64/link: running clang failed: exit status 1
duplicate symbol 'C::foo::bar(unsigned long long)' in:
This seems to be an unsupported edge case at the intersection between SIV (C and C/v2 are completely separate modules) and CGO (there can only be 1 instance of C::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 use C/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:
When both C/v1 and C/v2 use go, it's possible to write them such that both versions can be used in the same project. However, it's also possible to write them such they can't both be used. I don't think there is anything that the Go tools can do to avoid this problem. Happy to hear suggestions.