-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[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
Conversation
This is required for correctly loading the protobuf rules. It's possible we could drop the version here to a lower version, as long as that version supports the versions of bazel we support. I picked this because it is the current version being used by bazel 8.0.0 (which is defined in the .bazelversion). Users can override this in their project anyways if they need an older one
Any reason not to bump it to the latest stable version (8.4.2)? I have no problem w/ using this version though. We can bump this and the bazel version itself separately. |
|
should be totally safe, I can submit a PR to do that but i want to land this one first because it will also touch the MODULE.bazel.lock. it would be reasonably safe to gitignore this file if we wanted to, the value it provides being checked in for this repo is probably minimal and it will be a bit annoying as it drifts if folks don't realize they should check in their diffs |
Allegedly, the lockfile format is designed to minimize merge conflicts. But if it becomes a regular problem, sure. |
This reverts commit 930066f.
This reverts commit 930066f.
This reverts commit 930066f.
This reverts commit 930066f.
This reverts commit 930066f.
This reverts commit 930066f.
- Still carrying revert from last week llvm/llvm-project#162930 - New reverts of llvm/llvm-project#168933 and llvm/llvm-project#168928 because of bazel build failure. There are some discussions on discord https://discord.com/channels/689900678990135345/1080178290188374049/1442537425086709772. --------- Signed-off-by: yzhang93 <[email protected]>
This reverts commit 930066f.
- Still carrying revert from last week llvm/llvm-project#162930. - Reverts related to bazel build: - llvm/llvm-project#169450 - llvm/llvm-project#169146 - llvm/llvm-project#168933 - llvm/llvm-project#168928 Signed-off-by: yzhang93 <[email protected]>
- Still carrying revert from last week llvm/llvm-project#162930 - New reverts of llvm/llvm-project#168933 and llvm/llvm-project#168928 because of bazel build failure. There are some discussions on discord https://discord.com/channels/689900678990135345/1080178290188374049/1442537425086709772. --------- Signed-off-by: yzhang93 <[email protected]>
- Still carrying revert from last week llvm/llvm-project#162930. - Reverts related to bazel build: - llvm/llvm-project#169450 - llvm/llvm-project#169146 - llvm/llvm-project#168933 - llvm/llvm-project#168928 Signed-off-by: yzhang93 <[email protected]>
This reverts commit 930066f.
Carrying reverts related to bazel build: - llvm/llvm-project#169450 - llvm/llvm-project#169146 - llvm/llvm-project#168933 - llvm/llvm-project#168928 Drop SLSR [revert](iree-org/llvm-project@e1cb8b4) in iree that is currently reverted in upstream. Signed-off-by: yzhang93 <[email protected]>
This is required for correctly loading the protobuf rules. It's possible we could drop the version here to a lower version, as long as that version supports the versions of bazel we support. I picked this because it is the current version being used by bazel 8.0.0 (which is defined in the .bazelversion). Users can override this in their project anyways if they need an older one
This is required for correctly loading the protobuf rules. It's possible we could drop the version here to a lower version, as long as that version supports the versions of bazel we support. I picked this because it is the current version being used by bazel 8.0.0 (which is defined in the .bazelversion). Users can override this in their project anyways if they need an older one
This reverts commit 930066f.
Carrying reverts related to bazel build: - llvm/llvm-project#169450 - llvm/llvm-project#169146 - llvm/llvm-project#168933 - llvm/llvm-project#168928
| bazel_dep(name = "apple_support", version = "1.24.1", repo_name = "build_bazel_apple_support") | ||
| bazel_dep(name = "bazel_skylib", version = "1.8.2") | ||
| bazel_dep(name = "platforms", version = "1.0.0") | ||
| bazel_dep(name = "protobuf", version = "31.1", repo_name = "com_google_protobuf") |
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.bazel so only those components take the new dependency and @llvm-project//clang:clang can 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_dep itself, 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 this dev_dependency=True be 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.
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?
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.
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.
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.bazel file there. Thankfully it looks like all that was needed to the changes here was this line:
# Required by LLVM (for clang-fuzzer tools)
bazel_dep(name = "protobuf", version = "31.1", repo_name = "com_google_protobuf")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!
- Still carrying revert from last week llvm/llvm-project#162930 - New reverts of llvm/llvm-project#168933 and llvm/llvm-project#168928 because of bazel build failure. There are some discussions on discord https://discord.com/channels/689900678990135345/1080178290188374049/1442537425086709772. --------- Signed-off-by: yzhang93 <[email protected]>
This is required for correctly loading the protobuf rules. It's
possible we could drop the version here to a lower version, as long as
that version supports the versions of bazel we support. I picked this
because it is the current version being used by bazel 8.0.0 (which is
defined in the .bazelversion). Users can override this in their project
anyways if they need an older one