[Mlir-commits] [mlir] [MLIR][Python] Extend bindings for external projects without duplication (PR #173241)
Maksim Levental
llvmlistbot at llvm.org
Tue Dec 23 09:14:32 PST 2025
makslevental wrote:
> I use a custom `CAPI` function to register the `SDist` dialects.
I understand that I'm saying that you're lucky your custom function doesn't require global state (it mutates context instead). I pointed you to a function that does require global state (the pass registry) and thus you would be in a state where the globals in `SDistPythonCAPI` and `MLIRPythonCAPI` are distinct and differ (with different registered passes in this case). There is lots of other global state around in MLIR/LLVM (the `llvm::cl::opt`s being the most visible such case).
> Here is the tree for `venv/lib/python3.11/site-packages/mlir_sdist`
Okay now I understand you're trying to dedup the other dialect extensions and the `_mlir` (and the associated Python code). I understand why you'd want to do this (prevent always rebuilding those) and when I first started MLIR work that's what I wanted too. But it's just not possible with all the global state floating around. In fact you're going to have an even harder time after I land https://github.com/llvm/llvm-project/pull/171775 which introduces another library that's shared amongst all the extensions.
https://github.com/llvm/llvm-project/pull/173241
More information about the Mlir-commits
mailing list