phpv8 / v8js

V8 Javascript Engine for PHP — This PHP extension embeds the Google V8 Javascript Engine
http://pecl.php.net/package/v8js
MIT License
1.84k stars 200 forks source link

could not find libv8_libplatform library on version Above 2.1.0 #397

Closed grimpows closed 2 years ago

grimpows commented 5 years ago

Hey i'm using docker for get a php7.2-fpm with v8js, some time ago i have build the image and everything worked fine, 2 day ago i rebuild it and the build failed.

After a lot of research, the problem came from the fact that the latest version of v8js (php7) dont find the libv8_libplatform.so library while he find it if i just "git checkout 2.1.0" before use the command ./configure --with-v8js=/opt/v8 LDFLAGS="-lstdc++"

i follow the installation step from https://github.com/phpv8/v8js/blob/php7/README.Linux.md

treyhan commented 5 years ago

I ran into this same problem few days ago. Linker can't find NewDefaultPlatform implementation which is now used instead of deprecated CreateDefaultPlatform used by 2.1.0. This causes the slightly misleading _libv8libplatform.so not found error message to appear.

Solution for this - at least working for me - is to use _use_customlibcxx=false with v8gen like this: tools/dev/v8gen.py -vv x64.release -- is_component_build=true use_custom_libcxx=false

Without _use_customlibcxx=false v8 build uses inline namespace Cr inside std, and symbol for the function in libv8_libplatform.so ends up to be: **v8::platform::NewDefaultPlatform(int, v8::platform::IdleTaskSupport, v8::platform::InProcessStackDumping, std::__Cr::unique_ptr<v8::TracingController, std::Cr::default_delete >)**

As linker is not searching symbol with __Cr namespace, it fails to find what it's looking for.

With _use_customlibcxx=false the inline namespace is not used, and symbol is what linker looks for and everything goes fine: v8::platform::NewDefaultPlatform(int, v8::platform::IdleTaskSupport, v8::platform::InProcessStackDumping, std::unique_ptr<v8::TracingController, std::default_delete >)

Hopefully this helps!

grimpows commented 5 years ago

I'll let this a try (mean rebuild v8 haha) and may the doc should be updated, (by specify the checkout requierement to 2.1.0 or your solution for use the "latest" v8js, but as there is no release above 2.1.0 yet, may the detection of the __Cr will be implemented on newer version or the use_custom_libcxx=false requierement will be added to the doc for version > 2.1.0.

GytisT commented 5 years ago

@grimpows I was solving the same issue for like 3 days and actually what solved for me is compiling v8 with different params.

Take a look at my php-7.3.1-fpm-v8js dockerfile:

https://hub.docker.com/r/gytist/php-fpm-v8js

vietnguyen09 commented 5 years ago

@grimpows I was solving the same issue for like 3 days and actually what solved for me is compiling v8 with different params.

Take a look at my php-7.3.1-fpm-v8js dockerfile:

https://hub.docker.com/r/gytist/php-fpm-v8js

I'm tried but not work for me. Centos 7, PHP 7.1

GytisT commented 5 years ago

@vietnguyen09

If you're using official php-fpm image don't forget to install patchelf and run it to correct RPATH of built v8 lib like so:

for A in /opt/libv8-7.4/lib/*.so; do patchelf --set-rpath '$ORIGIN' $A;done

stesie commented 5 years ago

The hint on use_custom_libcxx=false flag was added to instructions via PR #405

MicroDreamIT commented 5 years ago

seems like a hard solution.

stesie commented 5 years ago

@MicroDreamIT this might very well be the case. However noone came up with a better solution since March so far; ... still, if someone does we can still remove the note. So far it's probably easier for many if they find the hint in the README, without going through the issues here

florinShm commented 5 years ago

If custom_libcxx is preferred you can pass LIBCPP_ABI_VERSION to the libc++ generated by v8: ./configure CXXFLAGS="-D_LIBCPP_ABI_UNSTABLE -D_LIBCPP_ABI_VERSION=Cr -std=c++11 -nostdinc++ -isystem../v8/buildtools/third_party/libc++/trunk/include", where -isystem points to the include path in the v8 libc++ folder.