j2kun/mlir-tutorial

Bazel errors on Ubuntu 22.04

llbytes opened this issue · 4 comments

Hi! Unfortunately, I'm still on the first page of this great guide. I'm trying to install this build on common systems (Ubuntu 22.04, Debian 12, FreeBSD 13.2). My actions (Ubuntu 22.04):

# apt install bazel-bootstrap bazel-skylib
# git clone https://github.com/j2kun/mlir-tutorial.git
# cd mlir-tutorial
# bazel build @llvm-project//mlir:IR

After this I get the following errors:

root@ubuntu:~/mlir-tutorial# bazel build @llvm-project//mlir:IR
INFO: Repository rules_python instantiated at:
  no stack (--record_rule_instantiation_callstack not enabled)
Repository rule new_git_repository defined at:
  /root/.cache/bazel/_bazel_root/fac3d405565bb727227c10fb24b5c557/external/bazel_tools/tools/build_defs/repo/git.bzl:182:37: in <toplevel>
ERROR: An error occurred during the fetch of repository 'rules_python':
   Traceback (most recent call last):
        File "/root/.cache/bazel/_bazel_root/fac3d405565bb727227c10fb24b5c557/external/bazel_tools/tools/build_defs/repo/git.bzl", line 169, column 13, in _new_git_repository_implementation
                fail("Exactly one of build_file and build_file_content must be provided.")
Error in fail: Exactly one of build_file and build_file_content must be provided.
ERROR: no such package '@rules_python//python': Exactly one of build_file and build_file_content must be provided.
INFO: Elapsed time: 0.056s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)

I tried to compile this tutorial on Ubuntu 22.04, Debian 12 and FreeBSD 13.2, but no luck so far. What makes debugging Bazel even more difficult is that the first step (cloning the monorepository) is quite time-consuming. Given your excellent example code, I might even find it easier to write my own CMakeLists.txt files.

Thank you for prudently indicating the commit number from which the compiler infrastructure should be built. Could you provide the version of the operating system and package versions that you use to successfully build this tutorial, as well as the commit version of the mlir-tutorial repository itself?

j2kun commented

Ah, seeing this here now.

Could you try running bazel through bazelisk? https://github.com/bazelbuild/bazelisk

For ubuntu you can find the releases here: https://github.com/bazelbuild/bazelisk/releases and manually add the binary to your path.

j2kun commented

For the record, I have used this both on Debian and Ubuntu 22.04, but the error message suggests an incompatibility with the bazel version, not the operating system.

I have run it with bazel 6.3.2.

j2kun commented

I also just pushed 822c84d which adds a version check during workspace initialization, if the bazel version is the problem then it should report a sensible error for you.

Could you try running bazel through bazelisk? https://github.com/bazelbuild/bazelisk

Thank you very much, this helped! I tested on Ubuntu 22.04 (works), Debian 12 (some build errors), FreeBSD 13.2 (bazelisk is not fully supported).

Just in case, I indicate the exact characteristics of my successful installation.

Versions:

  • Ubuntu: 22.04.3
  • bazel: 6.3.2
  • bazel-skylib: 1.0.3-1

Root:

# apt install bazel-skylib npm
# npm install -g @bazel/bazelisk

Regular user:

$ git clone https://github.com/j2kun/mlir-tutorial.git
$ cd mlir-tutorial
$ bazel build @llvm-project//mlir/...:all

The last command took about 15 minutes to run on a 16-core AMD EPYC.

~/.cache/bazel size is about 36G

Checking that everything works:

$ bazel run @llvm-project//mlir:mlir-opt -- --help
$ bazel run tools:tutorial-opt -- --help

$ cd mlir-tutorial/tests
$ bazel run @llvm-project//mlir:mlir-opt -- --convert-math-to-funcs=convert-ctlz $(pwd)/ctlz.mlir
$ bazel run @llvm-project//mlir:mlir-opt -- $(pwd)/affine_loop_unroll.mlir