From 14600d3be3b38b822c56d993347e8c88522039af Mon Sep 17 00:00:00 2001 From: Stefan Siegl Date: Wed, 17 Sep 2014 00:45:24 +0200 Subject: [PATCH] Initialize v8 platform as needed See http://comments.gmane.org/gmane.comp.lang.javascript.v8.general/8029 for more information. --- README.md | 3 ++- config.m4 | 24 ++++++++++++++++++++++++ v8js.cc | 6 ++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6c58c60..3912a6f 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,8 @@ make dependencies make native library=shared -j8 sudo mkdir -p /usr/lib /usr/include sudo cp out/native/lib.target/lib*.so /usr/lib/ -sudo cp include/v8* /usr/include +sudo cp out/native/obj.target/tools/gyp/libv8_libplatform.a /usr/lib +sudo cp -R include/v8* /usr/include ``` diff --git a/config.m4 b/config.m4 index 4baa05a..790b127 100644 --- a/config.m4 +++ b/config.m4 @@ -89,6 +89,30 @@ AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], LDFLAGS=$old_LDFLAGS CPPFLAGS=$old_CPPFLAGS + if test "$V8_API_VERSION" -ge 3029036 ; then + dnl building for v8 3.29.36 or later, which requires us to + dnl initialize and provide a platform; hence we need to + dnl link in libplatform to make our life easier. + PHP_ADD_INCLUDE($V8_DIR) + + SEARCH_FOR="lib/libv8_libplatform.a" + AC_MSG_CHECKING([for libv8_libplatform.a]) + + for i in $PHP_V8JS $SEARCH_PATH ; do + echo $i/$SEARCH_FOR + if test -r $i/$SEARCH_FOR; then + LIBPLATFORM_DIR=$i + AC_MSG_RESULT(found in $i) + fi + done + + if test -z "$LIBPLATFORM_DIR"; then + AC_MSG_RESULT([not found]) + AC_MSG_ERROR([Please provide libv8_libplatform.a next to the libv8.so, see README.md for details]) + fi + + LDFLAGS="$LDFLAGS $LIBPLATFORM_DIR/$SEARCH_FOR" + fi AC_CACHE_CHECK(for C standard version, ac_cv_v8_cstd, [ ac_cv_v8_cstd="c++11" diff --git a/v8js.cc b/v8js.cc index 04d05b3..13b301f 100644 --- a/v8js.cc +++ b/v8js.cc @@ -20,6 +20,7 @@ #endif #include +#include #include "php_v8js_macros.h" @@ -857,6 +858,11 @@ static void php_v8js_init(TSRMLS_D) /* {{{ */ return; } +#if PHP_V8_API_VERSION >= 3029036 + v8::Platform* platform = v8::platform::CreateDefaultPlatform(); + v8::V8::InitializePlatform(platform); +#endif + /* Set V8 command line flags (must be done before V8::Initialize()!) */ if (V8JSG(v8_flags)) { v8::V8::SetFlagsFromString(V8JSG(v8_flags), strlen(V8JSG(v8_flags)));