Skip to content

Conversation

@keith
Copy link
Member

@keith keith commented Nov 20, 2025

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
@llvmbot llvmbot added the bazel "Peripheral" support tier build system: utils/bazel label Nov 20, 2025
@rupprecht
Copy link
Collaborator

I picked this because it is the current version being used by bazel 8.0.0

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.

@keith
Copy link
Member Author

keith commented Nov 20, 2025

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

@keith keith merged commit 930066f into llvm:main Nov 20, 2025
14 of 23 checks passed
@keith keith deleted the ks/bazel-add-explicit-dep-on-protobuf branch November 20, 2025 19:20
@keith
Copy link
Member Author

keith commented Nov 20, 2025

#168933

@rupprecht
Copy link
Collaborator

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.

lialan added a commit to iree-org/llvm-project that referenced this pull request Nov 21, 2025
lialan added a commit to iree-org/llvm-project that referenced this pull request Nov 23, 2025
yzhang93 added a commit to iree-org/llvm-project that referenced this pull request Nov 24, 2025
yzhang93 added a commit to iree-org/llvm-project that referenced this pull request Nov 24, 2025
yzhang93 added a commit to iree-org/llvm-project that referenced this pull request Nov 24, 2025
yzhang93 added a commit to iree-org/llvm-project that referenced this pull request Nov 24, 2025
yzhang93 added a commit to iree-org/iree that referenced this pull request Nov 25, 2025
- 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]>
yzhang93 added a commit to iree-org/llvm-project that referenced this pull request Nov 25, 2025
yzhang93 added a commit to iree-org/iree that referenced this pull request Nov 25, 2025
bangtianliu pushed a commit to bangtianliu/iree that referenced this pull request Nov 25, 2025
- 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]>
bangtianliu pushed a commit to bangtianliu/iree that referenced this pull request Nov 25, 2025
yzhang93 added a commit to iree-org/llvm-project that referenced this pull request Nov 25, 2025
yzhang93 added a commit to iree-org/iree that referenced this pull request Nov 26, 2025
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]>
aadeshps-mcw pushed a commit to aadeshps-mcw/llvm-project that referenced this pull request Nov 26, 2025
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
Priyanshu3820 pushed a commit to Priyanshu3820/llvm-project that referenced this pull request Nov 26, 2025
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
lialan pushed a commit to iree-org/llvm-project that referenced this pull request Nov 26, 2025
lialan added a commit to iree-org/iree that referenced this pull request Nov 26, 2025
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")
Copy link
Member

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?

Copy link
Collaborator

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?

Copy link
Member Author

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.

Copy link
Member Author

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

Copy link
Member

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!

pstarkcdpr pushed a commit to pstarkcdpr/iree that referenced this pull request Nov 28, 2025
- 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]>
rupprecht added a commit that referenced this pull request Dec 1, 2025
This avoids needing to pull in protobuf deps for clang-fuzzer when that
is not needed.

Recently requested: #168928

Previously requested: #123126 / #123833
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bazel "Peripheral" support tier build system: utils/bazel

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants