Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions utils/bazel/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,35 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

"""bzlmod configuration for llvm-project"""

module(name = "llvm-project-overlay")

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!

bazel_dep(name = "rules_android", version = "0.6.6")
bazel_dep(name = "rules_cc", version = "0.2.11")
bazel_dep(name = "rules_foreign_cc", version = "0.15.1")
bazel_dep(name = "rules_python", version = "1.6.3")
bazel_dep(name = "rules_shell", version = "0.6.1")

llvm_repos_extension = use_extension(":extensions.bzl", "llvm_repos_extension")

use_repo(
llvm_repos_extension,
"gmp",
"llvm-raw",
"llvm_zlib",
"vulkan_headers",
"vulkan_sdk",
"gmp",
"mpfr",
"llvm_zstd",
"mpc",
"mpfr",
"nanobind",
"pfm",
"llvm_zstd",
"pybind11",
"pyyaml",
"robin_map",
"nanobind",
"vulkan_headers",
"vulkan_sdk",
)

llvm_configure = use_repo_rule("@llvm-raw//utils/bazel:configure.bzl", "llvm_configure")
Expand Down
Loading
Loading