in FreeBSD, hhvm

Compile HHVM 3.3 on FreeBSD 10

Since HHVM support wordpress I wanna try it on FreeBSD but compile guide for source only available for FreeBSD 8 and downgrade FreeBSD is not an option. Since I have access to vps that capable to run FreeBSD 10 64 bit I decide to take a ride and see how far (hhvm 3.3) and I can go. At least when I have to re-run the test I can see where I fall 🙂

Update hostname

#ee /etc/rc.conf

# Auto-Enabled NICs from pc-sysinstall

ifconfig_vtnet0=”inet 104.156.250.192 netmask 255.255.254.0″
defaultrouter=”104.156.250.1″
hostname=”hhvm330.rasyid.net”
sshd_enable=YES
static_routes=linklocal
route_linklocal=”-net 169.254.0.0/16 -interface vtnet0″

save.

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

# freebsd-update fetch
# freebsd-update install

update pkg

# pkg update
The package management tool is not yet installed on your system.
Do you want to fetch and install it now? [y/N]: y
Bootstrapping pkg from pkg+http://pkg.FreeBSD.org/freebsd:10:x86:64/latest, please wait…
Verifying signature with trusted certificate pkg.freebsd.org.2013102301… done
Installing pkg-1.3.8_3: 100%
Message for pkg-1.3.8_3:
If you are upgrading from the old package format, first run:

# pkg2ng
Updating FreeBSD repository catalogue…
Fetching meta.txz: 100%   944 B   0.9k/s    00:01
Fetching digests.txz: 100%    2 MB   2.1M/s    00:01
Fetching packagesite.txz: 100%    5 MB   5.3M/s    00:01
Processing new repository entries: 100%
FreeBSD repository update completed. 23551 packages processed:
0 updated, 0 removed and 23551 added.

# echo '104.156.250.192    hhvm330.rasyid.net ' >> /etc/hosts

#reboot

# uname -a
FreeBSD hhvm330.rasyid.net 10.0-RELEASE-p9 FreeBSD 10.0-RELEASE-p9 #0: Mon Sep 15 14:35:52 UTC 2014     [email protected]:/usr/obj/usr/src/sys/GENERIC  amd64

Ok, lets get started.

Install devel package :

# pkg install git cmake flex bison re2c openssl libxml2 libxslt openldap-client pcre oniguruma boost-libs libmemcached libmcrypt binutils expat mysql56-client wget tbb icu libexecinfo gcc48 gawk git cclient mc autoconf gmake libevent-hiphop sqlite3 lz4 libzip libedit libinotify glog libelf libdwarf unixodbc  gnulibiberty libyaml  jpeg

Add Jemalloc Support

# mkdir -p /usr/src/contrib
# cd /usr/src/contrib/

# git clone https://github.com/jemalloc/jemalloc.git --depth=1
Cloning into ‘jemalloc’…
remote: Counting objects: 181, done.
remote: Compressing objects: 100% (162/162), done.
remote: Total 181 (delta 18), reused 80 (delta 14)
Receiving objects: 100% (181/181), 372.00 KiB | 0 bytes/s, done.
Resolving deltas: 100% (18/18), done.
Checking connectivity… done.
.

Fix for CClient 2007

#cd /usr/local/lib
#ln -s libc-client4.so libc-client.so

Create a directory for build

# mkdir ~/hhvm330
# cd ~/hhvm330/
# mkdir libs

Get latest HHVM code

# git clone git://github.com/facebook/hhvm.git --depth=1
Cloning into ‘hhvm’…
remote: Counting objects: 40962, done.
remote: Compressing objects: 100% (31200/31200), done.
remote: Total 40962 (delta 6408), reused 29798 (delta 5604)
Receiving objects: 100% (40962/40962), 21.38 MiB | 10.27 MiB/s, done.
Resolving deltas: 100% (6408/6408), done.
Checking connectivity… done.
Checking out files: 100% (53350/53350), done.

#cd hhvm

# git submodule update --init --recursive
Submodule ‘third-party’ (https://github.com/hhvm/hhvm-third-party.git) registered for path ‘third-party’
Cloning into ‘third-party’…
remote: Counting objects: 2248, done.
remote: Total 2248 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (2248/2248), 6.66 MiB | 0 bytes/s, done.

Resolving deltas: 100% (1118/1118), done.
Checking connectivity… done.
Submodule path ‘third-party’: checked out ’12acbba4c05d8cbe97fe2a94a4a833c0c80e8182′
Submodule ‘folly’ (https://github.com/facebook/folly.git) registered for path ‘folly/src’
Submodule ‘thrift/src’ (https://github.com/facebook/fbthrift.git) registered for path ‘thrift/src’
Cloning into ‘folly/src’…
remote: Counting objects: 7548, done.
remote: Total 7548 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (7548/7548), 3.41 MiB | 0 bytes/s, done.
Resolving deltas: 100% (5746/5746), done.
Checking connectivity… done.
Submodule path ‘third-party/folly/src’: checked out ‘4ecd8cdd6396f2f4cbfc17c1063537884e3cd6b9’
Cloning into ‘thrift/src’…
remote: Counting objects: 8752, done.
remote: Total 8752 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (8752/8752), 4.99 MiB | 0 bytes/s, done.
Resolving deltas: 100% (6319/6319), done.
Checking connectivity… done.
Submodule path ‘third-party/thrift/src’: checked out ‘378e954ac82a00ba056e6fccd5e1fa3e76803cc8’

Configure environment for GCC 4.8

#setenv CC /usr/local/bin/gcc48
#setenv CXX /usr/local/bin/g++48
#setenv CMAKE_PREFIX_PATH `pwd`/../libs

Libmap

#ee /etc/libmap.conf

[hhvm]
libstdc++.so.6 gcc48/libstdc++.so.6

[program]
libstdc++.so.6 gcc48/libstdc++.so.6

save.

Create hhvm binary.

#cd hhvm
#cmake .

…..
…………..
CMake Warning (dev) at CMake/HPHPFunctions.cmake:156 (get_target_property):
Policy CMP0026 is not set: Disallow use of the LOCATION target property.
Run “cmake –help-policy CMP0026” for policy details.  Use the cmake_policy
command to set the policy and suppress this warning.

The LOCATION property should not be read from target “hhvm”.  Use the
target name directly with add_custom_command, or use the generator
expression $<TARGET_FILE>, as appropriate.

Call Stack (most recent call first):
hphp/hhvm/CMakeLists.txt:45 (HHVM_INSTALL)
This warning is for project developers.  Use -Wno-dev to suppress it.

— Configuring done
— Generating done
— Build files have been written to: /root/hhvm330/hhvm

#make

/root/hhvm330/hhvm/third-party/folly/folly/Conv.cpp:89:7: note: in expansion of macro ‘FOLLY_RANGE_CHECK’
FOLLY_RANGE_CHECK(value <= 1,
^
/root/hhvm330/hhvm/third-party/folly/folly/Conv.h:47:21: error: ‘to_string’ is not a member of ‘std’
(__FILE__ “(” + std::to_string((long long int) __LINE__) + “): ”    \
^
/root/hhvm330/hhvm/third-party/folly/folly/Conv.cpp:130:9: note: in expansion of macro ‘FOLLY_RANGE_CHECK’
FOLLY_RANGE_CHECK(false, “Invalid value for bool”);
^
/root/hhvm330/hhvm/third-party/folly/folly/Conv.h:47:21: error: ‘to_string’ is not a member of ‘std’
(__FILE__ “(” + std::to_string((long long int) __LINE__) + “): ”    \
^
/root/hhvm330/hhvm/third-party/folly/folly/Conv.cpp:134:7: note: in expansion of macro ‘FOLLY_RANGE_CHECK’
FOLLY_RANGE_CHECK(false, “Invalid value for bool”);
^
*** Error code 1

Stop.
make[2]: stopped in /root/hhvm330/hhvm
*** Error code 1

Stop.
make[1]: stopped in /root/hhvm330/hhvm
*** Error code 1

Stop.
make: stopped in /root/hhvm330/hhvm

Fiuh… I guess I need a break and wait for another release 🙂