llvm / llvm/llvm-project

[Bazel][MLIR] mlir:LLVMDiaclect fails to be built by bazel due to missing headers and dependenices.

Open
#222,701 2 comments 0 reactions 0 assignees View on GitHub
bazel mlir
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

### TL;DR

I tried to build LLVMDiaclect library using bazel tools and it failed.

### Detailed Description

I'm an independent llvm developer so I have to manage my build resources for LLVM. I normally use CMake/Ninja combination as I understand it better. However, I have been recently introduced to bazel that seems to manage memory more dynamically than ninja.

Attempting to build MLIRDialect by running:
``` bazel build --config=generic_clang @llvm-project//mlir:LLVMDialect ```
I received the following error:

``` external/+_repo_rules+llvm-project/mlir/lib/Dialect/LLVMIR/IR/LLVMOps.cpp:11:10: fatal error: 'IR/LLVMOps.h' file not found ```

I managed to fix that problem by adding `lib/Dialect/LLVMIR` to include directories of this target.

That problem was fixed but the build still failed emitting this error:
``` external/+_repo_rules+llvm-project/mlir/lib/Dialect/LLVMIR/IR/LLVMOps.h:89:10: fatal error: 'mlir/Dialect/LLVMIR/LLVMAllOps.h.inc' file not found ```

I believe this cmake target `add_mlir_dialect_tablegen_target(MLIRLLVMAllOpsIncGen)`, (line 29 of `mlir/include/mlir/Dialect/LLVMIR/CMakeLists.txt`) doesn't have an equivalent in bazel. So I added the corresponding `gentble_cc_library` command. This time the build succeeded. I'll follow this issue with an immediate PR.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing `bazel build --config=generic_clang @llvm-project//mlir:LLVMDialect` and inspect the MLIR LLVM dialect sources, especially `mlir/lib/Dialect/LLVMIR/IR/LLVMOps.cpp`, `LLVMOps.h`, and `mlir/include/mlir/Dialect/LLVMIR/CMakeLists.txt`. Compare the CMake `MLIRLLVMAllOpsIncGen` target with the Bazel definition. Done means the target builds without missing-header errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp
Domain
build-system, compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.