From 8218500ddf1c393fac324709962771fb1deae1f7 Mon Sep 17 00:00:00 2001 From: Abhishek Kulkarni <11399+adk9@users.noreply.github.com> Date: Thu, 7 Sep 2023 13:09:08 -0700 Subject: [PATCH] [llvm] Add option to enable MLIR Python bindings (#32415) --- ports/llvm/0010-remove-numpy.patch | 25 +++++++++++++++++++ ...clude.patch => 0011-missing-include.patch} | 0 ...12-create-destination-mlir-directory.patch | 13 ++++++++++ ports/llvm/portfile.cmake | 10 +++++++- ports/llvm/vcpkg.json | 17 ++++++++++++- versions/baseline.json | 2 +- versions/l-/llvm.json | 5 ++++ 7 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 ports/llvm/0010-remove-numpy.patch rename ports/llvm/{0010-missing-include.patch => 0011-missing-include.patch} (100%) create mode 100644 ports/llvm/0012-create-destination-mlir-directory.patch diff --git a/ports/llvm/0010-remove-numpy.patch b/ports/llvm/0010-remove-numpy.patch new file mode 100644 index 0000000000..aefd2eb534 --- /dev/null +++ b/ports/llvm/0010-remove-numpy.patch @@ -0,0 +1,25 @@ +From 80300a7f4533fdfc75ec60b0d1dc1c5d5a6b9e3c Mon Sep 17 00:00:00 2001 +From: Ankur Verma +Date: Fri, 14 Jul 2023 09:45:22 -0700 +Subject: [PATCH] remove_numpy + +--- + mlir/cmake/modules/MLIRDetectPythonEnv.cmake | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/mlir/cmake/modules/MLIRDetectPythonEnv.cmake b/mlir/cmake/modules/MLIRDetectPythonEnv.cmake +index 9c8966591514..35c94f0d1acc 100644 +--- a/mlir/cmake/modules/MLIRDetectPythonEnv.cmake ++++ b/mlir/cmake/modules/MLIRDetectPythonEnv.cmake +@@ -26,7 +26,7 @@ macro(mlir_configure_python_dev_packages) + set(_python_development_component Development.Module) + + find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION} +- COMPONENTS Interpreter ${_python_development_component} NumPy REQUIRED) ++ COMPONENTS Interpreter ${_python_development_component} REQUIRED) + unset(_python_development_component) + message(STATUS "Found python include dirs: ${Python3_INCLUDE_DIRS}") + message(STATUS "Found python libraries: ${Python3_LIBRARIES}") +-- +2.41.0.windows.2 + diff --git a/ports/llvm/0010-missing-include.patch b/ports/llvm/0011-missing-include.patch similarity index 100% rename from ports/llvm/0010-missing-include.patch rename to ports/llvm/0011-missing-include.patch diff --git a/ports/llvm/0012-create-destination-mlir-directory.patch b/ports/llvm/0012-create-destination-mlir-directory.patch new file mode 100644 index 0000000000..a8d6db47be --- /dev/null +++ b/ports/llvm/0012-create-destination-mlir-directory.patch @@ -0,0 +1,13 @@ +diff --git a/mlir/python/CMakeLists.txt b/mlir/python/CMakeLists.txt +index 7eb6e05e4..b9e1a096a 100644 +--- a/mlir/python/CMakeLists.txt ++++ b/mlir/python/CMakeLists.txt +@@ -483,6 +483,8 @@ add_mlir_python_common_capi_library(MLIRPythonCAPI + ${_ADDL_TEST_SOURCES} + ) + ++file(MAKE_DIRECTORY "${MLIR_BINARY_DIR}/python_packages/mlir_core/mlir/_mlir_libs") ++ + ################################################################################ + # The fully assembled package of modules. + # This must come last. diff --git a/ports/llvm/portfile.cmake b/ports/llvm/portfile.cmake index e4adf650df..4d7e26a182 100644 --- a/ports/llvm/portfile.cmake +++ b/ports/llvm/portfile.cmake @@ -15,7 +15,9 @@ vcpkg_from_github( 0007-Fix-install-bolt.patch 0008-llvm_assert.patch 0009-disable-libomp-aliases.patch - 0010-missing-include.patch + 0010-remove-numpy.patch + 0011-missing-include.patch + 0012-create-destination-mlir-directory.patch ) vcpkg_check_features( @@ -147,6 +149,12 @@ if("lldb" IN_LIST FEATURES) endif() if("mlir" IN_LIST FEATURES) list(APPEND LLVM_ENABLE_PROJECTS "mlir") + if("enable-mlir-python-bindings" IN_LIST FEATURES) + list(APPEND FEATURE_OPTIONS + -DMLIR_ENABLE_BINDINGS_PYTHON=ON + "-Dpybind11_DIR=${CURRENT_INSTALLED_DIR}/share/pybind11" + ) + endif() endif() if("openmp" IN_LIST FEATURES) list(APPEND LLVM_ENABLE_PROJECTS "openmp") diff --git a/ports/llvm/vcpkg.json b/ports/llvm/vcpkg.json index c9b2ed5836..4665ef82cf 100644 --- a/ports/llvm/vcpkg.json +++ b/ports/llvm/vcpkg.json @@ -1,7 +1,7 @@ { "name": "llvm", "version": "15.0.7", - "port-version": 5, + "port-version": 6, "description": "The LLVM Compiler Infrastructure.", "homepage": "https://llvm.org", "license": "Apache-2.0", @@ -193,6 +193,21 @@ "libxml2" ] }, + "enable-mlir-python-bindings": { + "description": "Build MLIR Python bindings.", + "supports": "!(windows & static)", + "dependencies": [ + { + "name": "llvm", + "default-features": false, + "features": [ + "mlir" + ] + }, + "pybind11", + "python3" + ] + }, "enable-rtti": { "description": "Build LLVM with run-time type information." }, diff --git a/versions/baseline.json b/versions/baseline.json index 8b900de9a2..da7078750d 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -5038,7 +5038,7 @@ }, "llvm": { "baseline": "15.0.7", - "port-version": 5 + "port-version": 6 }, "lmdb": { "baseline": "0.9.29", diff --git a/versions/l-/llvm.json b/versions/l-/llvm.json index d56d81d66f..1a224eb4e4 100644 --- a/versions/l-/llvm.json +++ b/versions/l-/llvm.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "484d2a5abb5ffc10d18e18603adb20bd01854012", + "version": "15.0.7", + "port-version": 6 + }, { "git-tree": "ce05511c7bf08ffecc627b73ae566e1a1e7e6b20", "version": "15.0.7",