Skip to content

Building and Installing on FreeBSD 8.2

Fred Emmott edited this page · 50 revisions
Clone this wiki locally

BSD IS NOT SUPPORTED BY THE HHVM TEAM - DO NOT EXPECT THIS TO WORK. These instructions are provided by the community, and your success may vary.

Building and Installing on FreeBSD 8.2

This walkthrough was tested with 64-bit 8.1, 8.2 and 9.0, but generally any FreeBSD with gcc46 should do.

Fix before FreeBSD update

mkdir -p /usr/src/lib/libc/gen

Update FreeBSD

freebsd-update fetch

freebsd-update install

Add required packages to build HPHP and HPHPI

pkg_add -r cmake flex bison re2c openssl gd libxml2 pcre oniguruma boost-libs libmemcached libmcrypt binutils expat mysql50-client wget tbb icu openldap24-client libexecinfo gcc46 gawk git cclient mc autoconf gmake

Add Jemalloc Support

cd /usr/src/contrib/
git clone git:// --depth=1
cd jemalloc
./configure --prefix=/usr/local
gmake install

It seems that git above is down, but the site is up. So one can use: or

Fix for CClient 2007

cd /usr/local/lib
ln -s

Create a directory for build

mkdir ~/hhbuild
cd ~/hhbuild
mkdir libs

Get the latest HipHop code

git clone git:// --depth=1
cd hhvm
git submodule update --init --recursive

Configure environment for GCC 4.6

You'll have to do this every time you're going to use HipHop.

setenv CC /usr/local/bin/gcc46
setenv CXX /usr/local/bin/g++46
setenv CMAKE_PREFIX_PATH `pwd`/../libs

OR Configure environment for CLang 3.0 ( cd /usr/ports/lang/clang; make install clean )

setenv CC /usr/bin/clang
setenv CXX /usr/bin/clang++
setenv CMAKE_PREFIX_PATH `pwd`/../libs

Build patched libevent

cd ..
tar -zxf libevent-1.4.14b-stable.tar.gz
cd libevent-1.4.14b-stable
patch -p1 < ../hhvm/hphp/patches/libevent-1.4.14b.patch
./configure --prefix=$CMAKE_PREFIX_PATH
make install
cd ..
rm -rf libevent-1.4.14b-stable

Build patched CURL

tar -zxf curl-7.20.0.tar.gz
cd curl-7.20.0
patch -p1 < ../hhvm/third-party/libcurl.fb-changes.diff
./configure --prefix=$CMAKE_PREFIX_PATH
make install
cd ..
rm -rf curl-7.20.0

If you have troubles compiling curl (conflicting types for 'libssh2_free') follow this path:

Apply unofficial patches (until official fixes)

cd hhvm
patch < ../hphp-freebsd-20120214.patch

For FreeBSD 9.0 you're also need to apply libmemcached-1.0 support patch:

cd ..
cd hhvm
patch < ../hphp-libmemcached-1.0.patch

Configure libmap

Since HipHop is compiled with non-base gcc, you should make HipHop to use specific libstdc++. Put this to /etc/libmap.conf:

[hhvm] gcc46/

[program] gcc46/

Build HipHop

cmake .

hhvm binary can be found in hphp/hhvm folder and is called hhvm


In case you're expiriencing occasional segfaults with 8.1, you should apply the patch from this PR:

Something went wrong with that request. Please try again.