IQVIA-ML / LightGBM.jl

Julia FFI interface to Microsoft's LightGBM package
Other
93 stars 10 forks source link

fixing precompile caching of the library path #108

Closed yalwan-sage closed 3 years ago

yalwan-sage commented 3 years ago

Addresses #105

Tested locally by re-invoking julia many times and seeing that the log message appears each time, and also by setting LD_LIBRARY_PATH and observing different log message appearing

yalwan-sage commented 3 years ago

Ok I figured out what's going on here

see: https://stackoverflow.com/a/35835289

In short, it might not be possible to have it so that setting or unsetting LD_LIBRARY_PATH allows to change the library (as a string) in between different invocations without also forcing the recompile -- the reason for this is that the args to ccall needs to be a const (and for a string that basically means a literal or something evaluated by the compiler into a literal -- determining this at runtime makes it not a constant expression basically), or a function symbol visible in the current process, or a pointer to a function

So, I reworked this so that the lib after its found is opened into a library pointer as the module variable, and updated the macro to look up the function pointer for each function it tries to call into, and then updated the ccall so that it uses the function specific pointer.

kainkad commented 3 years ago

thanks @yalwan-sage for your contribution and sorting this out!

kainkad commented 3 years ago

sorry Friday brain (or the 😺 pressed the button)