[Mlir-commits] [mlir] 3c84812 - [mlir][python] Fail fast when nanobind is missing for Python bindings (#174649)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu Jan 8 09:34:37 PST 2026
Author: Hideto Ueno
Date: 2026-01-08T09:34:33-08:00
New Revision: 3c848122329e0c397dd10d9beb800d35f1dd3328
URL: https://github.com/llvm/llvm-project/commit/3c848122329e0c397dd10d9beb800d35f1dd3328
DIFF: https://github.com/llvm/llvm-project/commit/3c848122329e0c397dd10d9beb800d35f1dd3328.diff
LOG: [mlir][python] Fail fast when nanobind is missing for Python bindings (#174649)
Remove problematic `return()` statements from
mlir_configure_python_dev_packages macro and convert nanobind detection
to FATAL_ERROR.
Using `return()` in a CMake macro is problematic because it returns from
the calling scope, not the macro itself, causing the parent
CMakeLists.txt to silently skip subsequent configuration steps. This
leads to confusing build failures when Python bindings are enabled but
nanobind is missing.
With this change, users get an immediate error with clear instructions
to install nanobind or set nanobind_DIR, rather than silent
configuration failures.
Added:
Modified:
mlir/cmake/modules/MLIRDetectPythonEnv.cmake
Removed:
################################################################################
diff --git a/mlir/cmake/modules/MLIRDetectPythonEnv.cmake b/mlir/cmake/modules/MLIRDetectPythonEnv.cmake
index 098d12aedeb91..01dd7437cc8fc 100644
--- a/mlir/cmake/modules/MLIRDetectPythonEnv.cmake
+++ b/mlir/cmake/modules/MLIRDetectPythonEnv.cmake
@@ -60,8 +60,7 @@ macro(mlir_configure_python_dev_packages)
OUTPUT_VARIABLE PACKAGE_DIR
ERROR_QUIET)
if(NOT STATUS EQUAL "0")
- message(STATUS "not found (install via 'pip install nanobind' or set nanobind_DIR)")
- return()
+ message(FATAL_ERROR "not found (install via 'pip install nanobind' or set nanobind_DIR)")
endif()
message(STATUS "found (${PACKAGE_DIR})")
set(nanobind_DIR "${PACKAGE_DIR}")
@@ -73,8 +72,7 @@ macro(mlir_configure_python_dev_packages)
OUTPUT_VARIABLE PACKAGE_DIR
ERROR_QUIET)
if(NOT STATUS EQUAL "0")
- message(STATUS "not found (install via 'pip install nanobind' or set nanobind_DIR)")
- return()
+ message(FATAL_ERROR "not found (install via 'pip install nanobind' or set nanobind_DIR)")
endif()
set(nanobind_INCLUDE_DIR "${PACKAGE_DIR}")
endif()
More information about the Mlir-commits
mailing list