Skip to content

Install mlx.dll into the same dir with python bindings on Windows - #1690

Merged
awni merged 4 commits into
ml-explore:mainfrom
zcbenz:msvc-install
Dec 14, 2024
Merged

awni merged 4 commits into
ml-explore:mainfrom
zcbenz:msvc-install

Conversation

@zcbenz

@zcbenz zcbenz commented Dec 11, 2024

Copy link
Copy Markdown
Member

Refs #1513.

On Windows the statically linked DLLs must be put in the same directory with the python bindings (or in the system DLL locations), and there is no compiler option to change that. This PR changes the install destination of mlx.dll to CMAKE_INSTALL_PREFIX instance of CMAKE_INSTALL_BINDIR.

The dlfcn-win32 dependency is also changed to be linked statically.

Comment thread CMakeLists.txt Outdated
Comment on lines +128 to +132
SOURCE_SUBDIR use-an-unexist-path-to-skip-cmake-of-dlfcn-win32
EXCLUDE_FROM_ALL)
FetchContent_MakeAvailable(dlfcn-win32)
target_include_directories(mlx PRIVATE "${dlfcn-win32_SOURCE_DIR}/src")
target_link_libraries(mlx PRIVATE dl)
target_sources(mlx PRIVATE ${dlfcn-win32_SOURCE_DIR}/src/dlfcn.c)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

it might be simpler to set(BUILD_SHARED_LIBS OFF) ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Updated the code to set BUILD_SHARED_LIBS, also bumped the required cmake version for using block.

@awni awni left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks! I'm ok with the cmake bump.

@awni

awni commented Dec 14, 2024

Copy link
Copy Markdown
Member

We should update our documentation though I think it specifies cmake 3.24. I can send a patch here or you can add it if you have time.

@zcbenz

zcbenz commented Dec 14, 2024

Copy link
Copy Markdown
Member Author

Updated the docs and requirements.

@awni

awni commented Dec 14, 2024

Copy link
Copy Markdown
Member

Thank you!

@zcbenz

zcbenz commented Dec 14, 2024 •

Copy link
Copy Markdown
Member Author

Sorry there was a cmake lint error, can you run tests again?

@awni
awni merged commit f9640e0 into ml-explore:main Dec 14, 2024
@stemann

stemann commented Dec 16, 2024

Copy link
Copy Markdown
Contributor

This broke building/installing shared libs on (MinGW) Windows for non-Python applications: https://buildkite.com/julialang/yggdrasil/builds/15595#0193cee0-171b-4396-ace6-6e62a0345b11

E.g., libmlx.dll ends up in a non-standard location (directly in CMAKE_INSTALL_PREFIX it seems).

@awni

awni commented Dec 16, 2024

Copy link
Copy Markdown
Member

It should be statically linked 🤔

@zcbenz
zcbenz deleted the msvc-install branch December 16, 2024 23:47
@zcbenz

zcbenz commented Dec 16, 2024

Copy link
Copy Markdown
Member Author

Static linking seems to be the simplest solution, I'll send a PR to do static linking in setup.py and revert the change on install location.

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.

3 participants