<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/95996>95996</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
my project's bazel build with llvm-project and stablehlo as dependencies fails to find tblgen.bzl
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
johnmatter
</td>
</tr>
</table>
<pre>
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
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWF9z2roS_zTOyw4eWyb8eeABktBmTtu0aXNPb18Y2V5jtbLkSjIJ_fR3VnbBUJImnTvn6TAM2NL--61W0u5ya8VaIc6C80VwfnnGG1dqM_uqS1Vx59CcpTrfzl6jlDqILoNo3v5eA6_Ama1Qa3Aa7o1wCBysrvC-5A6sqGqJ8PbN9S3kgkvMHGRabdBYoRU4rSU4InT8G1r46Hgq8fWbG-AWuAKh6sYF7AIM1pJnaKEU6xLNQOIGJRSNypzQykLAJhiuQ8i1g9rovMk8G6nSsiGagE3hXrgSpL7fCehM8vwkjHh4UQiF9FRxV9K_Q2W1Cdg0hD72v0tUcE3oCXraCJkTdcp_oARhoVEEhuYKoXJwqVyjCtMfEgptwCC3ZLlHzw2Crvn3xpNX6OF3khTepwJDmFdwDbkmT5N7XUlP90arNWgF1RZQef3akHJXokHvQmsbBKFoBKTcVIPa6K-0DtqA9f4upe50ZVoVYm2DZNkH-tqLMkhK-nRQCIk2SOZ94oAl7RdCT2uybnwUdV__6t0FgwH3C7hCtQmSy8X8y9Wb1cXnzzfvP30MksuAsYF1eZBcZgFbBGzBooCxk_JOK-_i7CTHKByG0bNk_X1z-9fH9_OLq5PU99p8szXPMGATxSuEILmEgLFKCrNqY92hIbvZtC9fap4HbEITw8hbu6LtYAO2DNjy56P30yrHgl4M1jpI5qVzNcWRl3lBumhkxU1Wig3-qulwdtIOAgD0ze2HRiu4o2uMtC3R-aJT5dfcm7kWrmzSMNNVwJYkovvbS1oalMgtkv25vlctbE-kzXoQT8I4HB9xdaOhNVnouAkffpBF55d7o6wzol7VBgvxcAp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