[*] Example of an actual link error, just to provide a flavor:
/build/tmp/_bazel_bazel/436badd4919a15958fa3800a4e21074a/external/local_config_cc/extra_tools/envoy_cc_wrapper -o bazel-out/k8-opt/bin/test/extensions/quic_listeners/quiche/dummy_test -pthread -pthread '-fuse-ld=gold' -Wl,-no-as-needed -Wl,-z,relro,-z,now -pass-exit-codes -Wl,--gc-sections -Wl,@bazel-out/k8-opt/bin/test/extensions/quic_listeners/quiche/dummy_test-2.params)
Execution platform: @bazel_tools//platforms:host_platform
/usr/bin/ld.gold: error: bazel-out/k8-opt/bin/source/common/common/_objs/assert_lib/assert.o: multiple definition of 'Envoy::Assert::ActionRegistrationImpl::debug_assertion_failure_record_action_'
/usr/bin/ld.gold: bazel-out/k8-opt/bin/external/envoy/source/common/common/_objs/assert_lib/assert.o: previous definition here
The problem here seems to be that the main workspace duplicates source code from the external workspace (in this case, envoy's assert.cc is duplicated in the main workspace). If I've understood correctly, you should be able to avoid this by removing assert.cc from your workspace and depending on @envoy//source/common/common:assert_lib.
I don't think that either of the approaches you referenced would help, since Bazel wouldn't know that the two copies of assert.cc define the same static variable.
Thanks! I should have been a little clearer--there aren't two copies of assert.cc. The main project is "envoy", and a library in the external dependency is attempting to depend *back* on something in envoy, via a BUILD rule (in the external dependency) that has deps = ["@envoy//source/common/common:assert_lib"]. I readily admit this is a weird setup--without getting into details, it's to work around idiosyncracies in a 3rd-party library that currently expects some of its source files to come from the codebase that embeds it.
Maybe the answer is "that isn't supported" or "I'm doing it wrong", but first I wanted to check if there are known ways to get this to work.
--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/7579d792-bce1-4daf-805e-e4a9d7ce5c22%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/e377043e-5405-460a-ba78-322f35745e77%40googlegroups.com.