-
Notifications
You must be signed in to change notification settings - Fork 9
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
Conversation
@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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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"] |
There was a problem hiding this comment.
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 👍
There was a problem hiding this 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.
@masa16 How do you think this? |
This may fix #35. |
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.