Skip to content

Instantly share code, notes, and snippets.

@koriym
Last active May 2, 2016 07:57
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koriym/3c663355e643cc818703454de61b53bf to your computer and use it in GitHub Desktop.
Save koriym/3c663355e643cc818703454de61b53bf to your computer and use it in GitHub Desktop.
v8js for MacOS

How to install latest v8 (5.x) on MacOS

Compile latest v8

# Install depot_tools first (needed for source checkout)
# https://github.com/phpv8/v8js/blob/php7/README.MacOS.md
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
export PATH=`pwd`/depot_tools:"$PATH"

# Download v8
fetch v8
cd v8
git checkout 5.2.99
gclient sync
make native library=shared -j8

# fix compile error #1, #2: gyp: Error importing pymod_do_mainmodule (detect_v8_host_arch): No module named detect_v8_host_arch
# http://ykominami.hatenablog.com/entry/2016/05/01/124346

cd build
ln -s detect_host_arch.py detect_v8_host_arch.py
ln -s ../gypfiles/has_valgrind.py .

# fix compile make[1]: *** [/Users/peter/freeswitch/libs/v8-3.24.14/out/native/obj.target/v8_snapshot/geni/snapshot.cc] Error 133
# https://bugs.chromium.org/p/v8/issues/detail?id=3107

cd v8/out/third_party/icu
grep -l -R "/usr/local/lib" . | tr '\n' '\0' | xargs -0 sed -i "" -e 's|/usr/local/lib|\$(builddir)|g'

make native library=shared -j8

# Install to /usr
mkdir -p /usr/local/lib /usr/local/include
cp out/native/lib*.dylib /usr/local/lib/
cp out/native/libv8_*.a  /usr/local/lib/
cp -R include/* /usr/local/include

v8js.so

sudo pecl install v8js-1.1.0
  • failed with 1.2.0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment