Skip to content

Conversation

@zcbenz
Copy link
Collaborator

@zcbenz zcbenz commented Jan 22, 2026

Close #3031.
Close #3020.

This PR links MLX with the prebuilt dynamic library of OpenBLAS on Windows instead of building it from source code, which can save a lot of build time. (Note that we can not do static-linking, check the comments for more.)

Which then requires changing the locations where libraries and executables are generated, as Windows requires the DLL and EXE files be in the same directory (as there is no equivalent of RPATH on Windows):

  • For building: the DLL and EXE would be written in the root build dir (previously EXE are put in sub-dirs like tests/test.exe)
  • For installing: the DLL would be put in the same dir with extension file (previously they are put in the bin sub-dir)

Note that the locations are only changed for Windows, and only when MLX is the top project, for projects that include MLX as a third party library there is nothing changed.

/cc @dhiltgen

Copy link
Member

@awni awni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

Copy link
Contributor

@dhiltgen dhiltgen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - I can rebase #3024 on top of this if it merges first.

EXCLUDE_FROM_ALL)
set(BUILD_STATIC_LIBS ON) # link statically
set(NOFORTRAN ON) # msvc has no fortran compiler
URL "https://github.com/OpenMathLib/OpenBLAS/releases/download/v0.3.31/OpenBLAS-0.3.31-x64.zip"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fwiw, I've also been playing around with trying to get things building on Windows ARM64, which needed patching of the OpenBLAS cmake files to get all the variables set up properly for LLVM-MinGW.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenBLAS provides binaries for Windows ARM64 (the woa64 files), can we just link with that?

@zcbenz zcbenz force-pushed the openblas-dynamic-lib branch from 4d42605 to 950fd70 Compare January 23, 2026 01:22
@zcbenz zcbenz merged commit 1650c49 into ml-explore:main Jan 23, 2026
16 checks passed
@zcbenz zcbenz deleted the openblas-dynamic-lib branch January 23, 2026 02:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Built DLLs in the same directory with EXEs on Windows Link with prebuilt binaries of OpenBLAS on Windows

3 participants