[flang-commits] [flang] [Flang] Link flangFrontendTool against MLIROpenMPDialect (PR #217448)
Kaviya Rajendiran via flang-commits
flang-commits at lists.llvm.org
Wed Aug 19 12:48:13 PDT 2026
https://github.com/kaviya2510 created https://github.com/llvm/llvm-project/pull/217448
### Issue:
Debug builds for flang failed with error:
```bash
[1/4] Linking CXX shared library lib/libflangFrontendTool.so.24.0git
FAILED: [code=1] lib/libflangFrontendTool.so.24.0git
: && /usr/bin/c++ -fPIC -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-dangling-reference -Wno-redundant-move -Wno-pessimizing-move -Wno-array-bounds -Wno-stringop-overread -Wno-dangling-pointer -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -Wno-deprecated-copy -Wno-ctad-maybe-unsupported -fno-semantic-interposition -g -DDEBUGF18 -shared -Wl,-z,defs -Wl,-z,nodelete -fuse-ld=gold -Wl,--gdb-index -Wl,--dependency-file=tools/flang/lib/FrontendTool/CMakeFiles/flangFrontendTool.dir/link.d -Wl,-soname,libflangFrontendTool.so.24.0git -o lib/libflangFrontendTool.so.24.0git tools/flang/lib/FrontendTool/CMakeFiles/flangFrontendTool.dir/ExecuteCompilerInvocation.cpp.o -Wl,-rpath,"\$ORIGIN/../lib:\$ORIGIN/../lib/aarch64-unknown-linux-gnu:/path/to/build/lib:" lib/libflangFrontend.so.24.0git lib/libflangPasses.so.24.0git lib/libclangDriver.so.24.0git lib/libMLIRPass.so.24.0git lib/libMLIRAnalysis.so.24.0git lib/libMLIRDataLayoutInterfaces.so.24.0git lib/libMLIRDialectUtils.so.24.0git lib/libMLIRInferIntDivisibilityOpInterface.so.24.0git lib/libMLIRInferStridedMetadataInterface.so.24.0git lib/libMLIRInferTypeOpInterface.so.24.0git lib/libMLIRLoopLikeInterface.so.24.0git lib/libMLIRControlFlowInterfaces.so.24.0git lib/libMLIRFunctionInterfaces.so.24.0git lib/libMLIRCallInterfaces.so.24.0git lib/libMLIRPresburger.so.24.0git lib/libMLIRSideEffectInterfaces.so.24.0git lib/libMLIRViewLikeInterface.so.24.0git lib/libMLIRInferIntRangeInterface.so.24.0git lib/libMLIRIR.so.24.0git lib/libMLIRSupport.so.24.0git lib/libLLVMPlugins.so.24.0git lib/libclangOptions.so.24.0git lib/libclangBasic.so.24.0git lib/libLLVMOption.so.24.0git lib/libLLVMSupport.so.24.0git -Wl,-rpath-link,/path/to/build/lib && :
/path/to/llvm-project/flang/include/flang/Tools/CrossToolHelpers.h:212: error: undefined reference to 'mlir::omp::IntegerWrapAroundAttr::get(mlir::MLIRContext*, bool)'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
```
#### CMake command:
```bash
cmake \
-G Ninja \
-DCMAKE_INSTALL_PREFIX=../install \
-DCMAKE_BUILD_TYPE=Debug \
-DLLVM_ENABLE_PROJECTS="clang;flang;mlir" \
-DFLANG_ENABLE_FLANG_RT=OFF \
-DLLVM_TARGETS_TO_BUILD=host \
-DBUILD_SHARED_LIBS=ON \
-DLLVM_USE_SPLIT_DWARF=ON \
-DLLVM_BUILD_TOOLS=OFF \
-DCLANG_BUILD_TOOLS=OFF \
-DFLANG_BUILD_TOOLS=OFF \
/path/to/llvm-project/llvm
```
Rootcause:
`ExecuteCompilerInvocation.cpp` includes `CrossToolHelpers.h`, which calls `mlir::omp::IntegerWrapAroundAttr::get()`. This attribute is generated by `TableGen` and defined out-of-line in `MLIROpenMPDialect`, so flangFrontendTool needs to link against it directly. This dependency was previously only satisfied transitively through flangFrontend, which worked with static libraries but broke shared library builds `-DBUILD_SHARED_LIBS=ON` since `-Wl,-z,defs` treats any unresolved symbol in a shared object as a hard error: `undefined reference to 'mlir::omp::IntegerWrapAroundAttr::get(mlir::MLIRContext*, bool)'`
Fix:
Add the missing dependency `MLIROpenMPDialect` in `flang/lib/FrontendTool/CMakeLists.txt`
Fixes the issue mentioned in [PR#214165](https://github.com/llvm/llvm-project/pull/214165#issuecomment-5323821248)
>From 81e3fda3c835d4cc290d2386d8a19317a6ee71f0 Mon Sep 17 00:00:00 2001
From: Kaviya Rajendiran <kaviyara2000 at gmail.com>
Date: Thu, 20 Aug 2026 01:08:46 +0530
Subject: [PATCH] [Flang] Link flangFrontendTool against MLIROpenMPDialect
---
flang/lib/FrontendTool/CMakeLists.txt | 1 +
1 file changed, 1 insertion(+)
diff --git a/flang/lib/FrontendTool/CMakeLists.txt b/flang/lib/FrontendTool/CMakeLists.txt
index 323d2e73e9a36..8827201339b3c 100644
--- a/flang/lib/FrontendTool/CMakeLists.txt
+++ b/flang/lib/FrontendTool/CMakeLists.txt
@@ -17,6 +17,7 @@ add_flang_library(flangFrontendTool
MLIR_LIBS
MLIRPass
+ MLIROpenMPDialect
CLANG_LIBS
clangBasic
More information about the flang-commits
mailing list