<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/106918>106918</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Setting `MLIR_SRC_SHARDER_TABLEGEN` doesn't seem to work when cross compiling
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          Zentrik
      </td>
    </tr>
</table>

<pre>
    I expected this to work like `MLIR_PDLL_TABLEGEN` or `MLIR_TABLEGEN` but it doesn't. Building with `MLIR_SRC_SHARDER_TABLEGEN` set still causes a nested build to start, presumably to build `mlir-src-sharder`.
I worked around this by setting `LLVM_NATIVE_TOOL_DIR` instead or by applying the following patch

```cmake
diff --git a/llvm/cmake/modules/TableGen.cmake b/llvm/cmake/modules/TableGen.cmake
index ffcc718b4777..5a8f887ee2b4 100644
--- a/llvm/cmake/modules/TableGen.cmake
+++ b/llvm/cmake/modules/TableGen.cmake
@@ -201,7 +201,8 @@ macro(add_tablegen target project)
       STRING "Native TableGen executable. Saves building one when cross-compiling.")
   else()
     # Internal tablegen
- set(${project}_TABLEGEN "${${project}_TABLEGEN_DEFAULT}")
+ set(${project}_TABLEGEN "${${project}_TABLEGEN_DEFAULT}" CACHE
+ STRING "Native TableGen executable. Saves building one when cross-compiling.")
     set_target_properties(${target} PROPERTIES EXCLUDE_FROM_ALL ON)
   endif()
```

@chapuni is there a reason why in https://github.com/llvm/llvm-project/commit/243e8f8d23ac71717115c73725658dac071ac4c2 you chose not to do what the patch above does?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0VUuP6jgT_TVmUwI5JuSxyILnvUj0Q8C9-vRtIscpiKedOLKdpvn3Iyc03b2Y0bQ0AxEkLlfVqaqTY26tPDeIGZktyGw14p2rtMn-j40z8mVU6PKabQHfWhQOS3CVtOA0XLR5ASVf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