[llvm] [MLIR] Fix the MLIR build by properly adding external directory- (PR #222749)
Erich Keane via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 10 11:57:18 PDT 2026
https://github.com/erichkeane created https://github.com/llvm/llvm-project/pull/222749
I don't know where we broke this, but it seems this is is necessary when doing -DLLVM_OPTIMIZED_TABLEGEN=true. I copied this off the clang-tablegen, and it fixes my local problem, which was
[1881/7447] Building native mlir-tblgen...
ninja: error: unknown target 'mlir-tblgen', did you mean 'llvm-tblgen'?
>From 9d0c330d1941020dc58f9cc10d26b717f8bc69ab Mon Sep 17 00:00:00 2001
From: erichkeane <ekeane at nvidia.com>
Date: Thu, 10 Sep 2026 11:54:58 -0700
Subject: [PATCH] [MLIR] Fix the MLIR build by properly adding external
directory-
I don't know where we broke this, but it seems this is is necessary when
doing -DLLVM_OPTIMIZED_TABLEGEN=true. I copied this off the
clang-tablegen, and it fixes my local problem, which was
[1881/7447] Building native mlir-tblgen...
ninja: error: unknown target 'mlir-tblgen', did you mean 'llvm-tblgen'?
---
llvm/cmake/modules/CrossCompile.cmake | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/llvm/cmake/modules/CrossCompile.cmake b/llvm/cmake/modules/CrossCompile.cmake
index dc222610dd81b..2332e941edda4 100644
--- a/llvm/cmake/modules/CrossCompile.cmake
+++ b/llvm/cmake/modules/CrossCompile.cmake
@@ -42,6 +42,12 @@ function(llvm_create_cross_target project_name target_name toolchain buildtype)
if (LLVM_USE_LINKER AND NOT CMAKE_CROSSCOMPILING)
set(linker_flag "-DLLVM_USE_LINKER=${LLVM_USE_LINKER}")
endif()
+ if (LLVM_EXTERNAL_MLIR_SOURCE_DIR AND LLVM_TOOL_MLIR_BUILD)
+ # Propagate MLIR source dir and enable flag so that mlir-tblgen can be built
+ set(external_mlir_dir
+ "-DLLVM_EXTERNAL_MLIR_SOURCE_DIR=${LLVM_EXTERNAL_MLIR_SOURCE_DIR}"
+ "-DLLVM_TOOL_MLIR_BUILD=TRUE")
+ endif()
if (LLVM_EXTERNAL_CLANG_SOURCE_DIR)
# Propagate LLVM_EXTERNAL_CLANG_SOURCE_DIR so that clang-tblgen can be built
set(external_clang_dir "-DLLVM_EXTERNAL_CLANG_SOURCE_DIR=${LLVM_EXTERNAL_CLANG_SOURCE_DIR}")
@@ -111,6 +117,7 @@ function(llvm_create_cross_target project_name target_name toolchain buildtype)
-DLLVM_TABLEGEN_FLAGS="${llvm_tablegen_flags}"
${python_executable_flag}
${build_type_flags} ${linker_flag} ${external_clang_dir}
+ ${external_mlir_dir}
${ARGN}
WORKING_DIRECTORY ${${project_name}_${target_name}_BUILD}
DEPENDS CREATE_${project_name}_${target_name}
More information about the llvm-commits
mailing list