@@ -2,87 +2,22 @@ V8Js on MacOS
2
2
=============
3
3
4
4
Installation of V8Js on MacOS is pretty much straight forward.
5
+ The ARM-based M1 chips also work just fine.
5
6
6
- If you have [ brew] ( https://brew.sh ) around, just `brew install
7
- php70-v8js` (or ` php71-v8js` / ` php72-v8js` depending on your PHP
8
- version) and you should be done. This will install a recent version
9
- of V8 along with this extension.
10
-
11
- Otherwise you need to compile latest v8 manually.
12
-
13
- Compile latest v8
14
- -----------------
15
-
16
- ```
17
- cd /tmp
18
-
19
- # Install depot_tools first (needed for source checkout)
20
- git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
21
- export PATH=`pwd`/depot_tools:"$PATH"
22
-
23
- # Download v8
24
- fetch v8
25
- cd v8
26
-
27
- # (optional) If you'd like to build a certain version:
28
- git checkout 3.32.6
29
- gclient sync
30
-
31
- # Compile V8 (using up to 8 CPU cores, requires a lot of RAM, adapt as needed)
32
- make native library=shared -j8
33
-
34
- # Install to /usr
35
- mkdir -p /usr/local/lib /usr/local/include
36
- cp out/native/lib*.dylib /usr/local/lib/
37
- cp out/native/libv8_*.a /usr/local/lib/
38
- cp -R include/* /usr/local/include
39
- ```
40
-
41
- You cannot install the libraries to any location you want since they
42
- have a install name that is baked into the library. You can check
43
- the install name with ` otool -D out/native/libv8.dylib ` .
44
-
45
- During the build snapshot generation may fail like so:
46
-
47
- ```
48
- ACTION tools_gyp_v8_gyp_v8_snapshot_target_run_mksnapshot /Users/vagrant/v8/out/native/obj.target/v8_snapshot/geni/snapshot.cc
49
- dyld: Library not loaded: /usr/local/lib/libicui18n.dylib
50
- Referenced from: /Users/vagrant/v8/out/native/mksnapshot
51
- Reason: image not found
52
- /bin/sh: line 1: 18964 Trace/BPT trap: 5 "/Users/vagrant/v8/out/native/mksnapshot" --log-snapshot-positions --logfile "/Users/vagrant/v8/out/native/obj.target/v8_snapshot/geni/snapshot.log" --random-seed 314159265 "/Users/vagrant/v8/out/native/obj.target/v8_snapshot/geni/snapshot.cc"
53
- make[1]: *** [/Users/vagrant/v8/out/native/obj.target/v8_snapshot/geni/snapshot.cc] Error 133
54
- make: *** [native] Error 2
55
- ```
56
-
57
- ... if that happens, just copy libicu* .dylib to /usr/local/lib already
58
- and start make again (then simply continue with installation):
59
-
60
- ```
61
- cp out/native/libicu*.dylib /usr/local/lib/
62
- make native library=shared -j8
63
- ```
7
+ You can use [ brew] ( https://brew.sh ) to install ` v8 ` . This provides
8
+ both the library as well as necessary include files in ` /opt/homebrew ` .
64
9
65
10
66
11
Compile php-v8js itself
67
12
-----------------------
68
13
69
- If you're using Apple LLVM compiler (instead of gcc) you need to pass the ` -Wno-c++11-narrowing `
70
- flag. Otherwise compilation fails due to narrowing errors in PHP itself, which LLVM is much pickier
71
- with (compared to gcc).
72
-
73
14
```
74
15
cd /tmp
75
16
git clone https://github.com/phpv8/v8js.git
76
17
cd v8js
77
18
phpize
78
- ./configure CXXFLAGS="-Wno-c++11-narrowing "
79
- make
19
+ ./configure --with-v8js=/opt/homebrew CPPFLAGS="-DV8_COMPRESS_POINTERS "
20
+ make -j4
80
21
make test
81
22
make install
82
23
```
83
-
84
- V8Js' build system assumes that the ` icudtl.dat ` file is located next to the ` libv8.dylib `
85
- library file and compiles the path into the library itself. If for whatever reason the
86
- ` icudtl.dat ` file is stored at a different place during runtime, you need to set the
87
- php.ini variable ` v8js.icudtl_dat_path ` to point to the file. Otherwise locale-aware
88
- features of V8 will not work as expected.
0 commit comments