Conversation
The dependency is relied on by Bazel macro definitions that Envoy publishes (namely envoy_cc_benchmark_test). With the flag set, a repository that consumes Envoy as a submodule can't use the macro: attempting to build a target defined with it produces an error Signed-off-by: Alex Bakon <abakon@netflix.com>
phlax
left a comment
There was a problem hiding this comment.
no real objection to this - but wonder if its something that would be better placed in downstream mods
fwiw - i pondered similar wrt the llvm toolchain - this is something that is not generally exposed as a non-build dep - in our case we kinda support a specific toolchain so i made some effort to workaround that
in the case of test deps im more inclined to think its something that downstreams should add if they wish to test it
|
ah - ok - just saw mention of macro - perhaps we could fix the macro to take a label - we have done that several other places for this purpose |
|
Note that while invoking the macro in my code is sufficient to demonstrate the issue, it isn't necessary. I'm also seeing similar errors when trying to run Envoy benchmarks from within my project: bazel run -c opt @envoy//test/common/stats:recent_lookups_benchmark
...
ERROR: no such package '@@[unknown repo 'benchmark' requested from @@envoy+]//': The repository '@@[unknown repo 'benchmark' requested from @@envoy+]' could not be resolved: No repository visible as '@benchmark' from repository '@@envoy+'
ERROR: /home/coder/.cache/bazel/_bazel_abakon/355d0dec2e3175fe6c76e1aadc5e2c98/external/envoy+/test/common/stats/BUILD:95:26: no such package '@@[unknown repo 'benchmark' requested from @@envoy+]//': The repository '@@[unknown repo 'benchmark' requested from @@envoy+]' could not be resolved: No repository visible as '@benchmark' from repository '@@envoy+' and referenced by '@@envoy+//test/common/stats:recent_lookups_benchmark'
ERROR: Analysis of target '@@envoy+//test/common/stats:recent_lookups_benchmark' failed; build aborted: Analysis failedI realized after writing the PR description that there was another error line (I omitted it because it looked duplicative): FWIW, the macro invocation in my repo looks like this - it sets envoy_cc_benchmark_binary(
name = "<benchmark_name>",
srcs = ["<benchmark_name>.cc"],
repository = "@envoy",
deps = [ ... ],
)The macro itself produces a rule that references an Envoy target, which I would expect to be able to see the |
|
setting there is a pattern that can make this work i think involving im ooo rn - but will follow up as soon as i get chance |
|
Sounds good, I'm happy for this to get done the Right Way. I'd be happy to test any patches against my project if that's helpful. |
|
cool, thanks I have a PR here #47556 that should fix this properly (switches the macros to If you're up for testing it that would be amazing. Note: in the end I made it so the macro doesn't inject the
im wondering whether we can make |
|
i remembered why |
|
Yep, that worked for me, and it looks like it's merged. Thanks! |
Commit Message:
envoy_cc_benchmark_binary produces targets that link //test/benchmark:main, which depends on the
@benchmark(google_benchmark) rule. This macro is part of Envoy's public Bazel build API and is used by downstream repositories that consume Envoy as a bzlmod dependency (e.g. a git submodule) rather than as the build's root module.Under bzlmod, a bazel_dep declared with dev_dependency=True is dropped from the dependency graph whenever the declaring module is not the root module of the current build. So any downstream repo building an envoy_cc_benchmark_binary target fails:
Dropping dev_dependency lets
@benchmarkresolve regardless of which module is root, matching how the macro is actually consumed.Additional Description:
I found this when attempting to define my own benchmark targets in a project that consumes Envoy as a submodule.
Risk Level: low
Testing: built targets in consuming project
Docs Changes: n/a
Release Notes: n/a
Platform Specific Features: n/a