[flang-commits] [flang] [flang] [mlir] Avoid clobbering mlir-tblgen target by defining dummy imported targets (PR #150987)

via flang-commits flang-commits at lists.llvm.org
Tue Aug 5 19:54:38 PDT 2025


Acture wrote:

> Can you describe how do you set up flang downstream? We have couple of downstream projects and I have never seen any issue regarding `mlir-tblgen`. Are you building flang as standalone or within the mono repo? 

I’m trying to build Flang as a standalone project within a Nix sandbox, rather than from the full LLVM monorepo.
In this setup, I encountered an issue with mlir-tblgen: although I explicitly set MLIR_TABLEGEN_EXE to the path of the binary produced by a prior Nix build of tablegen, the definition appears to be overridden during CMake configuration.

>From what I can tell, the CMake logic within Flang (or its MLIR dependencies) treats mlir-tblgen as a build target rather than an imported executable. This causes the system to ignore the externally provided binary and instead expect mlir-tblgen to be built as part of the current project. While this works in monorepo-based downstreams, it breaks in sandboxed or decoupled setups like Nix, where dependencies must be pre-built and explicitly declared.

A previous nix PR also ran into a similar issue when trying to externalize tablegen executables—it seems this behavior is somewhat hardcoded and not easy to override cleanly.

https://github.com/llvm/llvm-project/pull/150987


More information about the flang-commits mailing list