Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweak autoloader for Windows #42

Merged
merged 3 commits into from Jul 19, 2021
Merged

Conversation

mrkn
Copy link
Contributor

@mrkn mrkn commented Jul 13, 2021

This change tweaks the autoloader for Windows, especially for Ruby Installer 2.

Ruby Installer 2 adds the bin directory of its MSYS2 (a.k.a. DEVKIT) in the default DLL search directories. This directory is the location of the DLLs installed by pacman command.

If we try libraries only with their names like Fiddle.dlopen("libopenblas.dll") first, the autoloader makes it easier to use libraries installed by pacman command.

@mrkn
Copy link
Contributor Author

mrkn commented Jul 13, 2021

@yoshoku Could you please check this?

lib_dirs.find do |d|
x = Dir.glob("#{d}/lib#{l}{,64}.#{lib_ext}{,.*}").find do |lib|
begin
Fiddle.dlopen(lib).close
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Use Fiddle.dlopen here to examine the candidate files can be dlopen-ed.

false
else
true
end
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a smart way to find a loadable library 👍

@@ -64,7 +64,12 @@ def load_library
end

def detect_library_extension
case RbConfig::CONFIG['host_os']
# Ruby >= 2.5 provides SOEXT in rbconfig
so_ext = RbConfig::CONFIG["SOEXT"]
Copy link
Contributor

Choose a reason for hiding this comment

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

I am happy to know such a useful config value 👍

Copy link
Contributor

@yoshoku yoshoku left a comment

Choose a reason for hiding this comment

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

I am glad that the autoloader now runs on windows 👍

Ruby Installer 2 adds the bin directory of MSYS2 (DEVKIT) in the
default DLL directories.  Trying to seach DLLs in the default search
directories makes us easy to use OpenBLAS and LAPACK installed by
pacman command.
@mrkn
Copy link
Contributor Author

mrkn commented Jul 15, 2021

@masa16 How do you think this?

@mrkn
Copy link
Contributor Author

mrkn commented Jul 15, 2021

This may fix #35.

@masa16 masa16 merged commit a2454be into ruby-numo:master Jul 19, 2021
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.

None yet

3 participants