-
Notifications
You must be signed in to change notification settings - Fork 15.6k
[bazel] Add explicit dep on protobuf #168928
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this (quite large) dependency really needed here?
I see a bunch of commits reverting this PR in downstream forks like https://github.com/iree-org/llvm-project/ for https://github.com/iree-org/iree, where protobuf was not needed for building clang or other parts of LLVM (and is still not needed when building via CMake).
From a cursory scan through LLVM, I only see protobuf used in some parts of https://github.com/llvm/llvm-project/tree/main/clang-tools-extra and https://github.com/llvm/llvm-project/tree/main/clang/tools/clang-fuzzer. Would it be possible to split
utils/bazel/llvm-project-overlay/clang/BUILD.bazelso only those components take the new dependency and@llvm-project//clang:clangcan still be built without it?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At a glance, it does seem like we should be able to create clang/tools/clang-fuzzer/BUILD.bazel, and move proto_library + associated targets there. But, I recall this issue came up before, and yet the targets are still here... not sure if something prevented a move or we just didn't do it. Either way, I can take a look at doing that on Monday. Is that sufficient, or do you need changes in MODULE.bazel too?
As for the
bazel_depitself, the only way AFAIK to make something like this optional is to mark it as a dev dependency, which usually means deps only needed for running tests. A fuzzer is a bit more than a regular test, but probably not something that anyone is actually shipping in a toolchain, so maybe that's fine. @keith, would marking thisdev_dependency=Truebe a good idea? Otherwise, I'm not sure what change we could make here.Out of curiosity: what do you mean when you say it's large? Not doubting your claim, just trying to understand better. e.g. is it adding XX MiB to your build footprint or XX seconds/minutes to your build process?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving to a separate package sgtm. I would also be interested to hear where specifically this was an issue since these rules transitively depended on protobuf before, and bazel was still pulling that in. I wouldn't be surprised if because of the previously implicit nature it was less eager about fetching it though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving forward there is no way to remove this because in bazel 9.x+ these implicit loads will be required to be explicit, and being explicitly loaded means we have to have this explicit dep. Also the rules have to come from the protobuf repo itself not rules_proto (which is now deprecated instead)
it cannot be marked dev dependency because bazel consumers of the llvm repo could also need to use this tool, and at that point it would not be loadable if protobuf were a dev dependency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have metrics on hand, mostly speaking from prior experience. There were a few deps like protobuf, Abseil, and grpc that suffered from a tragedy of the commons where so many projects used them as base dependencies that they were quite large (and opinionated) relative to other deps. On IREE we build and release both compiler tools and runtime libraries in a variety of configurations ranging from python packages fit for use in datacenter applications to minimal source file sets for embedded system toolchains, so we're quite sensitive to new dependencies getting added.
I'm not as directly involved in maintaining this code these days (or the Bazel build system support in it), but here: iree-org/iree#22771. See the
MODULE.bazelfile there. Thankfully it looks like all that was needed to the changes here was this line:The IREE project has been a long time user of LLVM's Bazel build (our team contributed to its initial development in fact), but the current maintainers/users are less familiar with Bazel than they are CMake, so topics like this come up from time to time and those of us that remember where the bodies are buried (so to speak) chime in to help.
Thanks for your responses and for #170167!