@@ -3,16 +3,18 @@ V8Js on GNU/Linux
3
3
4
4
Installation of V8Js on GNU/Linux is pretty much straight forward.
5
5
6
- The biggest hurdle actually is that you need a rather new V8 library.
7
- However many distributions still ship the rusty version 3.14, published
8
- years ago .
6
+ First you need to decide if you can go with a V8 library that is
7
+ shipped with your GNU/Linux distribution or whether you would want
8
+ to compile V8 on your own .
9
9
10
- This means that you usually need to compile V8 on your own before
11
- you can start to compile & install V8Js itself.
10
+ Many GNU/Linux distributions, for example Debian/Ubuntu, have
11
+ recent V8 library versions installable, that are ready to be used.
12
+ In order to go with these, just ` sudo apt-get install libv8-dev `
13
+ (or similar, as it fits your distribution).
12
14
13
- It is recommended to install the V8 version for V8Js off your system's
14
- load path, so it doesn't interfere with the V8 library shipped with your
15
- system's distribution.
15
+ If you compile V8 on your own, it is recommended to install the V8
16
+ version for V8Js off your system's load path, so it doesn't interfere
17
+ with the V8 library shipped with your system's distribution.
16
18
17
19
18
20
Snapshots
@@ -51,12 +53,34 @@ then you
51
53
` CPPFLAGS="-DV8_COMPRESS_POINTERS" ` to the ` ./configure ` call.
52
54
53
55
56
+ Sandbox
57
+ -------
58
+
59
+ V8 has optional sandbox support. You need to compile php-v8js with matching
60
+ configurations. If your V8 library was called with sandbox support, you
61
+ need to pass the ` -DV8_ENABLE_SANDBOX ` flag to the configure call.
62
+
63
+ By default V8 currently enables this feature.
64
+ Many GNU/Linux distributions currently seem to have sandbox feature turned
65
+ off however.
66
+
67
+ If you configure it the wrong way round, you'll get runtime errors like this,
68
+ as soon as php-v8js tries to initialize V8:
69
+
70
+ ```
71
+ Embedder-vs-V8 build configuration mismatch. On embedder side sandbox is DISABLED while on V8 side it's ENABLED.
72
+ ```
73
+
74
+ In order to compile V8 with sandbox support off, pass ` v8_enable_sandbox=false `
75
+ to v8gen.py invocation.
76
+
77
+
54
78
Compile V8 5.6 and newer (using GN)
55
79
-----------------------------------
56
80
57
81
```
58
82
# Install required dependencies
59
- sudo apt-get install build-essential curl git python libglib2.0-dev
83
+ sudo apt-get install build-essential curl git python3 libglib2.0-dev
60
84
61
85
cd /tmp
62
86
@@ -69,8 +93,8 @@ fetch v8
69
93
cd v8
70
94
71
95
# (optional) If you'd like to build a certain version:
72
- git checkout 8 .0.426.30
73
- gclient sync
96
+ git checkout 12 .0.267.36
97
+ gclient sync -D
74
98
75
99
# Setup GN
76
100
tools/dev/v8gen.py -vv x64.release -- is_component_build=true use_custom_libcxx=false
@@ -101,7 +125,7 @@ cd /tmp
101
125
git clone https://github.com/phpv8/v8js.git
102
126
cd v8js
103
127
phpize
104
- ./configure --with-v8js=/opt/v8 LDFLAGS="-lstdc++" CPPFLAGS="-DV8_COMPRESS_POINTERS"
128
+ ./configure --with-v8js=/opt/v8 LDFLAGS="-lstdc++" CPPFLAGS="-DV8_COMPRESS_POINTERS -DV8_ENABLE_SANDBOX "
105
129
make
106
130
make test
107
131
sudo make install
0 commit comments