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

Building V8JS on Debian 11 Bullseye (Docker/Laradock) #471

Closed jakedowns closed 2 years ago

jakedowns commented 3 years ago

Hello, taking a shot in the dark here, but I've been struggling for a few days to get the v8js extension & classes working properly in my Laradock php-fpm container.

Originally, it was on Debian 10, but through trial and error, I ended up needing to upgrade it to 11 to resolve an issue with libstdc++6 not including symbols for GLIBCXX_3.4.26 until the version of the package for Debian 11.

my current blocker is when i run make in the v8js directory, I get this error output:

/tmp/v8js/v8js_v8.cc:67:2: error: no matching function for call to 'v8::V8::InitializeExternalStartupData(const char [29], const char [30])'
   67 |  );

Not that I'd want to run it without snapshots, but I tried adding DV8_USE_SNAPSHOT=0. It did not prevent the above error.

./configure --with-v8js=/opt/v8 LDFLAGS="-lstdc++" CPPFLAGS="-DV8_COMPRESS_POINTERS -DV8_USE_SNAPSHOT=0"

So, this error is what happens when i try to compile with the recommended version of 8.0.426.30 in the Linux readme

Looking at the OmahaProxy, I see Linux Stable is currently using v8 version 9.4.146.21. When I compile that version of v8 and then try to make v8js, I get the same error.


If i try installing via pecl install v8js I get the following error:

configure: error: Please reinstall the v8 distribution ``` root@b977271ad17e:/tmp/v8# export PATH="/usr/include/nodejs/deps/v8/include/:$PATH" root@b977271ad17e:/tmp/v8# pecl install v8js downloading v8js-2.1.2.tgz ... Starting to download v8js-2.1.2.tgz (102,977 bytes) ........................done: 102,977 bytes 28 source files, building running: phpize Configuring for: PHP Api Version: 20190902 Zend Module Api No: 20190902 Zend Extension Api No: 320190902 Please provide the installation prefix of libv8 [autodetect] : /usr/include/nodejs/deps/v8/include/ building in /tmp/pear/temp/pear-build-defaultuservYUUjj/v8js-2.1.2 running: /tmp/pear/temp/v8js/configure --with-php-config=/usr/local/bin/php-config --with-v8js=/usr/include/nodejs/deps/v8/include/ checking for grep that handles long lines and -e... /bin/grep checking for egrep... /bin/grep -E checking for a sed that does not truncate output... /bin/sed checking for pkg-config... /usr/bin/pkg-config checking pkg-config is at least version 0.9.0... yes checking for cc... cc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether cc accepts -g... yes checking for cc option to accept ISO C89... none needed checking how to run the C preprocessor... cc -E checking for icc... no checking for suncc... no checking for system library directory... lib checking if compiler supports -R... no checking if compiler supports -Wl,-rpath,... yes checking build system type... x86_64-pc-linux-gnu checking host system type... x86_64-pc-linux-gnu checking target system type... x86_64-pc-linux-gnu checking for PHP prefix... /usr/local checking for PHP includes... -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib checking for PHP extension directory... /usr/local/lib/php/extensions/no-debug-non-zts-20190902 checking for PHP installed headers prefix... /usr/local/include/php checking if debug is enabled... no checking if zts is enabled... no checking for gawk... no checking for nawk... nawk checking if nawk is broken... no checking for V8 Javascript Engine... yes, shared checking for V8 files in default path... not found configure: error: Please reinstall the v8 distribution ERROR: `/tmp/pear/temp/v8js/configure --with-php-config=/usr/local/bin/php-config --with-v8js=/usr/include/nodejs/deps/v8/include/' failed root@b977271ad17e:/tmp/v8# ```

On debian 11, libv8-dev remaps to libnode-dev Libnode-dev seems to have v8 header files in this directory: /usr/include/nodejs/deps/v8/include/

Tho, even if I export that directory in my $PATH variable: export PATH="/usr/include/nodejs/deps/v8/include/:$PATH" pecl install script still says i need to reinstall v8 dist

I'll update this ticket as I continue to work through the issue.


update: using dpkg -L libnode-dev | grep v8 I found the libv8.so file is installed to: /usr/lib/x86_64-linux-gnu/ so, if I export THAT to my path export PATH="/usr/lib/x86_64-linux-gnu:$PATH" and then run pecl install v8js and tell it libv8 prefix is /usr/lib/x86_64-linux-gnu/ I still get:

checking for V8 Javascript Engine... yes, shared
checking for V8 files in default path... not found
configure: error: Please reinstall the v8 distribution

I wonder tho, if it's because libnode-dev just does a symlink to libnode.so ? lrwxrwxrwx 1 root root 10 Aug 11 19:06 libv8.so -> libnode.so


Update: finally got configure to run.

basically i cleared out /opt/v8/lib/ & /opt/v8/include/

then, I used cp -Lr (L flag to dereference the symbolic link) to copy all the libv8.so files from libnode-dev `cp -Lr /usr/lib/x86_64-linux-gnu/libv8.so /opt/v8/include`

then, since it didn't look like libnode-dev installed the needed blob.bin files, I copied those from my failed build of v8 `cp out.gn/x64.release/lib.so out.gn/x64.release/*_blob.bin out.gn/x64.release/icudtl.dat /opt/v8/lib/` (hopefully they still work)

so, then I run Make and it completes with only warnings, no errors. But then I run make test, and all but 3 fail.


ugh, i forgot to run make clean last time, so i may have gotten a false negative. whatever. ran make clean and now i'm trying to rebuild from scratch with 7.8.279 which is the version of v8 that libnode-dev uses Result: 47 tests pass, 128 tests failing

redbullmarky commented 2 years ago

Closing this one now as V8 9.x+ is now required.

juan-morales commented 2 years ago

Closing this one now as V8 9.x+ is now required.

I am having problems installing libv8 version 9 or greater for Debian Bullseye ... I dont understand how to do such a thing actually.

Maybe is easy peace , can someone help me out?