<feed xmlns='http://www.w3.org/2005/Atom'>
<title>llvm-project.git/mlir/cmake/modules/AddMLIRPython.cmake, branch users/zyin/fix-pybind11-findpackage</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.
</subtitle>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/'/>
<entry>
<title>Adding find_package for pybind</title>
<updated>2025-08-14T14:00:22+00:00</updated>
<author>
<name>jerryyin</name>
<email>zhuoryin@amd.com</email>
</author>
<published>2025-08-14T14:00:22+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=2c4bde6e4ef310c87907983d468445ea1bd055f5'/>
<id>2c4bde6e4ef310c87907983d468445ea1bd055f5</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>[mlir][py] Don't use a CMake iteration to find nanobind target to suppress warnings (NFC) (#143863)</title>
<updated>2025-06-23T13:54:39+00:00</updated>
<author>
<name>Jacques Pienaar</name>
<email>jpienaar@google.com</email>
</author>
<published>2025-06-23T13:54:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=cd91d0fff9293a904704784c92c28637bfebef45'/>
<id>cd91d0fff9293a904704784c92c28637bfebef45</id>
<content type='text'>
Following approach suggested by @hpkfft.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Following approach suggested by @hpkfft.</pre>
</div>
</content>
</entry>
<entry>
<title>[MLIR] Fix nanobind linker args on macOS (#125733)</title>
<updated>2025-02-05T19:49:11+00:00</updated>
<author>
<name>Nikhil Kalra</name>
<email>nkalra@apple.com</email>
</author>
<published>2025-02-05T19:49:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=113534d12e9b2faa46607e27a115ec3ba22cd0fc'/>
<id>113534d12e9b2faa46607e27a115ec3ba22cd0fc</id>
<content type='text'>
Set the "-U,_PyClassMethod_New" linker flag on the Python library itself
isntead of on the CMAKE_MODULE_LINKER_FLAGS property.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Set the "-U,_PyClassMethod_New" linker flag on the Python library itself
isntead of on the CMAKE_MODULE_LINKER_FLAGS property.</pre>
</div>
</content>
</entry>
<entry>
<title>[mlir][python][cmake] Allow skipping nanobind compile options changes. (#123997)</title>
<updated>2025-01-23T17:18:12+00:00</updated>
<author>
<name>Scott Todd</name>
<email>scott.todd0@gmail.com</email>
</author>
<published>2025-01-23T17:18:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=1a8f49fdda5b14ccc894aacee653f19130df3a30'/>
<id>1a8f49fdda5b14ccc894aacee653f19130df3a30</id>
<content type='text'>
Context:
https://github.com/llvm/llvm-project/pull/107103#discussion_r1925834532

This code is brittle, especially when called from a superproject that
adds the `nanobind-*` target in a different source directory:
```cmake
get_property(all_targets DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY BUILDSYSTEM_TARGETS)
```

The changes here do help with my downstream build, but I'm not sure if
using the `MLIR_DISABLE_CONFIGURE_PYTHON_DEV_PACKAGES` option introduced
in https://github.com/llvm/llvm-project/pull/117934 is the right fix
given that the option is currently scoped directly to one location with
a matching name:
https://github.com/llvm/llvm-project/blob/7ad8a3da4771ce8abbd146611124104d42a4e63e/mlir/cmake/modules/MLIRDetectPythonEnv.cmake#L4-L5

Some other solutions to consider:

1. Search through an explicit list of target names using `if (TARGET)`
2. Iterate over _all_ targets in the project, not just the targets in
the current directory, using code like
https://stackoverflow.com/a/62311397
3. Iterate over targets in the directory known to MLIR
(`llvm-project/mlir/python`)
4. Move this `target_compile_options` setup into
`mlir_configure_python_dev_packages` (I started on this, but that runs
into similar issues where the target is defined in a different
directory)</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Context:
https://github.com/llvm/llvm-project/pull/107103#discussion_r1925834532

This code is brittle, especially when called from a superproject that
adds the `nanobind-*` target in a different source directory:
```cmake
get_property(all_targets DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY BUILDSYSTEM_TARGETS)
```

The changes here do help with my downstream build, but I'm not sure if
using the `MLIR_DISABLE_CONFIGURE_PYTHON_DEV_PACKAGES` option introduced
in https://github.com/llvm/llvm-project/pull/117934 is the right fix
given that the option is currently scoped directly to one location with
a matching name:
https://github.com/llvm/llvm-project/blob/7ad8a3da4771ce8abbd146611124104d42a4e63e/mlir/cmake/modules/MLIRDetectPythonEnv.cmake#L4-L5

Some other solutions to consider:

1. Search through an explicit list of target names using `if (TARGET)`
2. Iterate over _all_ targets in the project, not just the targets in
the current directory, using code like
https://stackoverflow.com/a/62311397
3. Iterate over targets in the directory known to MLIR
(`llvm-project/mlir/python`)
4. Move this `target_compile_options` setup into
`mlir_configure_python_dev_packages` (I started on this, but that runs
into similar issues where the target is defined in a different
directory)</pre>
</div>
</content>
</entry>
<entry>
<title>[mlir][python][cmake] Remove unsupported argument from AddMLIRPython. (#123858)</title>
<updated>2025-01-22T04:28:33+00:00</updated>
<author>
<name>Scott Todd</name>
<email>scott.todd0@gmail.com</email>
</author>
<published>2025-01-22T04:28:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=582fe3e0cac57cc47473f80dd96a2bd06ecd6290'/>
<id>582fe3e0cac57cc47473f80dd96a2bd06ecd6290</id>
<content type='text'>
See https://cmake.org/cmake/help/latest/policy/CMP0175.html

&gt; The `OUTPUT` form does not accept `PRE_BUILD`, `PRE_LINK`, or
`POST_BUILD` keywords.

When using CMake version 3.31+, this results in ~2000 lines of warning
spam in my downstream project:

```
CMake Warning (dev) at build-gcc/lib/cmake/mlir/AddMLIRPython.cmake:606 (add_custom_command):
  The following keywords are not supported when using
  add_custom_command(OUTPUT): PRE_BUILD.

  Policy CMP0175 is not set: add_custom_command() rejects invalid arguments.
  Run "cmake --help-policy CMP0175" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.
Call Stack (most recent call first):
  build-gcc/lib/cmake/mlir/AddMLIRPython.cmake:222 (add_mlir_python_sources_target)
  build-gcc/lib/cmake/mlir/AddMLIRPython.cmake:256 (_process_target)
  compiler/bindings/python/CMakeLists.txt:239 (add_mlir_python_modules)
This warning is for project developers.  Use -Wno-dev to suppress it.
```

General docs:
https://cmake.org/cmake/help/latest/command/add_custom_command.html.
Note that `PRE_BUILD` only appears in the _second_ signature for the
function (which takes `TARGET`) not the first (which takes `OUTPUT`).</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
See https://cmake.org/cmake/help/latest/policy/CMP0175.html

&gt; The `OUTPUT` form does not accept `PRE_BUILD`, `PRE_LINK`, or
`POST_BUILD` keywords.

When using CMake version 3.31+, this results in ~2000 lines of warning
spam in my downstream project:

```
CMake Warning (dev) at build-gcc/lib/cmake/mlir/AddMLIRPython.cmake:606 (add_custom_command):
  The following keywords are not supported when using
  add_custom_command(OUTPUT): PRE_BUILD.

  Policy CMP0175 is not set: add_custom_command() rejects invalid arguments.
  Run "cmake --help-policy CMP0175" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.
Call Stack (most recent call first):
  build-gcc/lib/cmake/mlir/AddMLIRPython.cmake:222 (add_mlir_python_sources_target)
  build-gcc/lib/cmake/mlir/AddMLIRPython.cmake:256 (_process_target)
  compiler/bindings/python/CMakeLists.txt:239 (add_mlir_python_modules)
This warning is for project developers.  Use -Wno-dev to suppress it.
```

General docs:
https://cmake.org/cmake/help/latest/command/add_custom_command.html.
Note that `PRE_BUILD` only appears in the _second_ signature for the
function (which takes `TARGET`) not the first (which takes `OUTPUT`).</pre>
</div>
</content>
</entry>
<entry>
<title>[mlir][python][cmake] Allows for specifying `NB_DOMAIN` in `add_mlir_python_extension` (#122865)</title>
<updated>2025-01-16T15:26:29+00:00</updated>
<author>
<name>erwei-xilinx</name>
<email>erwei.wang@amd.com</email>
</author>
<published>2025-01-16T15:26:29+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=9e863cd44945345f22a28cdd3ea12aaa7963345e'/>
<id>9e863cd44945345f22a28cdd3ea12aaa7963345e</id>
<content type='text'>
This PR allows the users to specify the `NB_DOMAIN` for
`add_mlir_python_extension`. This allows users to avoid nanobind domain
conflicts, when python bindings from multiple `mlir` projects were
imported.
(https://nanobind.readthedocs.io/en/latest/faq.html#how-can-i-avoid-conflicts-with-other-projects-using-nanobind)</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This PR allows the users to specify the `NB_DOMAIN` for
`add_mlir_python_extension`. This allows users to avoid nanobind domain
conflicts, when python bindings from multiple `mlir` projects were
imported.
(https://nanobind.readthedocs.io/en/latest/faq.html#how-can-i-avoid-conflicts-with-other-projects-using-nanobind)</pre>
</div>
</content>
</entry>
<entry>
<title>Enabled freethreading support in MLIR python bindings (#122684)</title>
<updated>2025-01-13T11:00:31+00:00</updated>
<author>
<name>vfdev</name>
<email>vfdev.5@gmail.com</email>
</author>
<published>2025-01-13T11:00:31+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=f136c800b60dbfacdbb645e7e92acba52e2f279f'/>
<id>f136c800b60dbfacdbb645e7e92acba52e2f279f</id>
<content type='text'>
Reland reverted https://github.com/llvm/llvm-project/pull/107103 with
the fixes for Python 3.8

cc @jpienaar

Co-authored-by: Peter Hawkins &lt;phawkins@google.com&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Reland reverted https://github.com/llvm/llvm-project/pull/107103 with
the fixes for Python 3.8

cc @jpienaar

Co-authored-by: Peter Hawkins &lt;phawkins@google.com&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>Revert "Added free-threading CPython mode support in MLIR Python bindings (#107103)"</title>
<updated>2025-01-12T18:30:42+00:00</updated>
<author>
<name>Jacques Pienaar</name>
<email>jpienaar@google.com</email>
</author>
<published>2025-01-12T18:30:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=3f1486f08e0dd64136fb7f50e38cd618dd0255d2'/>
<id>3f1486f08e0dd64136fb7f50e38cd618dd0255d2</id>
<content type='text'>
Breaks on 3.8, rolling back to avoid breakage while fixing.

This reverts commit 9dee7c44491635ec9037b90050bcdbd3d5291e38.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Breaks on 3.8, rolling back to avoid breakage while fixing.

This reverts commit 9dee7c44491635ec9037b90050bcdbd3d5291e38.
</pre>
</div>
</content>
</entry>
<entry>
<title>Added free-threading CPython mode support in MLIR Python bindings (#107103)</title>
<updated>2025-01-12T17:56:49+00:00</updated>
<author>
<name>vfdev</name>
<email>vfdev.5@gmail.com</email>
</author>
<published>2025-01-12T17:56:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=9dee7c44491635ec9037b90050bcdbd3d5291e38'/>
<id>9dee7c44491635ec9037b90050bcdbd3d5291e38</id>
<content type='text'>
Related to https://github.com/llvm/llvm-project/issues/105522

Description:

This PR is a joint work with Peter Hawkins (@hawkinsp) originally done
by myself for pybind11 and then reworked to nanobind based on Peter's
branch: https://github.com/hawkinsp/llvm-project/tree/nbdev .

- Added free-threading CPython mode support for MLIR Python bindings
- Added a test which can reveal data races when cpython and LLVM/MLIR
compiled with TSAN

Context:
- Related to https://github.com/google/jax/issues/23073

Co-authored-by: Peter Hawkins &lt;phawkins@google.com&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Related to https://github.com/llvm/llvm-project/issues/105522

Description:

This PR is a joint work with Peter Hawkins (@hawkinsp) originally done
by myself for pybind11 and then reworked to nanobind based on Peter's
branch: https://github.com/hawkinsp/llvm-project/tree/nbdev .

- Added free-threading CPython mode support for MLIR Python bindings
- Added a test which can reveal data races when cpython and LLVM/MLIR
compiled with TSAN

Context:
- Related to https://github.com/google/jax/issues/23073

Co-authored-by: Peter Hawkins &lt;phawkins@google.com&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>[mlir][python] declare `_PyClassMethod_New` undefined at link time (#121597)</title>
<updated>2025-01-03T21:52:07+00:00</updated>
<author>
<name>Maksim Levental</name>
<email>maksim.levental@gmail.com</email>
</author>
<published>2025-01-03T21:52:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=78f04477d658ae3de3cd416947c5bac65262a9ec'/>
<id>78f04477d658ae3de3cd416947c5bac65262a9ec</id>
<content type='text'>
`NanobindAdaptors.h` uses `PyClassMethod_New` to build `pure_subclass`es
but nanobind doesn't declare this API as undefined in its linker flags.
So we need to declare it as such for downstream users that do not do
something like `-undefined dynamic_lookup`</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
`NanobindAdaptors.h` uses `PyClassMethod_New` to build `pure_subclass`es
but nanobind doesn't declare this API as undefined in its linker flags.
So we need to declare it as such for downstream users that do not do
something like `-undefined dynamic_lookup`</pre>
</div>
</content>
</entry>
</feed>
