Open
Description
Hello
I am trying to write a somewhat simple MLIR dialect conversion tool that takes StableHLO as an input, replaces higher-level functions (e.g. dot product, convolution) with lower-level dialects (func, affine, math, tensor).
When I try to build, bazel is unable to find tblgen.bzl for reasons that are opaque to me as a bazel newbie. Am I doing something wrong on my end, or is there an issue in the llvm-project or stablehlo bazel configs?
Here are my bazel config files:
.bazelrc
build --action_env=BAZEL_CXXOPTS="-std=c++20"
.bazelversion
6.4.0
WORKSPACE
workspace(name = "mlir_converter")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "llvm-project",
urls = ["https://github.com/llvm/llvm-project/releases/download/llvmorg-18.1.7/llvm-project-18.1.7.src.tar.xz"],
strip_prefix = "llvm-project-18.1.7.src",
)
http_archive(
name = "stablehlo",
urls = ["https://github.com/openxla/stablehlo/archive/refs/tags/v1.0.0.tar.gz"],
strip_prefix = "stablehlo-1.0.0",
)
BUILD
package(default_visibility = ["//visibility:public"])
cc_binary(
name = "mlir_converter",
srcs = [
"src/main.cpp",
"src/Passes.cpp",
"include/Passes.h"
],
deps = [
"@llvm-project//llvm:Core",
"@llvm-project//llvm:IRReader",
"@llvm-project//llvm:Passes",
"@llvm-project//llvm:Target",
"@llvm-project//mlir:IR",
"@llvm-project//mlir:Pass",
"@llvm-project//mlir:Transforms",
"@llvm-project//mlir:Dialect",
"@llvm-project//mlir:Parser",
"@llvm-project//mlir:Support",
"@llvm-project//mlir:FuncDialect",
"@llvm-project//mlir:ArithDialect",
"@llvm-project//mlir:TensorDialect",
"@llvm-project//mlir:AffineDialect",
"@llvm-project//mlir:MathDialect",
"@stablehlo//:stablehlo_ops",
],
copts = [
"-std=c++17",
"-Iexternal/llvm-project/llvm/include",
"-Iexternal/llvm-project/mlir/include",
"-Iexternal/stablehlo/include",
],
)
MODULE.bazel
module(name = "mlir_converter")
bazel_dep(name = "rules_cc", version = "0.0.9")
bazel_dep(name = "rules_python", version = "0.33.1")
bazel build
output
$ bazel clean --expunge && bazel build //:mlir_converter
INFO: Starting clean (this may take a while). Consider using --async if the clean takes more than several minutes.
Starting local Bazel server and connecting to it...
DEBUG: Rule 'stablehlo' indicated that a canonical reproducible form can be obtained by modifying arguments integrity = "sha256-x5pcfw8eyM123HNpbO3d9qV3UXynBZ7pRpBUlCBIpGI="
DEBUG: Repository stablehlo instantiated at:
/home/ubuntu/stablehlo_lowering/WORKSPACE:11:13: in <toplevel>
Repository rule http_archive defined at:
/home/ubuntu/.cache/bazel/_bazel_ubuntu/bddf858a9ede0b8e5917960702c4f3df/external/bazel_tools/tools/build_defs/repo/http.bzl:382:31: in <toplevel>
DEBUG: Rule 'llvm-project' indicated that a canonical reproducible form can be obtained by modifying arguments integrity = "sha256-dERqtpQ/aGORlUy9oNd66S6KYMQy7/Q3uGZuEh10jsQ="
DEBUG: Repository llvm-project instantiated at:
/home/ubuntu/stablehlo_lowering/WORKSPACE:5:13: in <toplevel>
Repository rule http_archive defined at:
/home/ubuntu/.cache/bazel/_bazel_ubuntu/bddf858a9ede0b8e5917960702c4f3df/external/bazel_tools/tools/build_defs/repo/http.bzl:382:31: in <toplevel>
ERROR: error loading package '@@stablehlo//': Every .bzl file must have a corresponding package, but '@@llvm-project//mlir:tblgen.bzl' does not have one. Please create a BUILD file in the same or any parent directory. Note that this BUILD file does not need to do anything except exist.
ERROR: /home/ubuntu/stablehlo_lowering/BUILD:3:10: error loading package '@@stablehlo//': Every .bzl file must have a corresponding package, but '@@llvm-project//mlir:tblgen.bzl' does not have one. Please create a BUILD file in the same or any parent directory. Note that this BUILD file does not need to do anything except exist. and referenced by '//:mlir_converter'
ERROR: Analysis of target '//:mlir_converter' failed; build aborted: Analysis failed
INFO: Elapsed time: 41.021s, Critical Path: 0.08s
INFO: 1 process: 1 internal.
ERROR: Build did NOT complete successfully