From 1c2724e82bc86a748ffc9440852f7c45afee15b1 Mon Sep 17 00:00:00 2001 From: Jesper Stemann Andersen Date: Mon, 16 Dec 2024 10:37:28 +0100 Subject: [PATCH 1/9] [MLX] Updated to "master" --- M/MLX/build_tarballs.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/M/MLX/build_tarballs.jl b/M/MLX/build_tarballs.jl index 4de168db135..fc13f73e3d3 100644 --- a/M/MLX/build_tarballs.jl +++ b/M/MLX/build_tarballs.jl @@ -3,10 +3,10 @@ using BinaryBuilder, Pkg name = "MLX" -version = v"0.21.1" +version = v"0.21.2" # unofficial sources = [ - GitSource("https://github.com/ml-explore/mlx.git", "50fa7051259d31da0778133bc7456dc029471bff"), + GitSource("https://github.com/ml-explore/mlx.git", "af5a614aad314233a3a236ae08789680a533615e"), # master ArchiveSource("https://github.com/roblabla/MacOSX-SDKs/releases/download/macosx14.0/MacOSX14.0.sdk.tar.xz", "4a31565fd2644d1aec23da3829977f83632a20985561a2038e198681e7e7bf49"), # Using the PyPI wheel for aarch64-apple-darwin to get the metal backend, which requires the `metal` compiler to build (which is practically impossible to use from the BinaryBuilder build env.) From 80dccc3464c5db24f3e7b5d09042e92736ae253d Mon Sep 17 00:00:00 2001 From: Jesper Stemann Andersen Date: Mon, 16 Dec 2024 10:39:16 +0100 Subject: [PATCH 2/9] Removed cmake-win32-io patch --- M/MLX/build_tarballs.jl | 5 ----- M/MLX/bundled/patches/cmake-win32-io.patch | 13 ------------- 2 files changed, 18 deletions(-) delete mode 100644 M/MLX/bundled/patches/cmake-win32-io.patch diff --git a/M/MLX/build_tarballs.jl b/M/MLX/build_tarballs.jl index fc13f73e3d3..c13643cfde2 100644 --- a/M/MLX/build_tarballs.jl +++ b/M/MLX/build_tarballs.jl @@ -11,7 +11,6 @@ sources = [ "4a31565fd2644d1aec23da3829977f83632a20985561a2038e198681e7e7bf49"), # Using the PyPI wheel for aarch64-apple-darwin to get the metal backend, which requires the `metal` compiler to build (which is practically impossible to use from the BinaryBuilder build env.) FileSource("https://files.pythonhosted.org/packages/72/1f/267d7fb06eb257feb7c281f73472bcae9735c9a7c09fe86d9362069c85a7/mlx-0.21.1-cp313-cp313-macosx_13_0_arm64.whl", "88328c058f4765b0376ac908b49e6711d25f93e02b972b8e68b73a9e1c358eab"; filename = "mlx-aarch64-apple-darwin20.whl"), - DirectorySource("./bundled"), ] script = raw""" @@ -25,10 +24,6 @@ fi cd $WORKSPACE/srcdir/mlx -if [[ "$target" == *-w64-mingw32* ]]; then - atomic_patch -p1 ../patches/cmake-win32-io.patch -fi - CMAKE_EXTRA_OPTIONS=() if [[ "$target" == x86_64-apple-darwin* ]]; then CMAKE_EXTRA_OPTIONS+=("-DMLX_ENABLE_X64_MAC=ON") diff --git a/M/MLX/bundled/patches/cmake-win32-io.patch b/M/MLX/bundled/patches/cmake-win32-io.patch deleted file mode 100644 index 31b276f3f44..00000000000 --- a/M/MLX/bundled/patches/cmake-win32-io.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/mlx/io/CMakeLists.txt b/mlx/io/CMakeLists.txt -index 2402ff58..5daf93dc 100644 ---- a/mlx/io/CMakeLists.txt -+++ b/mlx/io/CMakeLists.txt -@@ -1,4 +1,7 @@ --target_sources(mlx PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/load.cpp) -+# load.cpp depends on pread, which is not available on mingw32 -+if(NOT WIN32) -+ target_sources(mlx PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/load.cpp) -+endif() - - if(MLX_BUILD_SAFETENSORS) - message(STATUS "Downloading json") From dc8358844a7bb984527eba3d3eb4448f1d429fd5 Mon Sep 17 00:00:00 2001 From: Jesper Stemann Andersen Date: Mon, 16 Dec 2024 10:47:55 +0100 Subject: [PATCH 3/9] Added mlx-io-load-mingw32.patch --- M/MLX/build_tarballs.jl | 5 +++++ .../bundled/patches/mlx-io-load-mingw32.patch | 22 +++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 M/MLX/bundled/patches/mlx-io-load-mingw32.patch diff --git a/M/MLX/build_tarballs.jl b/M/MLX/build_tarballs.jl index c13643cfde2..2268a0e780d 100644 --- a/M/MLX/build_tarballs.jl +++ b/M/MLX/build_tarballs.jl @@ -11,6 +11,7 @@ sources = [ "4a31565fd2644d1aec23da3829977f83632a20985561a2038e198681e7e7bf49"), # Using the PyPI wheel for aarch64-apple-darwin to get the metal backend, which requires the `metal` compiler to build (which is practically impossible to use from the BinaryBuilder build env.) FileSource("https://files.pythonhosted.org/packages/72/1f/267d7fb06eb257feb7c281f73472bcae9735c9a7c09fe86d9362069c85a7/mlx-0.21.1-cp313-cp313-macosx_13_0_arm64.whl", "88328c058f4765b0376ac908b49e6711d25f93e02b972b8e68b73a9e1c358eab"; filename = "mlx-aarch64-apple-darwin20.whl"), + DirectorySource("./bundled"), ] script = raw""" @@ -24,6 +25,10 @@ fi cd $WORKSPACE/srcdir/mlx +if [[ "$target" == *-w64-mingw32* ]]; then + atomic_patch -p1 ../patches/mlx-io-load-mingw32.patch +fi + CMAKE_EXTRA_OPTIONS=() if [[ "$target" == x86_64-apple-darwin* ]]; then CMAKE_EXTRA_OPTIONS+=("-DMLX_ENABLE_X64_MAC=ON") diff --git a/M/MLX/bundled/patches/mlx-io-load-mingw32.patch b/M/MLX/bundled/patches/mlx-io-load-mingw32.patch new file mode 100644 index 00000000000..0a9f6439ed3 --- /dev/null +++ b/M/MLX/bundled/patches/mlx-io-load-mingw32.patch @@ -0,0 +1,22 @@ +diff --git a/mlx/io/load.cpp b/mlx/io/load.cpp +index 22bffd01..feeafafb 100644 +--- a/mlx/io/load.cpp ++++ b/mlx/io/load.cpp +@@ -6,7 +6,7 @@ + #include + + // Used by pread implementation. +-#ifdef _MSC_VER ++#ifdef _WIN32 + #define NOMINMAX + #include + #endif +@@ -106,7 +106,7 @@ Dtype dtype_from_array_protocol(std::string_view t) { + "[from_str] Invalid array protocol type-string: " + std::string(t)); + } + +-#ifdef _MSC_VER ++#ifdef _WIN32 + // There is no pread on Windows, emulate it with ReadFile. + int64_t pread(int fd, void* buf, uint64_t size, uint64_t offset) { + HANDLE file = reinterpret_cast(_get_osfhandle(fd)); From 28d8d205b96c8752c5346c16b8a5ade53a03e73e Mon Sep 17 00:00:00 2001 From: Jesper Stemann Andersen Date: Mon, 16 Dec 2024 11:13:48 +0100 Subject: [PATCH 4/9] Updated mlx-io-load-mingw32.patch to only define NOMINMAX on MSVC --- M/MLX/bundled/patches/mlx-io-load-mingw32.patch | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/M/MLX/bundled/patches/mlx-io-load-mingw32.patch b/M/MLX/bundled/patches/mlx-io-load-mingw32.patch index 0a9f6439ed3..70bbea58de8 100644 --- a/M/MLX/bundled/patches/mlx-io-load-mingw32.patch +++ b/M/MLX/bundled/patches/mlx-io-load-mingw32.patch @@ -1,17 +1,21 @@ diff --git a/mlx/io/load.cpp b/mlx/io/load.cpp -index 22bffd01..feeafafb 100644 +index 22bffd01..d3d40642 100644 --- a/mlx/io/load.cpp +++ b/mlx/io/load.cpp -@@ -6,7 +6,7 @@ +@@ -6,9 +6,11 @@ #include // Used by pread implementation. --#ifdef _MSC_VER +#ifdef _WIN32 ++#include ++#endif + #ifdef _MSC_VER #define NOMINMAX - #include +-#include #endif -@@ -106,7 +106,7 @@ Dtype dtype_from_array_protocol(std::string_view t) { + + #include "mlx/io/load.h" +@@ -106,7 +108,7 @@ Dtype dtype_from_array_protocol(std::string_view t) { "[from_str] Invalid array protocol type-string: " + std::string(t)); } From 12c52b8eff6f80224fe20ca6c3df96230f73b8a8 Mon Sep 17 00:00:00 2001 From: Jesper Stemann Andersen Date: Wed, 18 Dec 2024 10:53:21 +0100 Subject: [PATCH 5/9] Updated - no patches should be needed --- M/MLX/build_tarballs.jl | 7 +---- .../bundled/patches/mlx-io-load-mingw32.patch | 26 ------------------- 2 files changed, 1 insertion(+), 32 deletions(-) delete mode 100644 M/MLX/bundled/patches/mlx-io-load-mingw32.patch diff --git a/M/MLX/build_tarballs.jl b/M/MLX/build_tarballs.jl index 2268a0e780d..ecd415bb0ab 100644 --- a/M/MLX/build_tarballs.jl +++ b/M/MLX/build_tarballs.jl @@ -6,12 +6,11 @@ name = "MLX" version = v"0.21.2" # unofficial sources = [ - GitSource("https://github.com/ml-explore/mlx.git", "af5a614aad314233a3a236ae08789680a533615e"), # master + GitSource("https://github.com/ml-explore/mlx.git", "070bd433ab027a2143364c467d95983f2317d3a3"), # master ArchiveSource("https://github.com/roblabla/MacOSX-SDKs/releases/download/macosx14.0/MacOSX14.0.sdk.tar.xz", "4a31565fd2644d1aec23da3829977f83632a20985561a2038e198681e7e7bf49"), # Using the PyPI wheel for aarch64-apple-darwin to get the metal backend, which requires the `metal` compiler to build (which is practically impossible to use from the BinaryBuilder build env.) FileSource("https://files.pythonhosted.org/packages/72/1f/267d7fb06eb257feb7c281f73472bcae9735c9a7c09fe86d9362069c85a7/mlx-0.21.1-cp313-cp313-macosx_13_0_arm64.whl", "88328c058f4765b0376ac908b49e6711d25f93e02b972b8e68b73a9e1c358eab"; filename = "mlx-aarch64-apple-darwin20.whl"), - DirectorySource("./bundled"), ] script = raw""" @@ -25,10 +24,6 @@ fi cd $WORKSPACE/srcdir/mlx -if [[ "$target" == *-w64-mingw32* ]]; then - atomic_patch -p1 ../patches/mlx-io-load-mingw32.patch -fi - CMAKE_EXTRA_OPTIONS=() if [[ "$target" == x86_64-apple-darwin* ]]; then CMAKE_EXTRA_OPTIONS+=("-DMLX_ENABLE_X64_MAC=ON") diff --git a/M/MLX/bundled/patches/mlx-io-load-mingw32.patch b/M/MLX/bundled/patches/mlx-io-load-mingw32.patch deleted file mode 100644 index 70bbea58de8..00000000000 --- a/M/MLX/bundled/patches/mlx-io-load-mingw32.patch +++ /dev/null @@ -1,26 +0,0 @@ -diff --git a/mlx/io/load.cpp b/mlx/io/load.cpp -index 22bffd01..d3d40642 100644 ---- a/mlx/io/load.cpp -+++ b/mlx/io/load.cpp -@@ -6,9 +6,11 @@ - #include - - // Used by pread implementation. -+#ifdef _WIN32 -+#include -+#endif - #ifdef _MSC_VER - #define NOMINMAX --#include - #endif - - #include "mlx/io/load.h" -@@ -106,7 +108,7 @@ Dtype dtype_from_array_protocol(std::string_view t) { - "[from_str] Invalid array protocol type-string: " + std::string(t)); - } - --#ifdef _MSC_VER -+#ifdef _WIN32 - // There is no pread on Windows, emulate it with ReadFile. - int64_t pread(int fd, void* buf, uint64_t size, uint64_t offset) { - HANDLE file = reinterpret_cast(_get_osfhandle(fd)); From 688d0034787fa0710d43ba411f30a070d4909785 Mon Sep 17 00:00:00 2001 From: Jesper Stemann Andersen Date: Wed, 18 Dec 2024 10:58:28 +0100 Subject: [PATCH 6/9] Temp. enabled tests and examples --- M/MLX/build_tarballs.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/M/MLX/build_tarballs.jl b/M/MLX/build_tarballs.jl index ecd415bb0ab..98217678e78 100644 --- a/M/MLX/build_tarballs.jl +++ b/M/MLX/build_tarballs.jl @@ -57,8 +57,8 @@ if [[ "$target" != aarch64-apple-darwin* ]]; then -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=$prefix \ -DCMAKE_TOOLCHAIN_FILE=$CMAKE_TARGET_TOOLCHAIN \ - -DMLX_BUILD_TESTS=OFF \ - -DMLX_BUILD_EXAMPLES=OFF \ + -DMLX_BUILD_TESTS=ON \ + -DMLX_BUILD_EXAMPLES=ON \ -DMLX_BUILD_METAL=OFF \ -DBUILD_SHARED_LIBS=ON \ -G Ninja \ From c749d722eb04b0f37027a925dfc92beff6654b35 Mon Sep 17 00:00:00 2001 From: Jesper Stemann Andersen Date: Wed, 18 Dec 2024 11:16:19 +0100 Subject: [PATCH 7/9] Temp. hack to not run tests in build --- M/MLX/build_tarballs.jl | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/M/MLX/build_tarballs.jl b/M/MLX/build_tarballs.jl index 98217678e78..2c98cc488dd 100644 --- a/M/MLX/build_tarballs.jl +++ b/M/MLX/build_tarballs.jl @@ -24,6 +24,9 @@ fi cd $WORKSPACE/srcdir/mlx +sed -i -e 's/doctest_discover_tests(tests)//' tests/CMakeLists.txt +sed -i -e 's/add_test(NAME tests COMMAND tests)//' tests/CMakeLists.txt + CMAKE_EXTRA_OPTIONS=() if [[ "$target" == x86_64-apple-darwin* ]]; then CMAKE_EXTRA_OPTIONS+=("-DMLX_ENABLE_X64_MAC=ON") @@ -66,6 +69,13 @@ if [[ "$target" != aarch64-apple-darwin* ]]; then cmake --build build --parallel $nproc cmake --install build cmake --install build --component headers + + cd build/examples/cpp + find . -type f -perm 755 -exec install -D -m 755 -v {} $bindir/mlx/examples/{} \; + cd - + cd build/tests + find . -type f -perm 755 -exec install -D -m 755 -v {} $bindir/mlx/{} \; + cd - else cd $WORKSPACE/srcdir unzip -d mlx-$target mlx-$target.whl From 031839e1bca345808202cef8505f421012360dcd Mon Sep 17 00:00:00 2001 From: Jesper Stemann Andersen Date: Thu, 19 Dec 2024 11:28:25 +0100 Subject: [PATCH 8/9] Updated - no need for dlfcn-win32 --- M/MLX/build_tarballs.jl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/M/MLX/build_tarballs.jl b/M/MLX/build_tarballs.jl index 2c98cc488dd..0337f4b3e2d 100644 --- a/M/MLX/build_tarballs.jl +++ b/M/MLX/build_tarballs.jl @@ -6,7 +6,7 @@ name = "MLX" version = v"0.21.2" # unofficial sources = [ - GitSource("https://github.com/ml-explore/mlx.git", "070bd433ab027a2143364c467d95983f2317d3a3"), # master + GitSource("https://github.com/ml-explore/mlx.git", "f17536af9c484ebb26a056292ed10acc32de3910"), # master ArchiveSource("https://github.com/roblabla/MacOSX-SDKs/releases/download/macosx14.0/MacOSX14.0.sdk.tar.xz", "4a31565fd2644d1aec23da3829977f83632a20985561a2038e198681e7e7bf49"), # Using the PyPI wheel for aarch64-apple-darwin to get the metal backend, which requires the `metal` compiler to build (which is practically impossible to use from the BinaryBuilder build env.) @@ -106,7 +106,6 @@ products = Product[ ] dependencies = [ - Dependency("dlfcn_win32_jll"; platforms = filter(Sys.iswindows, platforms)), Dependency("libblastrampoline_jll"; compat="5.4", platforms = libblastrampoline_platforms), Dependency("OpenBLAS32_jll"; platforms = openblas_platforms), HostBuildDependency(PackageSpec(name="CMake_jll")), # Need CMake >= 3.24 From 4a6bd9e25b59adfb8311e1ea7ac6341b84e4f263 Mon Sep 17 00:00:00 2001 From: Jesper Stemann Andersen Date: Tue, 7 Jan 2025 08:27:07 +0100 Subject: [PATCH 9/9] Updated to 545f84d905b94bf3d1eb18d8668ff58ee70d7a68 --- M/MLX/build_tarballs.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/M/MLX/build_tarballs.jl b/M/MLX/build_tarballs.jl index 0337f4b3e2d..65066bf8124 100644 --- a/M/MLX/build_tarballs.jl +++ b/M/MLX/build_tarballs.jl @@ -6,7 +6,7 @@ name = "MLX" version = v"0.21.2" # unofficial sources = [ - GitSource("https://github.com/ml-explore/mlx.git", "f17536af9c484ebb26a056292ed10acc32de3910"), # master + GitSource("https://github.com/ml-explore/mlx.git", "545f84d905b94bf3d1eb18d8668ff58ee70d7a68"), # master ArchiveSource("https://github.com/roblabla/MacOSX-SDKs/releases/download/macosx14.0/MacOSX14.0.sdk.tar.xz", "4a31565fd2644d1aec23da3829977f83632a20985561a2038e198681e7e7bf49"), # Using the PyPI wheel for aarch64-apple-darwin to get the metal backend, which requires the `metal` compiler to build (which is practically impossible to use from the BinaryBuilder build env.)