Skip to content

[mlir] Cannot build target libMLIRLLVMIRTransforms due to missing omp dependency #150959

@fabrizio-indirli

Description

@fabrizio-indirli

Hi all, in our downstream project we build the libMLIRLLVMIRTransforms target separately (e.g. with ninja libMLIRLLVMIRTransforms.a ).
After this commit (96bc07d49221dc40eb751e0759be2ccbb8a64f00), associated to this PR #147069 , we're not able to build it anymore because it fails with the error:

[1629/1745] Building CXX object tools/mlir/lib/Dial...eFiles/obj.MLIRNVVMDialect.dir/IR/NVVMDialect.cpp.o
FAILED: tools/mlir/lib/Dialect/LLVMIR/CMakeFiles/obj.MLIRNVVMDialect.dir/IR/NVVMDialect.cpp.o
/usr/bin/g++-11 -DEXPERIMENTAL_KEY_INSTRUCTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Illvm-project/build/tools/mlir/lib/Dialect/LLVMIR -Illvm-project/mlir/lib/Dialect/LLVMIR -Illvm-project/build/tools/mlir/include -Illvm-project/mlir/include -Illvm-project/build/include -Illvm-project/llvm/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Wundef -Wno-unused-but-set-parameter -Wno-deprecated-copy -O3 -DNDEBUG -std=c++17 -MD -MT tools/mlir/lib/Dialect/LLVMIR/CMakeFiles/obj.MLIRNVVMDialect.dir/IR/NVVMDialect.cpp.o -MF tools/mlir/lib/Dialect/LLVMIR/CMakeFiles/obj.MLIRNVVMDialect.dir/IR/NVVMDialect.cpp.o.d -o tools/mlir/lib/Dialect/LLVMIR/CMakeFiles/obj.MLIRNVVMDialect.dir/IR/NVVMDialect.cpp.o -c llvm-project/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp
In file included from llvm-project/llvm/include/llvm/Frontend/OpenMP/OMPConstants.h:19,
from llvm-project/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h:18,
from llvm-project/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h:28,
from llvm-project/mlir/include/mlir/Dialect/LLVMIR/NVVMDialect.h:26,
from llvm-project/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp:17:
llvm-project/llvm/include/llvm/Frontend/OpenMP/OMP.h:16:10: fatal error: llvm/Frontend/OpenMP/OMP.h.inc: No such file or directory
16 | #include "llvm/Frontend/OpenMP/OMP.h.inc"
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

We configure the build with the following CMake command:

cmake -G Ninja -S llvm -B build -DLLVM_ENABLE_PROJECTS=mlir -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_REQUIRES_RTTI=ON -DLLVM_REQUIRES_EH=ON -DLLVM_ENABLE_ASSERTIONS=0 -DLLVM_ABI_BREAKING_CHECKS=FORCE_OFF -DLLVM_ENABLE_TERMINFO=OFF -DLLVM_USE_LINKER=lld

using GCC v11.4 and CMake v3.31 on Ubuntu 24.04. This issue shows when doing a clean build in Release mode.

For reference, this quick-and-dirty fix seems to allow the target to be built:

--- a/mlir/lib/Dialect/LLVMIR/Transforms/CMakeLists.txt
+++ b/mlir/lib/Dialect/LLVMIR/Transforms/CMakeLists.txt
@@ -9,6 +9,7 @@ add_mlir_dialect_library(MLIRLLVMIRTransforms
   RequestCWrappers.cpp
 
   DEPENDS
+  omp_gen
   MLIRLLVMPassIncGen
 
   LINK_LIBS PUBLIC

although we probably shouldn't do this as MLIRLLVMIRTransforms doesn't depend directly on OpenMP headers, if I understand correctly.

I'm not sure if it is expected that mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h now includes OpenMP specific code, given that the remainder of the header seems to be mostly on LLVM IR? If so, could there be a missing dependency in some CMakeLists file?

Thank you in advance :)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions