[go: nahoru, domu]

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

Build native libs instead of installing a bunch of potentially incompatible or broken ones #7

Closed
barracuda156 opened this issue Mar 9, 2024 · 4 comments

Comments

@barracuda156
Copy link

@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:

  1. This will fail on every arch which does not have a pre-built lib.
  2. This will likely not work correctly on specific OS versions even on supported archs.
  3. This leaves the gem broken due to hardcoded dependencies.
  4. 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:

  1. libomp is a clang-specific library, so gonna fail with GCC.
  2. libomp is an LLVM-specific library, so may not be available with Apple clang.
  3. It uses an odd hardcoded path, so this will fail even when libomp is available, but the path differs.
@ankane
Copy link
Owner
ankane commented Mar 9, 2024

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 ankane closed this as completed Mar 9, 2024
@barracuda156
Copy link
Author

@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?

@barracuda156
Copy link
Author

@ankane If you would wish to test on your end: https://ports.macports.org/port/LightGBM/details

@barracuda156
Copy link
Author

@ankane Any update on this?

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

No branches or pull requests

2 participants