Build native libs instead of installing a bunch of potentially incompatible or broken ones
Closed this issue · 4 comments
@ankane Could you please take a look?
Currently the gem seems to simply install arbitrary pre-built libs:
/opt/local/lib/ruby3.3/gems/3.3.0/gems/lightgbm-0.3.2/vendor/lib_lightgbm.arm64.dylib
/opt/local/lib/ruby3.3/gems/3.3.0/gems/lightgbm-0.3.2/vendor/lib_lightgbm.dylib
/opt/local/lib/ruby3.3/gems/3.3.0/gems/lightgbm-0.3.2/vendor/lib_lightgbm.so
/opt/local/lib/ruby3.3/gems/3.3.0/gems/lightgbm-0.3.2/vendor/lib_lightgbm.dll
This is a problematic way:
- This will fail on every arch which does not have a pre-built lib.
- This will likely not work correctly on specific OS versions even on supported archs.
- This leaves the gem broken due to hardcoded dependencies.
- It is desirable not to install unnecessary stuff: there is no reason for someone to want a Windows dll on macOS or BSD, I believe.
Instead, if the library is built from source, that gonna fix all those issues.
P. S. To the point 3, pre-built dylib has an odd hardcoded path for libomp
:
Could not open /opt/homebrew/opt/libomp/lib/libomp.dylib: Error opening or reading file (referenced from /opt/local/lib/ruby3.3/gems/3.3.0/gems/lightgbm-0.3.2/vendor/lib_lightgbm.arm64.dylib)
Could not open /usr/local/opt/libomp/lib/libomp.dylib: Error opening or reading file (referenced from /opt/local/lib/ruby3.3/gems/3.3.0/gems/lightgbm-0.3.2/vendor/lib_lightgbm.dylib)
---> Found 2 broken files, matching files to ports
---> Found 1 broken port, determining rebuild order
You can always run 'port rev-upgrade' again to fix errors.
The following ports will be rebuilt: rb33-lightgbm @0.3.2
This is wrong for three reasons:
libomp
is a clang-specific library, so gonna fail with GCC.libomp
is an LLVM-specific library, so may not be available with Apple clang.- It uses an odd hardcoded path, so this will fail even when
libomp
is available, but the path differs.
Hi @barracuda156, I think the current approach is better for most users, but you can build LightGBM from source and set LightGBM.ffi_lib
if needed.
@ankane Ok, I have made a port for a standalone LightGBM
now, once PR merged, it will be in MacPorts.
Could you say how do I set the variable for Ruby, so that it does not install any bundled libs but instead uses an external one?
@ankane If you would wish to test on your end: https://ports.macports.org/port/LightGBM/details
@ankane Any update on this?