making bbPress (and WordPress) work better!

How to build HHVM 3.22 master trunk on CentOS 7

HHVM 3.20, 3.21 and 3.22 are still faster than PHP 7.2 especially with many connections under load, however as of October 2017 there still are no official pre-compiled HHVM packages for CentOS 7.x so we need to revisit how to build it by hand, which is not too difficult, just takes most servers awhile to assemble

There are instructions on the HHVM wiki for CentOS7 but they are a year out of date now.

The process is straightforward, first we need to not only make sure we have all the libraries we need but also the development libraries and most recently a newer version of the GCC compiler, we will use GCC 6.3 found in the official SCL Devtoolset-6 for CentOS 7 (trusted because it is built by Redhat/CentOS)

yum install centos-release-scl devtoolset-6 scl-utils cmake3 make git psmisc ocaml gperf enca \
{binutils,boost,jemalloc,numactl,unixODBC,expat,mariadb,pam,fastlz,double-conversion,re2,fribidi,libc-client,glib2}-devel \
{glog,oniguruma,libjpeg-turbo,openssl,ImageMagick,sqlite,tbb,bzip2,openldap,readline,elfutils-libelf,gmp,lz4,pcre}-devel \

now you need to move into your temporary directory, either /tmp or /temp and copy the newest HHVM into it

cd /tmp
git clone -b master hhvm --recursive
### optionally "-b master" could be "-b HHVM-3.21" if you wanted a branch
cd hhvm

then we enable the newer GCC without disturbing the rest of your system, we no longer use ./configure but instead the newer cmake3 and compile HHVM

scl enable devtoolset-6 bash
cmake3 .  -DCMAKE_C_FLAGS="-O2 -pipe -march=native" -DCMAKE_CXX_FLAGS="-O2 -pipe -march=native" -DCMAKE_ASM_FLAGS="-O2 -pipe -march=native"  -DCMAKE_BUILD_TYPE="Release"
time ionice -c2 -n7 nice -n19 make -j7  
./hphp/hhvm/hhvm --version
make install
hhvm --version

the flags are forced on the cmake line, I use O2 instead of O3 because it reduces compiling time from like 2 hours to “only” an hour, the “-j7” on the make line is to try to use more cpu threads when available, try your CPU count +1 and I use ionice and nice to try to make it give priority to other things going on in the system since it is such a resource hog

an hour, or two, later you should have success and “make install” puts it into place – you need a service script to start/stop hhvm but that is beyond the scope of this help and available on the official wiki anyway

the “exit” on the end is to escape out of the SCL shell which is what gives you the newer GCC compiler and returns you to the regular system

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s