Skip to content

[flang][mlir] MLIRConfig.cmake overrides MLIR_TABLEGEN_EXE and breaks external/flang builds #150986

@Acture

Description

@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.
As shown in #150987

See attached PR for the patch.

Related:
Previous Nixpkgs PR encountering this
My downstream patch discussion

Would appreciate feedback on whether this is an appropriate fix or if a deeper MLIR-side solution is needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    build-problemflangFlang issues not falling into any other category

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions