Hello, thank you for this very useful gem.
On Alpine (a non-glibc Linux), it fails to guess versioned library names correctly. Here's what happens:
- My gem needs to open the library
glib-2.0. This shared library is installed like this on Alpine:
/ # ls /usr/lib/libglib*
/usr/lib/libglib-2.0.so.0 /usr/lib/libglib-2.0.so.0.5800.1
ie. the .so symlink is only installed with the glib-dev package. This means ffi will need an ABI version. My library therefore asks ffi for glib-2.0.so.0.
-
ffi_lib calls map_library_name to turn this into a platform native name. This adds a lib prefix to make libglib-2.0.so.0 (the correct name).
-
However, ffi then checks FFI::Platform::IS_GNU, finds it nil (this is a musl Linux, not glibc), and erroneously adds an extra .so suffix.
-
libglib-2.0.so.0.so is not found and my gem fails to start.
Here's the map_library_name method for reference:
https://github.com/ffi/ffi/blob/master/lib/ffi/library.rb#L34
I'm probably being naive here, but it seems to me that IS_GNU is being used to mean something like "is linux" (ie. not macos or win).
How about changing that line to be:
r = Platform::IS_WINDOWS || Platform::IS_MAC ?
"\\.#{Platform::LIBSUFFIX}$" :
"\\.so($|\\.[1234567890]+)"
ie. only attach the suffix on windows and mac (the only two platforms which always use it, I think).
Hello, thank you for this very useful gem.
On Alpine (a non-glibc Linux), it fails to guess versioned library names correctly. Here's what happens:
glib-2.0. This shared library is installed like this on Alpine:ie. the
.sosymlink is only installed with theglib-devpackage. This means ffi will need an ABI version. My library therefore asks ffi forglib-2.0.so.0.ffi_libcallsmap_library_nameto turn this into a platform native name. This adds alibprefix to makelibglib-2.0.so.0(the correct name).However, ffi then checks
FFI::Platform::IS_GNU, finds it nil (this is a musl Linux, not glibc), and erroneously adds an extra.sosuffix.libglib-2.0.so.0.sois not found and my gem fails to start.Here's the
map_library_namemethod for reference:https://github.com/ffi/ffi/blob/master/lib/ffi/library.rb#L34
I'm probably being naive here, but it seems to me that
IS_GNUis being used to mean something like "is linux" (ie. not macos or win).How about changing that line to be:
ie. only attach the suffix on windows and mac (the only two platforms which always use it, I think).