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

v8js.so with static version of libv8 #89

Closed carlos22 closed 10 years ago

carlos22 commented 10 years ago

Is it possible to use a static build of the libv8 to build php-v8js. This would be very useful as the required libv8 version is not even included in recent linux distributions (like Ubuntu 14.04). Therefore a simple installation via pecl or similar is not possible.

stesie commented 10 years ago

I agree that it is a pity that php-v8js only supports pretty recent v8 versions. The number of supported versions could be enlarged, however this is tedious since the v8 internal api is changed pretty regularly

Contrary building against a statically linked v8 version is problematic as well, since v8 doesn't support such a build out of the box. Hence you have to fiddle the build systems of both v8 and php-v8js.

Depends on whether you'd like to package the extension; if not it's probably best to rpath link the shared library installed to some non-standard directory. This is, just compile v8 as a shared library and copy library & header files to /opt or /usr/local/v8-something; the pass the --with-v8js option to configure (which triggers a rpath build)

cheers stesie

carlos22 commented 10 years ago

Thanks for your reply. According to the v8 devs static builds are the default. In a google groups thread they discuss how to do a static link. Chrome/Chromium also seems to use v8 static. But as Chromium also uses the GYP buildsystem they just need to say "require v8" and it "just works". There is also a gem (ruby) which provides static builds of libv8 as dependency for ruby projects (mainly therubyracer - v8js for ruby).

For now I will use the non-standard path shard lib method, as it works quite well. If I find some spare time, I may try to build against the static .a files...

stesie commented 10 years ago

The difference to chrome is, that chrome is an executable while v8js is a shared library that is dynamically loaded into PHP.

It should theoretically be possible to statically link PHP with V8Js and V8, but I would consider this out of scope of this project.

cheers ~stesie

refs #114