HipHop for PHP is a source code transformer which transforms PHP code to C++ and compiles it with gcc/g++. I wanted to experiment with it and tried to install in on my PC with Fedora 15. Here is how I did it and how you can do it ( hopefully 🙂 ). Please note that this did not work and I will update the article soon.
Install Dependencies Available in the Repos
In the terminal, run the following command:
su -c 'yum -y install git cmake boost pcre-devel libicu-devel libmcrypt-devel oniguruma-devel mysql-devel gd-devel boost-devel libxml2-devel libcap-devel binutils-devel flex bison expat-devel re2c tbb libmemcached-devel tbb-devel bzip2-devel openldap-devel readline-devel libc-client-devel pam-devel gcc-c++ memcached'
Setup build environment
I compiled it in dev folder of home directory. Change directory in subsequent commands if you are doing it somewhere else. Run the following commands:
mkdir -p dev/local
git clone git://github.com/facebook/hiphop-php.git
Download, patch and compile libcurl and libevent
Use these versions because as of current, patches for these versions are only available in hiphop git.
tar xvzf libevent-1.4.13-stable.tar.gz
tar xvjf curl-7.20.0.tar.bz2
cp ../hiphop-php/src/third_party/libevent-1.4.13.fb-changes.diff .
patch < libevent-1.4.13.fb-changes.diff
cp ../hiphop-php/src/third_party/libcurl.fb-changes.diff .
patch -p0 < libcurl.fb-changes.diff #see note-1 below
Note-1: While patching curl, you may be asked paths to the files. Enter includes/curl/multi.h and lib/multi.c respectively.
Now, you will need to make a small change in Makefile for it to compile properly. To do that open the file src/Makefile in gedit or any text editor, find the line that has the following:
curl_LDADD = $(top_builddir)/lib/libcurl.la -lz
and append -lrt so that the line looks like the following:
curl_LDADD = $(top_builddir)/lib/libcurl.la -lz -lrt
Now, run the following in the terminal:
git submodule init
git submodule update
cmake . #see note-2 below
make #see note-3 below
Note-2: You may get errors while running cmake. This may be because of dependencies I might have missed above. In that case, please let me know the output of cmake in the comments so that I might be able to help.
Note-3: If you encounter any errors while using make, remove CMakeCache.txt and run make clean, cmake and make again.
This should have worked, but I am getting the following error:
../../bin/libhphp_runtime.a(ext_mysql.cpp.o): In function `HPHP::php_mysql_do_query_general(HPHP::String const&, HPHP::Variant const&, bool)':
ext_mysql.cpp:(.text+0x8100): undefined reference to `cli_safe_read'
ext_mysql.cpp:(.text+0x826a): undefined reference to `net_field_length'
ext_mysql.cpp:(.text+0x83a0): undefined reference to `cli_safe_read'
ext_mysql.cpp:(.text+0x8712): undefined reference to `free_root'
collect2: ld returned 1 exit status
make: *** [src/hphp/hphp] Error 1
make: *** [src/hphp/CMakeFiles/hphp.dir/all] Error 2
make: *** [all] Error 2
It seems like a problem with mysql version in the Fedora repo. I will download and build mysql and update this post.