Issue 150986
Summary MLIRConfig.cmake overrides MLIR_TABLEGEN_EXE and breaks external/flang builds
Labels flang
Assignees
Reporter Acture
    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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to