<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/150986>150986</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
MLIRConfig.cmake overrides MLIR_TABLEGEN_EXE and breaks external/flang builds
</td>
</tr>
<tr>
<th>Labels</th>
<td>
flang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Acture
</td>
</tr>
</table>
<pre>
In downstream (e.g., Nix-based) builds of Flang, explicitly setting MLIR_TABLEGEN_EXE is ignored due to MLIRConfig.cmake redefining the mlir-tblgen target.
This causes build failures such as:
> ninja: error: 'include/flang/Optimizer/Dialect/CUF/Attributes/mlir-tblgen', needed by '.../CUFEnumAttr.h.inc', missing and no known rule to make it
Root cause:
TableGen.cmake expects mlir-tblgen to already be defined. But MLIRConfig overwrites the target, causing CMake to misresolve the executable.
Proposed fix:
Define a dummy imported target (mlir-tblgen and MLIR-TBLGen) early in flang/CMakeLists.txt if not already defined. This prevents accidental overwriting.
See attached PR for the patch.
Related:
• [Previous Nixpkgs PR encountering this](https://github.com/NixOS/nixpkgs/pull/391942)
• [My downstream patch discussion](https://github.com/llvm/llvm-project/issues/%E4%BD%A0%E7%9A%84%20Nixpkgs%20PR%20%E9%93%BE%E6%8E%A5)
Would appreciate feedback on whether this is an appropriate fix or if a deeper MLIR-side solution is needed.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJycVM1u4zgTfBr60oggU5ZtHXSQEysYIMkEmXz49jagxLbUE4oU-OPY-_QLSraRxQ6wwJ5EQdXsqlJ1C-eo04gly3csf1iI4Htjy6r1weKiMfJcftMgzad23qIYgPEtJl3C-D280OmuEQ4l4wU0gZR0YA5QK6G7-B1Po6KWvDqDQ-9Jd_D89O3t53u1e9o_7l9-7v_YAzmgThuLEmRA8GbC3Bt9oC5pB_GBYFHigXSs9z3CoMje-UZ1qMEL26FPWFqxtHrvyUErgkM304GDIB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