Skip to content

Building and installing HHVM on OSX 10.8

Daniel Sloof edited this page May 24, 2013 · 34 revisions

As of yet, HHVM does not completely work on OSX. This page serves as a work in progress for getting it partially working.

Packages installation

Install homebrew.

Install the following packages with homebrew:

brew install git jemalloc libtool mcrypt glog oniguruma re2c autoconf libelf readline automake mysql pcre gd icu4c libmemcached mysql-connector-c pkg-config tbb boost imagemagick mysql-connector-c++ binutils ncurses

Install cclient separately, since it is not yet part of official homebrew repository yet:

brew install https://raw.github.com/msonnabaum/megalodon/master/formulas/cclient.rb

We need gcc to build:

brew tap homebrew/versions
brew install --enable-cxx --use-llvm gcc47

Install patched cmake (PR pending):

brew install https://gist.github.com/danslo/5621408/raw/3fd4b4747f7c4d077ff05772c46138034604a947/cmake.rb

Homebrew carries a package called dwarf, but it is not libdwarf from elftoolchain. Install this custom libdwarf formula until homebrew creates an elftoolchain package.

brew install https://gist.github.com/danslo/5621394/raw/7826e6046bf77bea549265099c306debfcbe6b04/libdwarf.rb

Downgrade libmemcached due to this bug.

cd /usr/local
git checkout e029db5 Library/Formula/libmemcached.rb
brew unlink libmemcached
brew install libmemcached
brew switch libmemcached 1.0.4

Getting HipHop source-code

cd ~
mkdir dev
cd dev
export CMAKE_PREFIX_PATH=`/bin/pwd`
git clone git://github.com/facebook/hiphop-php.git

libevent

git clone git://github.com/libevent/libevent.git
cd libevent
git checkout release-1.4.14b-stable
cat ../hiphop-php/hphp/third_party/libevent-1.4.14.fb-changes.diff | patch -p1
./autogen.sh
./configure --prefix=$CMAKE_PREFIX_PATH
make
make install
cd ..

Note, you may have issues with configure.in which can be solved by manually editing the file.

Building HipHop

cd hiphop-php
export HPHP_HOME=`pwd`
cmake . \
    -DCMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH \
    -DMYSQL_INCLUDE_DIR=$(brew --prefix mysql)/include \
    -DMYSQL_LIB_DIR=$(brew --prefix mysql)/lib \
    -DICU_INCLUDE_DIR=$(brew --prefix icu4c)/include \
    -DICU_LIBRARY=$(brew --prefix icu4c)/lib \
    -DLIBDWARF_INCLUDE_DIRS=$(brew --prefix libdwarf)/include \
    -DLIBDWARF_LIBRARIES=$(brew --prefix libdwarf)/lib \
    -DBINUTIL_LIB=$(brew --prefix binutils)/lib \
    -DLIBUNWIND_INCLUDE_DIR=/usr/include \
    -DLIBUNWIND_LIBRARY=/usr/lib \
    -DCMAKE_CXX_COMPILER=$(brew --prefix gcc47)/bin/g++-4.7 \
    -DCMAKE_C_COMPILER=$(brew --prefix gcc47)/bin/gcc-4.7 \
    -DCMAKE_ASM_COMPILER=$(brew --prefix gcc47)/bin/gcc-4.7 \
    -DREADLINE_INCLUDE_DIR=$(brew --prefix readline)/include \
    -DREADLINE_LIBRARY=$(brew --prefix readline)/lib \
    -DNCURSES_LIBRARY=$(brew --prefix ncurses)/lib
make

And sadly there is an ERROR: hphp/util/alloc.h:94:39: error: 'dallocm' was not declared in this scope