[Mlir-commits] [mlir] [mlir] Use add_tablegen() for mlir-src-sharder to fix aarch64 cross-compile (PR #196202)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Wed May 6 15:50:39 PDT 2026


https://github.com/diksha created https://github.com/llvm/llvm-project/pull/196202

## Summary
`add_tablegen()` already sets `MLIR_SRC_SHARDER_TABLEGEN_EXE` to the native host-tool path during cross-compilation (via `build_native_tool`). The leftover manual `set(MLIR_SRC_SHARDER_TABLEGEN_EXE mlir-src-sharder PARENT_SCOPE)` clobbered that path with the bare binary name, causing aarch64 cross-builds to fail with:

```
/bin/sh: 1: mlir-src-sharder: not found
```

when sharding `TestOps`. Switching `mlir-src-sharder` from `add_llvm_executable` to `add_tablegen` (and dropping the redundant `set(... PARENT_SCOPE)`) lets the existing cross-compile machinery point consumers at the host build of the tool.

## Test plan
- [ ] aarch64 cross-build of MLIR succeeds (TestOps sharding step finds the host `mlir-src-sharder`)
- [ ] Native x86_64 build still produces and uses `mlir-src-sharder` correctly

>From 0db60983236f67506dba6a7fc2455a893356a289 Mon Sep 17 00:00:00 2001
From: Diksha Gohlyan <dgohlyan at nvidia.com>
Date: Wed, 6 May 2026 15:31:21 -0700
Subject: [PATCH] [mlir] Use add_tablegen() for mlir-src-sharder to fix aarch64
 cross-compile

add_tablegen() already sets MLIR_SRC_SHARDER_TABLEGEN_EXE to the native
host-tool path during cross-compilation (via build_native_tool). The
leftover manual `set(... mlir-src-sharder PARENT_SCOPE)` clobbered that
path with the bare binary name, causing aarch64 cross-builds to fail
with `/bin/sh: 1: mlir-src-sharder: not found` when sharding TestOps.
---
 mlir/tools/mlir-src-sharder/CMakeLists.txt | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/mlir/tools/mlir-src-sharder/CMakeLists.txt b/mlir/tools/mlir-src-sharder/CMakeLists.txt
index ba78dad1c87b5..bc4a11bd4c0cb 100644
--- a/mlir/tools/mlir-src-sharder/CMakeLists.txt
+++ b/mlir/tools/mlir-src-sharder/CMakeLists.txt
@@ -1,11 +1,10 @@
 set(LLVM_LINK_COMPONENTS Support)
 set(LIBS MLIRSupport)
 
-add_llvm_executable(mlir-src-sharder mlir-src-sharder.cpp)
+add_tablegen(mlir-src-sharder MLIR_SRC_SHARDER
+  mlir-src-sharder.cpp)
 
 set_target_properties(mlir-src-sharder PROPERTIES FOLDER "MLIR/Tablegenning")
 target_link_libraries(mlir-src-sharder PRIVATE ${LIBS})
 
-set(MLIR_SRC_SHARDER_TABLEGEN_EXE mlir-src-sharder PARENT_SCOPE)
-
 mlir_check_all_link_libraries(mlir-src-sharder)



More information about the Mlir-commits mailing list