#1 Request: custom FFI Loader?

Terbuka
dibuka 4 tahun lalu oleh Gounlaf · 5 komentar

Hi,

Could you provide a way to make the FFI loading dynamic? I would like to use this library https://github.com/rask/php-libload. Right now, I think I can extend your classes and override completely the ctor. But it's not really safe.

Thanks,

Regards

Hi, Could you provide a way to make the FFI loading dynamic? I would like to use this library https://github.com/rask/php-libload. Right now, I think I can extend your classes and override completely the ctor. But it's not really safe. Thanks, Regards
Nichlas Severinsen komentar 4 tahun lalu
Pemilik

It's been quite a while since I've touched this, but I thought this already did load the FFI dynamically?

Reading that library you linked to I see this:

In smaller projects with limited audiences these limitations might not matter. Or maybe the library you intend to use is a well-known and often preinstalled one (e.g. libc). But once you want to distribute public code that relies on a custom built FFI library, you're in trouble.

As you probably know, xxhash is rather similar to libc with it being packaged by most distros, so the libxxhash.so file usually ends up in /usr/lib/.

I'm not entirely sure what you want me to do, but maybe if you showed me some example code that you would like to work I could try to see if I'm able to fix this library so that it works. I'm also curious as to which limitations you are having.

It's been quite a while since I've touched this, but I thought this already did load the FFI dynamically? Reading that library you linked to I see this: > In smaller projects with limited audiences these limitations might not matter. Or maybe the library you intend to use is a well-known and often preinstalled one (e.g. libc). But once you want to distribute public code that relies on a custom built FFI library, you're in trouble. As you probably know, xxhash is rather similar to libc with it being packaged by most distros, so the libxxhash.so file usually ends up in /usr/lib/. I'm not entirely sure what you want me to do, but maybe if you showed me some example code that you would like to work I could try to see if I'm able to fix this library so that it works. I'm also curious as to which limitations you are having.
Gounlaf komentar 4 tahun lalu
Poster

Hi @necklace,

Thanks you for replying quickly :)

As the linked library says, sometimes the dynamic loading failed. I'm using php 7.4 via docker (image php:7.4-alpine).

I've installed libxxhash, libffi, enabled the extension. When constructing a XxHash64 object, it failed because it can't find the libxxhash.so (located in /usr/lib according to https://pkgs.alpinelinux.org/contents?branch=edge&name=libxxhash&arch=x86_64&repo=community) It's hard to dig and find if it's related to LD_LIBRARY_PATH or some other env variable.

I found rask/php-libload and I would try to fix the path temporary; but all your classes are final ; so I can't override ctor.

My request can be re-asked as :

Can you provide a way to customize the call to FFI::load ?

I will try to setup a bare project to reproduce the issue and share it here if it can help to understand the problem.

Thanks.

Hi @necklace, Thanks you for replying quickly :) As the linked library says, sometimes the dynamic loading failed. I'm using php 7.4 via docker (image php:7.4-alpine). I've installed libxxhash, libffi, enabled the extension. When constructing a XxHash64 object, it failed because it can't find the libxxhash.so (located in `/usr/lib` according to https://pkgs.alpinelinux.org/contents?branch=edge&name=libxxhash&arch=x86_64&repo=community) It's hard to dig and find if it's related to LD_LIBRARY_PATH or some other env variable. I found `rask/php-libload` and I would try to fix the path temporary; but all your classes are final ; so I can't override ctor. My request can be re-asked as : Can you provide a way to customize the call to FFI::load ? I will try to setup a bare project to reproduce the issue and share it here if it can help to understand the problem. Thanks.
Nichlas Severinsen komentar 4 tahun lalu
Pemilik

No problem!

I see, that makes sense. I'm thinking of adding php-libload as an optional dependency. In the meantime while I try to fix the code, could you try symlinking /usr/lib/libxxhash.so.0 to /usr/lib/libxxhash.so? Like so (with root):

ln -s /usr/lib/libxxhash.so.0 /usr/lib/libxxhash.so

Might be worth a shot.

Edit: tested it in an alpine vm, that solved it.

No problem! I see, that makes sense. I'm thinking of adding php-libload as an optional dependency. In the meantime while I try to fix the code, could you try symlinking /usr/lib/libxxhash.so.0 to /usr/lib/libxxhash.so? Like so (with root): ``` ln -s /usr/lib/libxxhash.so.0 /usr/lib/libxxhash.so ``` Might be worth a shot. Edit: tested it in an alpine vm, that solved it.
Nichlas Severinsen komentar 4 tahun lalu
Pemilik

@Gounlaf did you get it to work?

@Gounlaf did you get it to work?
Gounlaf komentar 4 tahun lalu
Poster

@necklace sorry didn't have time will try this we

@necklace sorry didn't have time will try this we
Masuk untuk bergabung dalam percakapan ini.
Tidak ada Label
Tidak ada tonggak
Tidak ada penerima
2 Peserta
Memuat...
Batal
Simpan
Belum ada konten.