-
-
Save aozisik/a522e3b602daff6ae51f134aa949eec9 to your computer and use it in GitHub Desktop.
# This will retrieve v8 7.4.288.25 when installled | |
wget https://raw.githubusercontent.com/Homebrew/homebrew-core/0a6171330678879285f2c566db9349da421d6f62/Formula/v8.rb | |
brew install v8.rb | |
brew list v8 | |
# You will see this: | |
# /usr/local/Cellar/v8/7.4.288.25/bin/d8 | |
# /usr/local/Cellar/v8/7.4.288.25/libexec/include/ (21 files) | |
# /usr/local/Cellar/v8/7.4.288.25/libexec/ (7 files) | |
mkdir -p /usr/local/Cellar/v8/7.4.288.25/libexec/lib | |
cp /usr/local/Cellar/v8/7.4.288.25/libexec/* /usr/local/Cellar/v8/7.4.288.25/libexec/lib | |
# Ignore the following errors, everything is fine: | |
# cp: /usr/local/Cellar/v8/7.4.288.25/libexec/include is a directory (not copied). | |
# cp: /usr/local/Cellar/v8/7.4.288.25/libexec/lib is a directory (not copied). | |
cd /tmp | |
git clone https://github.com/phpv8/v8js | |
cd v8js | |
git checkout php7 | |
phpize | |
./configure CXXFLAGS="-Wno-c++11-narrowing" --with-v8js="/usr/local/Cellar/v8/7.4.288.25/libexec" | |
make | |
make test | |
# Make sure that make test succeeds | |
make install | |
# Expected output: | |
# Installing shared extensions: /usr/local/Cellar/[email protected]/7.2.18/pecl/20170718/ | |
# Check if it's already working: | |
php -m | grep v8js | |
# No? It's not there? | |
# You may need to add v8js.so to your php.ini | |
# Locate your php.ini by doing: | |
php --ini | |
# Open the file and add: extension="v8js.so" | |
# Enjoy! | |
# Guys/gals... This took >4 hours to get right. | |
# | |
# Here are some troubleshooting checklist in case you're getting errors: | |
# | |
# - Make sure you have no other v8 libraries lying around your system. Get rid of those first! | |
# - Run apt-get update and upgrade before running this. Obviously... | |
# - I got v8js-2.0.0 working against 6.4.388.18. Never got it to work against v8-7.x... | |
# - Don't even try apt-get install libv8-7.2. Lost hours, couldn't get it to work... Just compile yourself... | |
# Install required dependencies | |
apt-get install build-essential curl git python libglib2.0-dev | |
cd /tmp | |
# Install depot_tools first (needed for source checkout) | |
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git | |
export PATH=`pwd`/depot_tools:"$PATH" | |
# Download v8 | |
fetch v8 | |
cd v8 | |
# I needed this to make it work with PHP 7.1 | |
git checkout 6.4.388.18 | |
gclient sync | |
# Setup GN | |
tools/dev/v8gen.py -vv x64.release -- is_component_build=true | |
# Build | |
ninja -C out.gn/x64.release/ | |
# Move libraries to necessary location | |
cp out.gn/x64.release/lib*.so /usr/lib/ | |
cp out.gn/x64.release/*_blob.bin /usr/lib | |
cp out.gn/x64.release/icudtl.dat /usr/lib | |
cp -R include/* /usr/include | |
cd out.gn/x64.release/obj | |
ar rcsDT libv8_libplatform.a v8_libplatform/*.o | |
# Are you getting v8 (library) not found error? Try this before pecl install: | |
apt-get install patchelf | |
for A in /usr/lib/*.so; do patchelf --set-rpath '$ORIGIN' $A;done | |
# Then let's pull v8js. | |
cd /tmp | |
git clone https://github.com/phpv8/v8js.git | |
cd v8js | |
# Checkout version 2.1.0 | |
git checkout 2.1.0 | |
phpize | |
# This flag is important! | |
./configure LDFLAGS="-lstdc++" --with-v8js=/usr | |
make clean | |
make | |
# Make sure that the tests pass... | |
make test | |
make install | |
# DON'T FORGET TO Add | |
# extension=v8js.so | |
# To your php.ini as needed. | |
# You can check if the module is there by doing php -m | grep v8js |
Could you please update your script on this?
I'm still having errors on the compilation, despite following your script as of now.
Does it works with PHP7.2 only or is PHP7.3 also included?
Why haven't you included gcc+, etc.
Because I've launched the script directly after installing my VPS, on the assumption that everything was already there.
Could you please update your script on this?
I'm still having errors on the compilation, despite following your script as of now.
Does it works with PHP7.2 only or is PHP7.3 also included?
Why haven't you included gcc+, etc.
Because I've launched the script directly after installing my VPS, on the assumption that everything was already there.
It's something that worked for me. Sorry that it didn't work for you.
What's your setup (distro version) ? And what error did you get?
I received this error, after everything went well, and all I had to do, in order to complet the case, was to execute make
&& make test
&& make install
.
/bin/bash /tmp/v8js/libtool --mode=compile g++ -Wno-narrowing -std=c++11 -I. -I/tmp/v8js -DPHP_ATOM_INC -I/tmp/v8js/include -I/tmp/v8js/main -I/tmp/v8js -I/usr/include/php/20180731 -I/usr/include/php/20180731/main -I/usr/include/php/20180731/TSRM -I/usr/include/php/20180731/Zend -I/usr/include/php/20180731/ext -I/usr/include/php/20180731/ext/date/lib -I/opt/v8/include -I/opt/v8 -DHAVE_CONFIG_H -g -O2 -c /tmp/v8js/v8js_convert.cc -o v8js_convert.lo
libtool: compile: g++ -Wno-narrowing -std=c++11 -I. -I/tmp/v8js -DPHP_ATOM_INC -I/tmp/v8js/include -I/tmp/v8js/main -I/tmp/v8js -I/usr/include/php/20180731 -I/usr/include/php/20180731/main -I/usr/include/php/20180731/TSRM -I/usr/include/php/20180731/Zend -I/usr/include/php/20180731/ext -I/usr/include/php/20180731/ext/date/lib -I/opt/v8/include -I/opt/v8 -DHAVE_CONFIG_H -g -O2 -c /tmp/v8js/v8js_convert.cc -fPIC -DPIC -o .libs/v8js_convert.o
Makefile:214: recipe for target 'v8js_convert.lo' failed
dark-aii@vps12345:/tmp/v8js$ make
/bin/bash /tmp/v8js/libtool --mode=compile g++ -Wno-narrowing -std=c++11 -I. -I/tmp/v8js -DPHP_ATOM_INC -I/tmp/v8js/include -I/tmp/v8js/main -I/tmp/v8js -I/usr/include/php/20180731 -I/usr/include/php/20180731/main -I/usr/include/php/20180731/TSRM -I/usr/include/php/20180731/Zend -I/usr/include/php/20180731/ext -I/usr/include/php/20180731/ext/date/lib -I/opt/v8/include -I/opt/v8 -DHAVE_CONFIG_H -g -O2 -c /tmp/v8js/v8js_convert.cc -o v8js_convert.lo
libtool: compile: g++ -Wno-narrowing -std=c++11 -I. -I/tmp/v8js -DPHP_ATOM_INC -I/tmp/v8js/include -I/tmp/v8js/main -I/tmp/v8js -I/usr/include/php/20180731 -I/usr/include/php/20180731/main -I/usr/include/php/20180731/TSRM -I/usr/include/php/20180731/Zend -I/usr/include/php/20180731/ext -I/usr/include/php/20180731/ext/date/lib -I/opt/v8/include -I/opt/v8 -DHAVE_CONFIG_H -g -O2 -c /tmp/v8js/v8js_convert.cc -fPIC -DPIC -o .libs/v8js_convert.o
In file included from /usr/include/dirent.h:245:0,
from /usr/include/php/20180731/Zend/zend_virtual_cwd.h:76,
from /usr/include/php/20180731/main/php.h:467,
from /tmp/v8js/php_v8js_macros.h:42,
from /tmp/v8js/v8js_convert.cc:22:
/tmp/v8js/v8js_class.h: In function ‘v8js_ctx* v8js_ctx_fetch_object(zend_object*)’:
/tmp/v8js/v8js_class.h:83:54: warning: offsetof within non-standard-layout type ‘v8js_ctx’ is undefined [-Winvalid-offsetof]
return (struct v8js_ctx *)((char *)obj - XtOffsetOf(struct v8js_ctx, std));
/tmp/v8js/v8js_class.h:83:43: note: in expansion of macro ‘XtOffsetOf’
return (struct v8js_ctx *)((char *)obj - XtOffsetOf(struct v8js_ctx, std));
^~~~~~~~~~
/tmp/v8js/v8js_convert.cc: In function ‘v8::Local<v8::Value> v8js_hash_to_jsarr(zval*, v8::Isolate*)’:
/tmp/v8js/v8js_convert.cc:82:65: warning: ‘v8::Local<v8::Context> v8::Isolate::GetEnteredContext()’ is deprecated: Use GetEnteredOrMicrotaskContext(). [-Wdeprecated-declarations]
v8::Local<v8::Context> v8_context = isolate->GetEnteredContext();
^
In file included from /opt/v8/include/v8-internal.h:14:0,
from /opt/v8/include/v8.h:25,
from /tmp/v8js/php_v8js_macros.h:52,
from /tmp/v8js/v8js_convert.cc:22:
/opt/v8/include/v8.h:8007:32: note: declared here
Local<Context> GetEnteredContext());
^
/opt/v8/include/v8config.h:311:3: note: in definition of macro ‘V8_DEPRECATED’
declarator __attribute__((deprecated(message)))
^~~~~~~~~~
/tmp/v8js/v8js_convert.cc:100:64: warning: ignoring return value of ‘v8::Maybe<bool> v8::Object::Set(v8::Local<v8::Context>, uint32_t, v8::Local<v8::Value>)’, declared with attribute warn_unused_result [-Wunused-result]
newarr->Set(v8_context, index++, zval_to_v8js(data, isolate));
^
In file included from /tmp/v8js/php_v8js_macros.h:52:0,
from /tmp/v8js/v8js_convert.cc:22:
/opt/v8/include/v8.h:3330:37: note: declared here
V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context, uint32_t index,
^~~
/tmp/v8js/v8js_convert.cc: In function ‘v8::Local<v8::Value> zval_to_v8js(zval*, v8::Isolate*)’:
/tmp/v8js/v8js_convert.cc:152:48: warning: ‘v8::Local<v8::Context> v8::Isolate::GetEnteredContext()’ is deprecated: Use GetEnteredOrMicrotaskContext(). [-Wdeprecated-declarations]
v8::Date::New(isolate->GetEnteredContext(), ((double)Z_LVAL(dtval) * 1000.0)).ToLocal(&jsValue);
^
In file included from /opt/v8/include/v8-internal.h:14:0,
from /opt/v8/include/v8.h:25,
from /tmp/v8js/php_v8js_macros.h:52,
from /tmp/v8js/v8js_convert.cc:22:
/opt/v8/include/v8.h:8007:32: note: declared here
Local<Context> GetEnteredContext());
^
/opt/v8/include/v8config.h:311:3: note: in definition of macro ‘V8_DEPRECATED’
declarator __attribute__((deprecated(message)))
^~~~~~~~~~
/tmp/v8js/v8js_convert.cc: In function ‘int v8js_to_zval(v8::Local<v8::Value>, zval*, int, v8::Isolate*)’:
/tmp/v8js/v8js_convert.cc:215:59: error: no matching function for call to ‘v8::Value::BooleanValue(v8::Local<v8::Context>&)’
v8::Maybe<bool> value = jsValue->BooleanValue(v8_context);
^
In file included from /tmp/v8js/php_v8js_macros.h:52:0,
from /tmp/v8js/v8js_convert.cc:22:
/opt/v8/include/v8.h:2551:8: note: candidate: bool v8::Value::BooleanValue(v8::Isolate*) const
bool BooleanValue(Isolate* isolate) const;
^~~~~~~~~~~~
/opt/v8/include/v8.h:2551:8: note: no known conversion for argument 1 from ‘v8::Local<v8::Context>’ to ‘v8::Isolate*’
/tmp/v8js/v8js_convert.cc: In function ‘v8::Local<v8::Value> zval_to_v8js(zval*, v8::Isolate*)’:
/tmp/v8js/v8js_convert.cc:152:92: warning: ignoring return value of ‘bool v8::MaybeLocal<T>::ToLocal(v8::Local<S>*) const [with S = v8::Value; T = v8::Value]’, declared with attribute warn_unused_result [-Wunused-result]
v8::Date::New(isolate->GetEnteredContext(), ((double)Z_LVAL(dtval) * 1000.0)).ToLocal(&jsValue);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
Makefile:214: recipe for target 'v8js_convert.lo' failed
make: *** [v8js_convert.lo] Error 1
The checkout git checkout 6.4.388.18
had been outdaded, so I didn't execute it. And no errors has shown either, so I made the right chice.
@Dark-Aii Read this. It may help solve your problem and anyone elses:
Figured it out - wrong libv8 version:
checking for libv8_libplatform... found
checking for V8 version... 5.2.371
configure: WARNING: libv8 prior to 6.4.388.18 is missing speculative execution mitigations
My assumption was that leaving out the optional commands (from README.Linux.md) would build the latest v8 (7.5+ for ex.) - but that's not the case and it ends up building 5.2:
(optional) If you'd like to build a certain version:
git checkout 6.4.388.18
gclient sync
I've added the following commands and everything worked great (7.5.288.30 was latest stable via https://omahaproxy.appspot.com/ when I checked):
git checkout 7.5.288.30
gclient sync
Since v8js requires 6.9+ now maybe update the README.*.md's to direct users to install a version of v8 compatible with v8js? 6.9.427.18, 7.5.288.30 or otherwise?
Similar issue #421 from a couple days ago when trying to use the 6.4.388.18 version called out in README.Linux.md
@ss03 I'm familiar with this error, but don't know exactly what caused it. It's either your v8 version or you're not following the gist step by step. Make sure you get rid of all the pre-existing v8 versions and install the versions that I point out in the gist. Wish you lots of luck
Thanks a lot.
It worked.
I ran phpize command before ./configure LDFLAGS="-lstdc++" --with-v8js=/usr.
Hope it helps others.
Regards
@Dark-Aii Read this. It may help solve your problem and anyone elses:
Figured it out - wrong libv8 version:
checking for libv8_libplatform... found
checking for V8 version... 5.2.371
configure: WARNING: libv8 prior to 6.4.388.18 is missing speculative execution mitigations
My assumption was that leaving out the optional commands (from README.Linux.md) would build the latest v8 (7.5+ for ex.) - but that's not the case and it ends up building 5.2:(optional) If you'd like to build a certain version:
git checkout 6.4.388.18
gclient sync
I've added the following commands and everything worked great (7.5.288.30 was latest stable via https://omahaproxy.appspot.com/ when I checked):git checkout 7.5.288.30
gclient sync
Since v8js requires 6.9+ now maybe update the README.*.md's to direct users to install a version of v8 compatible with v8js? 6.9.427.18, 7.5.288.30 or otherwise?Similar issue #421 from a couple days ago when trying to use the 6.4.388.18 version called out in README.Linux.md
#For PHP 7.3
#use V8js version 2.1.1 instead of 2.1.0. and v8 version 7.5.288.30
git checkout 6.4.388.18 -> git checkout 7.5.288.30
git checkout 2.1.0 -> git checkout 2.1.1
#Tested on Ubuntu 18.04
I'm facing issue to configuring v8js on mac and ubuntu 18
Can you help out to figure out this issue
checking how to allow c++11 narrowing... -Wno-c++11-narrowing
checking for libv8_libplatform... configure: error: could not find libv8_libplatform library
Just wanted to say thank you. After days of struggling with installing this shitload of a software, this is the first tutorial that finally worked. It even installed no problem on the M1 mac mini (using Rosetta2). You are my hero!
@KarimGeiger I'm on M1 mac mini as well stuck on
v8: Calling
cellar
in a bottle block is disabled! Usebrew style --fix
on the formula to update the style or usesha256
with acellar:
argument instead.
How do you manage to make it work? Thanks.
@jbrtsnts I didn't get that error message at all, so I don't know how to fix that. But I ran it using Rosetta 2, so prefixing every command with arch -x86_64
to run it on the x86 architecture, instead of ARM. Maybe that helps.
@KarimGeiger, I finally got it working. The formula is not working anymore, and only have to go with the latest version - 9.1.269.36 at the time of this comment. Thanks anyway for the quick response!
@ss03 I'm familiar with this error, but don't know exactly what caused it. It's either your v8 version or you're not following the gist step by step. Make sure you get rid of all the pre-existing v8 versions and install the versions that I point out in the gist. Wish you lots of luck