@@ -15,21 +15,30 @@ on Windows, since you need to compile PHP with all its dependencies beforehand.
1515You need to have Visual Studio 2015 (aka VC14), make sure to install the C++
1616compiler (which is not installed by default any longer).
1717
18- Compiling V8 using GN (required for 5.6 and higher)
18+ Compiling V8 using GN (required for 5.2 and higher)
1919---------------------------------------------------
2020
21- [ Build transcript using GN] ( https://github.com/phpv8/v8js/issues/272 ) by @Jan-E
21+ [ Build transcript using GN] ( https://github.com/phpv8/v8js/issues/287#issuecomment-284222529 ) by @Jan-E
2222
23- TL;DR: up until 'msbuild all.sln' are the essential steps
24- Do not forget to build v8_libbase.lib & v8_libplatform.lib afterwards
23+ This is how I built V8 5.8.
24+
25+ TL;DR: these are the essential commands for x64.
2526
2627```
27- cd obj\v8_libplatform && lib /out:v8_libplatform.lib *.obj
28- cd ..\\..\obj\v8_libbase && lib /out:v8_libbase.lib *.obj
28+ call git checkout 5.8-lkgr
29+ call gclient sync
30+ call gn gen v5.8\x64.release --args="is_component_build=true is_debug=false v8_use_snapshot=false enable_nacl=false target_cpu=\"x64\"" --ide=vs
31+ cd v5.8\x64.release
32+ msbuild all.sln
2933```
3034
31- My initial setup was a mixture of the Linux & Windows commands at
32- https://www.chromium.org/developers/how-tos/install-depot-tools
35+ Prerequisites:
36+
37+ - VC14 aka VS2015 with the C and C++ compilers. The Community edition suffices.
38+ - The Windows 10 Debugging Tools. If you did not install the Windows 10 SDK together with VC14, you can do a separate download from https://developer.microsoft.com/en-us/windows/hardware/windows-driver-kit => Windows 10 (WinDbg)
39+
40+ My initial setup was a mixture of the Linux & Windows commands at https://www.chromium.org/developers/how-tos/install-depot-tools
41+
3342```
3443D:
3544cd \
@@ -44,283 +53,33 @@ git stash
4453```
4554Note: do not add the checkout dir to your path permanently if you've already installed git.exe somewhere in your path: the depot tools will create a git.bat in the checkout dir!
4655
47- Transcript of building V8 v5.4.500.43 in a VS2015 x64 command prompt:
48- ```
49- D:\chromium\v8>set path=D:\chromium;%path%
50-
51- D:\chromium\v8>set GYP_MSVS_VERSION=2015
52-
53- D:\chromium\v8>set DEPOT_TOOLS_WIN_TOOLCHAIN=0
54-
55- D:\chromium\v8>set GYP_CHROMIUM_NO_ACTION=0
56-
57- D:\chromium\v8>git checkout 5.4-lkgr
58- Checking out files: 100% (1561/1561), done.
59- Switched to branch '5.4-lkgr'
60- Your branch is up-to-date with 'origin/5.4-lkgr'.
56+ Then I ran the following batch script, inside a 'VS2015 x64 Native Tools Command Prompt' (x64) or a 'VS2015 x86 Native Tools Command Prompt' (x86):
6157
62- D:\chromium\v8>gclient sync
63- Syncing projects: 45% (11/24) v8/third_party/instrumented_libraries
64-
65- D:\chromium\v8>gclient sync
66- Syncing projects: 100% (24/24) v8/third_party/icu
67-
68- v8/tools/mb (ERROR)
69- ----------------------------------------
70- [0:00:32] Started.
71- [0:00:37] From https://chromium.googlesource.com/chromium/src/tools/mb
72- [0:00:37] dc02dd5..b1e1230 master -> origin/master
73- ----------------------------------------
74- Error: 20>
75- 20> ____ v8\tools\mb at 99788b8b516c44d7db25cfb68695bc234fdee5ed
76- 20> You have unstaged changes.
77- 20> Please commit, stash, or reset.
78-
79- D:\chromium\v8>cd tools\mb
80-
81- D:\chromium\v8\tools\mb>git stash
82- Saved working directory and index state WIP on (no branch): 99788b8 Fix libfuzzer configura
83- tions to actually use proprietary codecs.
84- HEAD is now at 99788b8 Fix libfuzzer configurations to actually use proprietary codecs.
85-
86- D:\chromium\v8\tools\mb>cd ..\..
87-
88- D:\chromium\v8>gclient sync
89- Syncing projects: 37% ( 9/24) v8/test/test262/data
90-
91- After a lot or messages:
92-
93- Hook ''D:\chromium\python276_bin\python.exe' v8/gypfiles/gyp_v8' took 11.56 secs
94-
95- D:\chromium\v8>gn args v5.4/x64.release
96- Waiting for editor on "D:\chromium\v8\v5.4\x64.release\args.gn"...
97-
98- In your editor change args.gn to something like
99-
100- # Build arguments go here. Examples:
101- is_component_build = true
102- is_debug = false
103- # See "gn args <out_dir> --list" for available build arguments.
104- target_cpu="x64"
105- v8_target_cpu="x64"
106-
107- And close your editor
108-
109- In the VS2015 command prompt:
110-
111- Generating files...
112- Done. Made 60 targets from 43 files in 2791ms
113-
114- D:\chromium\v8>gn gen v5.4/x64.release --ide=vs
115- Generating Visual Studio projects took 268ms
116- Done. Made 60 targets from 43 files in 2374ms
117-
118- D:\chromium\v8>cd v5.4\x64.release
119-
120- D:\chromium\v8\v5.4\x64.release>msbuild all.sln
121- Microsoft (R) Build Engine version 14.0.25420.1
122- Copyright (C) Microsoft Corporation. All rights reserved.
123-
124- Building the projects in this solution one at a time. To enable parallel build, please add
125- the "/m" switch.
126- Build started 24/11/16 21:40:52.
127- Project "D:\chromium\v8\v5.4\x64.release\all.sln" on node 1 (default targets).
128- ValidateSolutionConfiguration:
129- Building solution configuration "GN|x64".
130- Project "D:\chromium\v8\v5.4\x64.release\all.sln" (1) is building "D:\chromium\v8\v5.4\x64
131- .release\obj\build\config\sanitizers\deps.vcxproj" (2) on node 1 (default targets).
132- Build:
133- call ninja.exe -C ../../../../../../v5.4/x64.release/ obj/build/config/sanitizers/deps.s
134- tamp
135- ninja: Entering directory `../../../../../../v5.4/x64.release/'
136- [1/2] STAMP obj/build/config/sanitizers/deps_no_options.stamp
137- [2/2] STAMP obj/build/config/sanitizers/deps.stamp
138-
139- etc. etc.
140-
141- [902/906] CXX obj/v8_external_snapshot/snapshot-external.obj
142- [903/906] STAMP obj/v8_external_snapshot.stamp
143- [904/906] STAMP obj/v8_maybe_snapshot.stamp
144- [905/906] LINK(DLL) v8.dll v8.dll.lib v8.dll.pdb
145- LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/OPT:ICF' specification [D:\chromium\v8\v5.4\x64.release\obj\d8.vcxproj]
146-
147- [906/906] LINK d8.exe d8.exe.pdb
148- LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/OPT:ICF' specification [D:\chromium\v8\v5.4\x64.release\obj\d8.vcxproj]
149-
150- Done Building Project "D:\chromium\v8\v5.4\x64.release\obj\d8.vcxproj" (default targets).
151-
152- Project "D:\chromium\v8\v5.4\x64.release\all.sln" (1) is building "D:\chromium\v8\v5.4\x64.release\obj\fuzzer_support.vcxproj" (7) on node 1 (default targets).
153- Build:
154- call ninja.exe -C ../../../v5.4/x64.release/ obj/fuzzer_support.stamp
155- ninja: Entering directory `../../../v5.4/x64.release/'
156- [1/3] STAMP obj/fuzzer_support.inputdeps.stamp
157- [2/3] CXX obj/fuzzer_support/fuzzer-support.obj
158- [3/3] STAMP obj/fuzzer_support.stamp
159- Done Building Project "D:\chromium\v8\v5.4\x64.release\obj\fuzzer_support.vcxproj" (default targets).
160-
161- Project "D:\chromium\v8\v5.4\x64.release\all.sln" (1) is building "D:\chromium\v8\v5.4\x64.release\obj\gn_all.vcxproj" (8) on node 1 (default targets).
162- Build:
163- call ninja.exe -C ../../../v5.4/x64.release/ obj/gn_all.stamp
164- ninja: Entering directory `../../../v5.4/x64.release/'
165- [1/333] STAMP obj/v8_hello_world.inputdeps.stamp
166- [2/333] STAMP obj/json_fuzzer.inputdeps.stamp
167- [3/333] STAMP obj/parser_fuzzer.inputdeps.stamp
168- [4/333] STAMP obj/v8_parser_shell.inputdeps.stamp
169- [5/333] STAMP obj/regexp_fuzzer.inputdeps.stamp
170-
171- etc. etc.
172-
173- Done Building Project "D:\chromium\v8\v5.4\x64.release\all.sln" (default targets).
174-
175-
176- Build succeeded.
177-
178- "D:\chromium\v8\v5.4\x64.release\all.sln" (default target) (1) ->
179- "D:\chromium\v8\v5.4\x64.release\obj\d8.vcxproj" (default target) (6) ->
180- (Build target) ->
181- LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/OPT:ICF' specification [D:\chromium\v8\v5.4\x64.release\obj\d8.vcxproj]
182- LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/OPT:ICF' specification [D:\chromium\v8\v5.4\x64.release\obj\d8.vcxproj]
183- LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/OPT:ICF' specification [D:\chromium\v8\v5.4\x64.release\obj\d8.vcxproj]
184- LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/OPT:ICF' specification [D:\chromium\v8\v5.4\x64.release\obj\d8.vcxproj]
185-
186-
187- "D:\chromium\v8\v5.4\x64.release\all.sln" (default target) (1) ->
188- "D:\chromium\v8\v5.4\x64.release\obj\gn_all.vcxproj" (default target) (8) ->
189- LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/OPT:ICF' specification [D:\chromium\v8\v5.4\x64.release\obj\gn_all.vcxproj]
190- LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/OPT:ICF' specification [D:\chromium\v8\v5.4\x64.release\obj\gn_all.vcxproj]
191- LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/OPT:ICF' specification [D:\chromium\v8\v5.4\x64.release\obj\gn_all.vcxproj]
192- LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/OPT:ICF' specification [D:\chromium\v8\v5.4\x64.release\obj\gn_all.vcxproj]
193- LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/OPT:ICF' specification [D:\chromium\v8\v5.4\x64.release\obj\gn_all.vcxproj]
194- LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/OPT:ICF' specification [D:\chromium\v8\v5.4\x64.release\obj\gn_all.vcxproj]
195- LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/OPT:ICF' specification [D:\chromium\v8\v5.4\x64.release\obj\gn_all.vcxproj]
196- LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/OPT:ICF' specification [D:\chromium\v8\v5.4\x64.release\obj\gn_all.vcxproj]
197- LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/OPT:ICF' specification [D:\chromium\v8\v5.4\x64.release\obj\gn_all.vcxproj]
198- LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/OPT:ICF' specification [D:\chromium\v8\v5.4\x64.release\obj\gn_all.vcxproj]
199- LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/OPT:ICF' specification [D:\chromium\v8\v5.4\x64.release\obj\gn_all.vcxproj]
200- LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/OPT:ICF' specification [D:\chromium\v8\v5.4\x64.release\obj\gn_all.vcxproj]
201-
202- 16 Warning(s)
203- 0 Error(s)
204-
205- Time Elapsed 00:41:27.06
206-
207- D:\chromium\v8\v5.4\x64.release>type d:\batch\v8x64.bat
208- xcopy v8*.lib ..\win64build.vc14\lib\ /y
209- xcopy v8*.dll ..\win64build.vc14\bin\ /y
210- xcopy v8*.dll.pdb ..\win64build.vc14\bin\ /y
211- xcopy icu*.lib ..\win64build.vc14\lib\ /y
212- xcopy icu*.dll ..\win64build.vc14\bin\ /y
213- xcopy icu*.dll.pdb ..\win64build.vc14\bin\ /y
214- cd obj\v8_libplatform
215- lib /out:..\..\..\win64build.vc14\lib\v8_libplatform.lib *.obj
216- xcopy ..\v8_libplatform_cc.pdb ..\..\..\win64build.vc14\lib\ /y
217- cd ..\..\obj\v8_libbase
218- lib /out:..\..\..\win64build.vc14\lib\v8_libbase.lib *.obj
219- xcopy ..\v8_libbase_cc.pdb ..\..\..\win64build.vc14\lib\ /y
220- cd ..\..\
221- xcopy ..\..\include\*.h ..\win64build.vc14\include\ /s /y
222-
223- D:\chromium\v8\v5.4\x64.release>d:\batch\v8x64.bat
224-
225- D:\chromium\v8\v5.4\x64.release>xcopy v8*.lib ..\win64build.vc14\lib\ /y
226- D:v8.dll.lib
227- D:v8_parser_shell.lib
228- D:v8_simple_json_fuzzer.lib
229- D:v8_simple_parser_fuzzer.lib
230- D:v8_simple_regexp_fuzzer.lib
231- D:v8_simple_wasm_asmjs_fuzzer.lib
232- D:v8_simple_wasm_fuzzer.lib
233- 7 File(s) copied
234-
235- D:\chromium\v8\v5.4\x64.release>xcopy v8*.dll ..\win64build.vc14\bin\ /y
236- D:v8.dll
237- 1 File(s) copied
238-
239- D:\chromium\v8\v5.4\x64.release>xcopy v8*.dll.pdb ..\win64build.vc14\bin\ /y
240- D:v8.dll.pdb
241- 1 File(s) copied
242-
243- D:\chromium\v8\v5.4\x64.release>xcopy icu*.lib ..\win64build.vc14\lib\ /y
244- D:icui18n.dll.lib
245- D:icuuc.dll.lib
246- 2 File(s) copied
247-
248- D:\chromium\v8\v5.4\x64.release>xcopy icu*.dll ..\win64build.vc14\bin\ /y
249- D:icui18n.dll
250- D:icuuc.dll
251- 2 File(s) copied
252-
253- D:\chromium\v8\v5.4\x64.release>xcopy icu*.dll.pdb ..\win64build.vc14\bin\ /y
254- D:icui18n.dll.pdb
255- D:icuuc.dll.pdb
256- 2 File(s) copied
257-
258- D:\chromium\v8\v5.4\x64.release>cd obj\v8_libplatform
259-
260- D:\chromium\v8\v5.4\x64.release\obj\v8_libplatform>lib /out:..\..\..\win64build.vc14\lib\v8
261- _libplatform.lib *.obj
262- Microsoft (R) Library Manager Version 14.00.24215.1
263- Copyright (C) Microsoft Corporation. All rights reserved.
264-
265-
266- D:\chromium\v8\v5.4\x64.release\obj\v8_libplatform>xcopy ..\v8_libplatform_cc.pdb ..\..\..\
267- win64build.vc14\lib\ /y
268- ..\v8_libplatform_cc.pdb
269- 1 File(s) copied
270-
271- D:\chromium\v8\v5.4\x64.release\obj\v8_libplatform>cd ..\..\obj\v8_libbase
272-
273- D:\chromium\v8\v5.4\x64.release\obj\v8_libbase>lib /out:..\..\..\win64build.vc14\lib\v8_lib
274- base.lib *.obj
275- Microsoft (R) Library Manager Version 14.00.24215.1
276- Copyright (C) Microsoft Corporation. All rights reserved.
277-
278-
279- D:\chromium\v8\v5.4\x64.release\obj\v8_libbase>xcopy ..\v8_libbase_cc.pdb ..\..\..\win64bui
280- ld.vc14\lib\ /y
281- ..\v8_libbase_cc.pdb
282- 1 File(s) copied
283-
284- D:\chromium\v8\v5.4\x64.release\obj\v8_libbase>cd ..\..\
285-
286- D:\chromium\v8\v5.4\x64.release>xcopy ..\..\include\*.h ..\win64build.vc14\include\ /s /y
287- ..\..\include\v8-debug.h
288- ..\..\include\v8-experimental.h
289- ..\..\include\v8-platform.h
290- ..\..\include\v8-profiler.h
291- ..\..\include\v8-testing.h
292- ..\..\include\v8-util.h
293- ..\..\include\v8-version.h
294- ..\..\include\v8.h
295- ..\..\include\v8config.h
296- ..\..\include\libplatform\libplatform.h
297- ..\..\include\libplatform\v8-tracing.h
298- 11 File(s) copied
299-
300- D:\chromium\v8\v5.4\x64.release>type ..\..\include\v8-version.h
301- // Copyright 2015 the V8 project authors. All rights reserved.
302- // Use of this source code is governed by a BSD-style license that can be
303- // found in the LICENSE file.
304-
305- #ifndef V8_INCLUDE_VERSION_H_ // V8_VERSION_H_ conflicts with src/version.h
306- #define V8_INCLUDE_VERSION_H_
307-
308- // These macros define the version number for the current version.
309- // NOTE these macros are used by some of the tool scripts and the build
310- // system so their names cannot be changed without changing the scripts.
311- #define V8_MAJOR_VERSION 5
312- #define V8_MINOR_VERSION 4
313- #define V8_BUILD_NUMBER 500
314- #define V8_PATCH_LEVEL 43
315-
316- // Use 1 for candidates and 0 otherwise.
317- // (Boolean macro values are not supported by all preprocessors.)
318- #define V8_IS_CANDIDATE_VERSION 0
319-
320- #endif // V8_INCLUDE_VERSION_H_
58+ ```
59+ D:
60+ cd \chromium\v8
61+ set WindowsSdkDir=C:\Program Files (x86)\Windows Kits\10\
62+ set WindowsSDK_ExecutablePath_x64=C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.2 Tools\x64\
63+ set WindowsSDK_ExecutablePath_x86=C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.2 Tools\
64+ set path=D:\chromium;%path%
65+ set GYP_MSVS_VERSION=2015
66+ set DEPOT_TOOLS_WIN_TOOLCHAIN=0
67+ set GYP_CHROMIUM_NO_ACTION=0
68+ set xn=x86
69+ if not %platform%x==x set xn=%platform%
70+ if %xn%==X64 set xn=x64
71+ call git checkout 5.8-lkgr
72+ call git pull
73+ call gclient sync
74+ call gn gen v5.8\%xn%.release --args="is_component_build=true is_debug=false v8_use_snapshot=false enable_nacl=false target_cpu=\"%xn%\"" --ide=vs
75+ cd v5.8\%xn%.release
76+ msbuild all.sln /t:clean
77+ msbuild all.sln
78+ pause
79+ unittests
32180```
32281
323- Compiling V8 5.5 (and before)
82+ Compiling V8 5.1 (and before)
32483-----------------------------
32584
32685The Google v8 project already has excellent step-by-step guide on
@@ -399,7 +158,7 @@ nmake
399158After nmake completes the php.exe is in Release_TS\ directory.
400159
401160In order to try things out in place, copy over ` icui18n.dll ` , ` icuuc.dll ` and
402- ` v8.dll ` file from ` \v8\build\Release ` folder to
161+ ` v8* .dll ` files from ` \v8\build\Release ` folder to
403162` \php-sdk\phpdev\vc14\x86\php-7.0.1\Release_TS\ ` first.
404163
405164Then run
@@ -408,5 +167,4 @@ Then run
408167Release_TS\php.exe -d extension=php_v8js.dll -d extension_dir=Release_TS\
409168```
410169
411- Alternatively copy all stuff to c:\php\ (including the three DLL files from
412- v8 build).
170+ Alternatively copy all stuff to c:\php\ (including the DLL files from v8 build).
0 commit comments