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

Errors when build v8js #418

Closed pogor closed 2 years ago

pogor commented 5 years ago

Hi! I get some errors when I build v8js:

os: ubuntu 18.04 php: 7.3 lib v8: latest error:

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:7941: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:2547:8: note: candidate: bool v8::Value::BooleanValue(v8::Isolate*) const
   bool BooleanValue(Isolate* isolate) const;
        ^~~~~~~~~~~~
/opt/v8/include/v8.h:2547: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

os: ubuntu 18.04 php: 7.2 lib v8: 6.9.427.18 or 6.9.454 error:

In file included from /tmp/v8js/php_v8js_macros.h:52:0,
                 from /tmp/v8js/v8js_class.cc:22:
/opt/v8/include/v8.h:3377:37: note: declared here
   V8_WARN_UNUSED_RESULT Maybe<bool> CreateDataProperty(Local<Context> context,
                                     ^~~~~~~~~~~~~~~~~~
/tmp/v8js/v8js_class.cc: In function ‘int v8js_register_extension(zend_string*, zend_string*, zval*, zend_bool)’:
/tmp/v8js/v8js_class.cc:1070:65: error: cannot convert ‘std::unique_ptr<v8::Extension>’ to ‘v8::Extension*’ for argument ‘1’ to ‘void v8::RegisterExtension(v8::Extension*)’
  v8::RegisterExtension(std::unique_ptr<v8::Extension>(extension));
                                                                 ^
/tmp/v8js/v8js_class.cc: In function ‘void v8js_write_property(zval*, zval*, zval*, void**)’:
/tmp/v8js/v8js_class.cc:1331:87: warning: ignoring return value of ‘v8::Maybe<bool> v8::Object::DefineOwnProperty(v8::Local<v8::Context>, v8::Local<v8::Name>, v8::Local<v8::Value>, v8::PropertyAttribute)’, declared with attribute warn_unused_result [-Wunused-result]
   jsobj->DefineOwnProperty(v8_context, key, zval_to_v8js(value, isolate), v8::ReadOnly);
                                                                                       ^
In file included from /tmp/v8js/php_v8js_macros.h:52:0,
                 from /tmp/v8js/v8js_class.cc:22:
/opt/v8/include/v8.h:3390:37: note: declared here
   V8_WARN_UNUSED_RESULT Maybe<bool> DefineOwnProperty(
                                     ^~~~~~~~~~~~~~~~~
/tmp/v8js/v8js_class.cc: In function ‘void v8js_unset_property(zval*, zval*, void**)’:
/tmp/v8js/v8js_class.cc:1355:31: warning: ignoring return value of ‘v8::Maybe<bool> v8::Object::Delete(v8::Local<v8::Context>, v8::Local<v8::Value>)’, declared with attribute warn_unused_result [-Wunused-result]
  jsobj->Delete(v8_context, key);
                               ^
In file included from /tmp/v8js/php_v8js_macros.h:52:0,
                 from /tmp/v8js/v8js_class.cc:22:
/opt/v8/include/v8.h:3452:37: note: declared here
   V8_WARN_UNUSED_RESULT Maybe<bool> Delete(Local<Context> context,
                                     ^~~~~~
Makefile:210: recipe for target 'v8js_class.lo' failed
make: *** [v8js_class.lo] Error 1

Can you help me fix this problems?

AdemJensen commented 5 years ago

I'm getting the same result, wonder if something wrong...

AdemJensen commented 5 years ago

If you choose to build the older version (2.1.0), it won't produce any error messages (Only warning) and it is able to use, try it out!

pogor commented 5 years ago

Thank you! I compile version v8 from issue#419 - 7.5.289. It's works!

stesie commented 5 years ago

I'm confused, is there a problem now or isn't there? Have you tried to build V8 6.9 with most recent php-v8js initially and that failed? Or what's wrong?

mkummer225 commented 5 years ago

@stesie I'm getting a similar build error as op when trying to build latest 2.1.1 release (php7.2, Ubuntu 16.04, libv8 compiled to latest via README.Linux.md):

Error specifics:

/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/20170718 -I/usr/include/php/20170718/main -I/usr/include/php/20170718/TSRM -I/usr/include/php/20170718/Zend -I/usr/include/php/20170718/ext -I/usr/include/php/20170718/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/20170718 -I/usr/include/php/20170718/main -I/usr/include/php/20170718/TSRM -I/usr/include/php/20170718/Zend -I/usr/include/php/20170718/ext -I/usr/include/php/20170718/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
/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: 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:102: 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);
                                                                                                      ^
make: *** [v8js_convert.lo] Error 1
mkummer225 commented 5 years ago

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

kervinpierre commented 5 years ago

FYI. 2.1.1 requires V8 > 6.9

It would help with autoconf detected the libv8 version and failed if it wasn't compatible.

kervinpierre commented 5 years ago

I'm running into a ld link bug with g++: https://github.com/v8/v8/commit/3b8c624bda58d05aea80dd9626cd550537d6ac3f#diff-1dd7b6eaeebb8457fcb57aa637f469dc

To those who got 7.5 built, are you using g++ or clang?