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.83k stars 200 forks source link

Windows VC14 PHP7 extension available #210

Closed Jan-E closed 8 years ago

Jan-E commented 8 years ago

I have included php_v8js.dll in my regular builds of PHP7 for Windows: https://www.apachelounge.com/viewtopic.php?t=6359

This is with V8 version 4.7.80.32, as you can see in the phpinfo() dump: https://phpdev.toolsforresearch.com/php-7.0.4-Win32-VC14-x64.htm

If anyone knows how to compile V8 version 5.x with VC14, I could upgrade as well.

Jan-E commented 8 years ago

I managed to compile V8 version 5.1.0 (candidate) with VC14.

Moreover, I changed config.w32 to parse v8-version.h and use those values for PHP_V8_API_VERSION and PHP_V8_VERSION. A pull request is in the making.

Jan-E commented 8 years ago

https://github.com/phpv8/v8js/pull/212 (master branch) https://github.com/phpv8/v8js/pull/213 (php7 branch)

will result in things like: capture

stesie commented 8 years ago

Thanks for pushing forward on V8 on Windows! :-)

... I haven't compiled it on Windows for a while ... so does the README file (https://github.com/phpv8/v8js/blob/php7/README.Win32.md) still apply? Or has it changed since the 5.x branch in some way?

Besides that I think you shouldn't use V8 5.1 (which currently has "canary" status) in production, and having pre-built packages misleads to that a bit ... See https://omahaproxy.appspot.com/ for which V8 version is beta or stable. That said I would use the latest version from the 4.9 branch.

Last not least, could you please provide your x86 build results of V8 (headers, dlls including *.lib) for use with AppVeyor (either privately to me once, or $somewhere AppVeyor could download it from). I've built V8 4.7 on Windows and accidentally deleted the files (that's why AppVeyor currently reports a broken build). But I have no Windows box around, hence I always resort to an EC2 box otherwise ...

Jan-E commented 8 years ago

I did a 'git pull', 'git checkout 4.9.385.29' on V8 now, then a 'gclient sync' and am building the x86 libs with

set DEPOT_TOOLS_WIN_TOOLCHAIN=0
python build\gyp_v8 -Dcomponent=shared_library -Dv8_use_snapshot=0 
perl -pi.bak -e "s/AsError>true/AsError>false/gi" tools\gyp\v8_base_0.vcxproj
perl -pi.bak -e "s/AsError>true/AsError>false/gi" tools\gyp\v8_base_1.vcxproj
perl -pi.bak -e "s/AsError>true/AsError>false/gi" tools\gyp\v8_base_2.vcxproj
perl -pi.bak -e "s/AsError>true/AsError>false/gi" tools\gyp\v8_base_3.vcxproj
perl -pi.bak -e "s/AsError>true/AsError>false/gi" tools\gyp\v8_nosnapshot.vcxproj
perl -pi.bak -e "s/<\/DebugInformationFormat>/<\/DebugInformationFormat>\n      <ProgramDataBaseFileName>\$\(OutDir)\\lib\\\$\(ProjectName)lib.pdb<\/ProgramDataBaseFileName>/gi" tools\gyp\v8.vcxproj
perl -pi.bak -e "s/<\/DebugInformationFormat>/<\/DebugInformationFormat>\n      <ProgramDataBaseFileName>\$\(OutDir)\\lib\\\$\(ProjectName).pdb<\/ProgramDataBaseFileName>/gi" tools\gyp\v8_libbase.vcxproj
perl -pi.bak -e "s/<\/DebugInformationFormat>/<\/DebugInformationFormat>\n      <ProgramDataBaseFileName>\$\(OutDir)\\lib\\\$\(ProjectName).pdb<\/ProgramDataBaseFileName>/gi" tools\gyp\v8_libplatform.vcxproj
if exist tools\gyp\v8_base_?.vcxproj.bak del tools\gyp\v8_base_?.vcxproj.bak
call msbuild build\All.sln /m /p:Configuration=Release /p:Platform=Win32
cd build\release
unittests
hello-world
cd ..\..

The changes in the v8base*.vcxproj files are needed to avoid that VC14 stumbles over error C2220: http://stackoverflow.com/questions/18225636/error-c2220-warning-treated-as-error-no-object-file-generated

The changes in v8_libbase.vcxproj and v8_libplatform.vcxproj are not really needed but tell VC14 to create *.pdb files.

Jan-E commented 8 years ago

What should be the PHP_V8_API_VERSION for 4.9.385.29? v8js_zeroPad(v8build,2) in my PR's clearly does not suffice.

Jan-E commented 8 years ago

There was an error while compiling:

60>D:\chromium\v8\test\unittests\unittests_run.targets(28,5): error MSB3721: The comma
   nd "call "D:\chromium\v8\test\unittests\..\..\third_party\cygwin\setup_env.bat" &&
   set CYGWIN=nontsec&& set OUTDIR=..\..\build\Release\&& set INPUTPATH=unittests.isol
   ate && bash -c "\"python\" \"../../tools/isolate_driver.py\" \"check\" \"--isolated
   \" \"`cygpath -m \\\"${OUTDIR}\\\"`/unittests.isolated\" \"--isolate\" \"`cygpath -
   m \\\"${INPUTPATH}\\\"`\" \"--path-variable\" \"DEPTH\" \"../..\" \"--path-variable
   \" \"PRODUCT_DIR\" \"`cygpath -m \\\"${OUTDIR}\\\"`\" \"--config-variable\" \"CONFI
   GURATION_NAME=Release\" \"--config-variable\" \"OS=win\" \"--config-variable\" \"as
   an=0\" \"--config-variable\" \"cfi_vptr=0\" \"--config-variable\" \"icu_use_data_fi
   le_flag=0\" \"--config-variable\" \"msan=0\" \"--config-variable\" \"tsan=0\" \"--c
   onfig-variable\" \"component=shared_library\" \"--config-variable\" \"target_arch=i
   a32\" \"--config-variable\" \"use_custom_libcxx=0\" \"--config-variable\" \"v8_use_
   external_startup_data=1\" \"--config-variable\" \"v8_use_snapshot=0\" \"--config-va
   riable\" \"msvs_version=2013\""" exited with code 1. [D:\chromium\v8\test\unittests
   \unittests_run.vcxproj]

The 'msvs_version=2013' is clearly not correct. Nevertheless unittests.exe was created and produced:

[----------] Global test environment tear-down [==========] 1844 tests from 129 test cases ran. (21323 ms total) [ PASSED ] 1844 tests.

YOU HAVE 4 DISABLED TESTS

I will zip the files and put them for download somewhere.

What should be the PHP_V8_API_VERSION for 4.9.385.29?

Wondering...

Jan-E commented 8 years ago

What should be the PHP_V8_API_VERSION for 4.9.385.29?

Result of my PR's was v8api = 40938529, v8ver = 4.9.385.29 I have locally changed the config.w32:

    var v8api = v8major + v8js_zeroPad(v8minor,2) + v8js_zeroPad(v8build,4);

With result v8api = 4090385, v8ver = 4.9.385.29 Better, but I do not know if this is the correct value for the API version. I did not investigate config.m4 yet. Rebuilding PHP 7.04 x86 TS right now.

Jan-E commented 8 years ago

The V8 files can be found here: https://phpdev.toolsforresearch.com/V8-4.9.385.29-x86.zip 282 MB ...

stesie commented 8 years ago

PHP_V8_API_VERSION for 4.9.385.29 would be 4009385, the last part is ignored there

Jan-E commented 8 years ago

YOU HAVE 4 DISABLED TESTS

In a glance I noticed there were some other failures at compiling the tests. That might explain the disabled tests. I will try to correct this.

Furthermore, "include/v8-platform.h" in include/libplatform/libplatform.h had to be changed in "v8-platform.h". A corrected zip is uploading right now.

phpinfo() after recompiling PHP 7.04 TS: capture

See

PHP_V8_API_VERSION for 4.9.385.29 would be 4009385, the last part is ignored there

https://phpdev.toolsforresearch.com/php-7.0.4-Win32-VC14-x86.htm https://phpdev.toolsforresearch.com/php-7.0.4-Win32-VC14-x86.zip

I see now. Then the line in config.w32 should be:

    var v8api = v8major + v8js_zeroPad(v8minor,3) + v8js_zeroPad(v8build,3);

Do you need a PR or will you change it yourself? I already deleted my fork...

stesie commented 8 years ago

I've just changed it in config.w32 file. Thanks. Not yet in PHP7 branch, I'll do that with the next merge then.

Jan-E commented 8 years ago

There were also some leftovers from the V8 v5 files in https://phpdev.toolsforresearch.com/V8-4.9.385.29-x86.zip

There is a x64 version as well: https://phpdev.toolsforresearch.com/V8-4.9.385.29-x64.zip

Jan-E commented 8 years ago

In a glance I noticed there were some other failures at compiling the tests. That might explain the disabled tests. I will try to correct this.

Changing msvs_version=2013 into msvs_version=2015 did not make any difference. The compilation of unittests_run, cctest_run and d8_run kept failing. I am not really surprised, because it is a system-call with use of python, cygwin, bash and the like. The chances of failing are high, but it does not make any difference to the generated files. The failing projects only tried to run unittests, cctest and d8.

In the mean time I have recompiled all my PHP7 builds: https://www.apachelounge.com/viewtopic.php?t=6359