| # Copyright 2024 The IREE Authors | |
| # | |
| # Licensed under the Apache License v2.0 with LLVM Exceptions. | |
| # See https://llvm.org/LICENSE.txt for license information. | |
| # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| """Bazel module configuration for IREE.""" | |
| module( | |
| name = "iree_core", | |
| version = "0.0.1", | |
| ) | |
| # Core Bazel dependencies - versions aligned with LLVM's MODULE.bazel | |
| 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 = "rules_cc", version = "0.2.11") | |
| bazel_dep(name = "rules_python", version = "1.9.0") | |
| # Python pip dependencies | |
| pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip") | |
| pip.parse( | |
| hub_name = "pip", | |
| python_version = "3.11", | |
| requirements_lock = "//build_tools/bazel:requirements.txt", | |
| ) | |
| use_repo(pip, "pip") | |
| bazel_dep(name = "rules_shell", version = "0.6.1") | |
| # Required by LLVM (for clang-fuzzer tools) | |
| bazel_dep(name = "protobuf", version = "31.1", repo_name = "com_google_protobuf") | |
| # LLVM also needs these | |
| bazel_dep(name = "libxml2", version = "2.15.3") | |
| bazel_dep(name = "rules_android", version = "0.6.6") | |
| bazel_dep(name = "rules_foreign_cc", version = "0.15.1") | |
| bazel_dep(name = "xz", version = "5.4.5.bcr.9", repo_name = "llvm_xz") | |
| bazel_dep(name = "zlib-ng", version = "2.0.7", repo_name = "llvm_zlib") | |
| bazel_dep(name = "zstd", version = "1.5.7", repo_name = "llvm_zstd") | |
| # Stack trace support on Linux. | |
| bazel_dep(name = "libbacktrace", version = "1.0.0-20250926-7939218") | |
| # LLVM project overlay module | |
| bazel_dep(name = "llvm-project-overlay", version = "main") | |
| local_path_override( | |
| module_name = "llvm-project-overlay", | |
| path = "third_party/llvm-project/utils/bazel", | |
| ) | |
| # llvm-project-overlay/llvm/config.bzl refers to @llvm//platforms/config:{gnu,musl}. | |
| # We need to teach the IREE bazel build about `@llvm`, so it can understand this | |
| # reference. The overlay declares @llvm as a dev_dependency, and we should mirror | |
| # it with the same dependency version here. | |
| bazel_dep(name = "llvm", version = "0.8.5") | |
| # Third-party dependencies that LLVM's bzlmod setup now sources from the Bazel | |
| # Central Registry as bazel_deps (previously generated by llvm_repos_extension). | |
| # IREE only references nanobind directly (//runtime/bindings/python); gmp, mpc, | |
| # mpfr, pfm and robin_map are consumed by the LLVM overlay itself, which now | |
| # declares its own bazel_deps for them. | |
| bazel_dep(name = "nanobind", version = "2.12.0.bcr.1") | |
| # Use LLVM's extension for third-party dependencies | |
| llvm_repos_ext = use_extension( | |
| "@llvm-project-overlay//:extensions.bzl", | |
| "llvm_repos_extension", | |
| ) | |
| use_repo( | |
| llvm_repos_ext, | |
| "pyyaml", | |
| # Note: vulkan_headers is provided by iree_ext with IREE's custom BUILD.overlay | |
| "vulkan_sdk", | |
| ) | |
| # IREE extension creates MLIR-adjacent source repos when IREE is root and other | |
| # IREE-specific repos unconditionally. | |
| iree_ext = use_extension("//build_tools/bazel:extensions.bzl", "iree_extension") | |
| use_repo( | |
| iree_ext, | |
| "abseil_cpp", | |
| "amdgpu_device_libs", | |
| "com_github_dvidelabs_flatcc", | |
| "com_google_benchmark", | |
| "com_google_googletest", | |
| "dawn", | |
| "dlmalloc", | |
| "hip_api_headers", | |
| "hsa_runtime_headers", | |
| "iree_amdgpu_device_toolchain", | |
| "iree_cuda", | |
| "llvm-raw", | |
| "nccl", | |
| "rccl", | |
| "spirv_cross", | |
| "spirv_headers", | |
| "spirv_tools", | |
| "stablehlo", | |
| "torch-mlir-raw", | |
| "tracy_client", | |
| "vulkan_headers", | |
| "wasi_sdk", | |
| "webgpu_headers", | |
| ) | |
| # The LLVM overlay imports @llvm-raw from its own llvm_repos_extension, which | |
| # only generates it when the overlay is the root module. IREE is the root | |
| # module here, so inject IREE's @llvm-raw (created by iree_extension) into the | |
| # overlay extension to satisfy its use_repo("llvm-raw"). | |
| inject_repo(llvm_repos_ext, "llvm-raw") | |
| # Configure LLVM using the llvm-raw repo (creates llvm-project) | |
| llvm_configure = use_repo_rule("@llvm-raw//utils/bazel:configure.bzl", "llvm_configure") | |
| llvm_configure( | |
| name = "llvm-project", | |
| targets = [ | |
| "AArch64", | |
| "AMDGPU", | |
| "ARM", | |
| "NVPTX", | |
| "RISCV", | |
| "SPIRV", | |
| "WebAssembly", | |
| "X86", | |
| ], | |
| ) | |
| # Configure torch-mlir using its upstream Bazel overlay. The configured | |
| # repository is only needed when the Torch input plugin is selected. | |
| torch_mlir_configure = use_repo_rule("@torch-mlir-raw//utils/bazel:configure.bzl", "torch_mlir_configure") | |
| torch_mlir_configure( | |
| name = "torch-mlir", | |
| src_workspace = "@torch-mlir-raw//:CMakeLists.txt", | |
| ) |