in DragonFy BSD

Compile HHVM 3.4 on DragonFlyBSD 4

My last experiment with HHVM is testing compile it with HHVM LTS (its version 3.3) on FreeBSD 10. Since HHVM 3.4 is out I think I’ll try it again with FreeBSD 10 but since I just install DragonFlyBSD 4 then I think I’ll give it try.

Another reason is I just curious to see implementation of DragonFlyBSD in many field. By share it to others perhaps I can contribute too.

Ok, lets go back to topic.

I use DragonFlyBSD 4 that I install recently. It has 2 cpu and memory 2GB plus hammer filesystem enabled.

See current installed package

# pkg info
bind-tools-9.10.1_3 BIND DNS suite with updated DNSSEC and DNS64
ca_root_nss-3.17.2_1 The root certificate bundle from the Mozilla Project
cdrtools-3.00_2 CD/DVD/BluRay and ISO-9660 image creation and extraction tools
curl-7.38.0_2 Non-interactive tool to get files from FTP, GOPHER, HTTP(S) servers
cvsps-2.1_1 Create patchset information from CVS
expat-2.1.0_1 XML 1.0 parser written in C
gettext-0.18.3.1_1 GNU gettext package
git-2.1.2 Distributed source code management tool
idnkit-1.0_5 Library to handle internationalized domain names
indexinfo-0.2 Utility to regenerate the GNU info page index
isc-dhcp42-server-4.2.7 The ISC Dynamic Host Configuration Protocol server
libxml2-2.9.2_2 XML parser library for GNOME
openssl-1.0.1_16 SSL and crypto library
pkg-1.3.8_3 Package manager

Update pkg

# pkg update
Updating Avalon repository catalogue…
Fetching meta.txz: 100% 264 B 0.3k/s 00:01
Fetching digests.txz: 100% 2 MB 111.4k/s 00:17
Fetching packagesite.txz: 100% 4 MB 136.9k/s 00:34
Processing new repository entries: 100%
Avalon repository update completed. 21772 packages processed:
0 updated, 0 removed and 21772 added.

# uname -a
DragonFly 4.0-RELEASE DragonFly v4.0.0.32.gce3e27-RELEASE #25: Mon Nov 24 20:15:26 PST 2014 root@pkgbox64.dragonflybsd.org:/usr/obj/build/home/justin/src/sys/X86_64_GENERIC x86_64

# pkg install cmake flex bison re2c openssl libxml2 libxslt openldap-client pcre oniguruma boost-libs libmemcached libmcrypt binutils expat mysql56-client wget icu libexecinfo gawk git cclient mc autoconf gmake libevent-hiphop sqlite3 lz4 libzip libedit libinotify glog libelf libdwarf unixodbc gnulibiberty libyaml jpeg
Updating Avalon repository catalogue…
Avalon repository is up-to-date.
All repositories are up-to-date.
The following 76 packages will be affected (of 0 checked):

New packages to be INSTALLED:
cmake: 3.0.2
flex: 2.5.39_2
bison: 2.7.1,1
re2c: 0.13.6
libxslt: 1.1.28_5
openldap-client: 2.4.40_1
pcre: 8.35_2
oniguruma: 2.5.8
boost-libs: 1.55.0_4
libmemcached: 1.0.7_4
libmcrypt: 2.5.8_2
binutils: 2.24_1
mysql56-client: 5.6.22
wget: 1.16
icu: 53.1
libexecinfo: 1.1_3
gawk: 4.1.1_1
cclient: 2007f_2,1
mc: 4.8.13_3
autoconf: 2.69
gmake: 4.1_1
libevent-hiphop: 1.4.14b_4
sqlite3: 3.8.7.2
lz4: r101
libzip: 0.11.2_1
libedit: 3.1.20141030
libinotify: 20140622
glog: 0.3.3_3
libelf: 0.8.13_1
libdwarf: 20130207
unixODBC: 2.3.2_1
gnulibiberty: 2.19.1_2
libyaml: 0.1.6_1
jpeg: 8_6
cmake-modules: 3.0.2
gettext-runtime: 0.19.3
m4: 1.4.17_1,1
libgcrypt: 1.6.1_5
libgpg-error: 1.17
libevent2: 2.0.21_3
libidn: 1.29
libsigsegv: 2.10_1
p5-Authen-SASL: 2.16_1
p5-GSSAPI: 0.28_1
krb5: 1.13
perl5: 5.18.4_10
p5-Digest-HMAC: 1.03_1
p5-Net-SMTP-SSL: 1.01_3
p5-IO-Socket-SSL: 2.007
p5-Mozilla-CA: 20130114_1
p5-Net-SSLeay: 1.66_1
p5-Socket: 2.016_1
p5-IO-Socket-IP: 0.34
python27: 2.7.8_6
readline: 6.3.8
libffi: 3.0.13_3
p5-Error: 0.17022_1
p5-MIME-Base64: 3.14_1
libXext: 1.3.3,1
xproto: 7.0.26
xextproto: 7.3.0
libXau: 1.0.8_2
libX11: 1.6.2_2,1
libxcb: 1.11
libXdmcp: 1.1.1_2
libpthread-stubs: 0.3_6
kbproto: 1.0.6
libssh2: 1.4.3_4,2
libslang2: 2.2.4_6
png: 1.5.20
glib: 2.42.1
libiconv: 1.14_6
autoconf-wrapper: 20131203
gflags: 2.0_1

Installed packages to be UPGRADED:
expat: 2.1.0_1 -> 2.1.0_2
git: 2.1.2 -> 2.1.2_1

The process will require 518 MB more space.
79 MB to be downloaded.

Proceed with this action? [y/N]: y
………………
……………………
Fetching kbproto-1.0.6.txz: 100% 122 KB 31.2k/s 00:04
Fetching libssh2-1.4.3_4,2.txz: 100% 193 KB 49.3k/s 00:04
Fetching libslang2-2.2.4_6.txz: 100% 894 KB 91.6k/s 00:10
Fetching png-1.5.20.txz: 100% 230 KB 58.9k/s 00:04
Fetching glib-2.42.1.txz: 100% 3 MB 103.9k/s 00:27
Fetching libiconv-1.14_6.txz: 100% 591 KB 75.7k/s 00:08
Fetching autoconf-wrapper-20131203.txz: 100% 2 KB 2.2k/s 00:01
Fetching gflags-2.0_1.txz: 100% 140 KB 35.9k/s 00:04
Checking integrity…Assertion failed: (pkgdb_ensure_loaded(j->db, p2, PKG_LOAD_FILES|PKG_LOAD_DIRS) == EPKG_OK), function pkg_conflicts_need_conflict, file pkg_jobs_conflicts.c, line 211.
Child process pid=1060 terminated abnormally: Abort trap

I don’t know abuot that error
# pkg fetch -u
Updating Avalon repository catalogue…
Avalon repository is up-to-date.
All repositories are up-to-date.
The following packages will be fetched:

New packages to be FETCHED:
bind-tools-9.10.1P1 (25.78% of 9 MB: 2 MB)
ca_root_nss-3.17.3_1 (3.39% of 9 MB: 316 KB)
cdrtools-3.00_2 (7.59% of 9 MB: 707 KB)
curl-7.39.0_1 (14.48% of 9 MB: 1 MB)
cvsps-2.1_1 (0.38% of 9 MB: 36 KB)
gettext-0.19.3 (0.01% of 9 MB: 504 B)
idnkit-1.0_5 (2.15% of 9 MB: 200 KB)
indexinfo-0.2 (0.05% of 9 MB: 5 KB)
isc-dhcp42-server-4.2.7 (10.29% of 9 MB: 959 KB)
libxml2-2.9.2_2 (8.38% of 9 MB: 780 KB)
openssl-1.0.1_16 (27.49% of 9 MB: 3 MB)

The process will require 9 MB more space.
9 MB to be downloaded.

Proceed with fetching packages? [y/N]: y
Fetching bind-tools-9.10.1P1.txz: 100% 2 MB 98.4k/s 00:25
Fetching ca_root_nss-3.17.3_1.txz: 100% 316 KB 64.7k/s 00:05
Fetching cdrtools-3.00_2.txz: 100% 707 KB 90.5k/s 00:08
Fetching curl-7.39.0_1.txz: 100% 1 MB 92.1k/s 00:15
Fetching cvsps-2.1_1.txz: 100% 36 KB 18.3k/s 00:02
Fetching gettext-0.19.3.txz: 100% 504 B 0.5k/s 00:01
Fetching idnkit-1.0_5.txz: 100% 200 KB 41.0k/s 00:05
Fetching indexinfo-0.2.txz: 100% 5 KB 4.9k/s 00:01
Fetching isc-dhcp42-server-4.2.7.txz: 100% 959 KB 98.2k/s 00:10
Fetching libxml2-2.9.2_2.txz: 100% 780 KB 53.3k/s 00:15
Fetching openssl-1.0.1_16.txz: 100% 3 MB 114.0k/s 00:23

#pkg upgrade

and rerun the command

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

this time no error.

Check all installed package using pkg info

# pkg info
autoconf-2.69 Automatically configure source code on many Un*x platforms
autoconf-wrapper-20131203 Wrapper script for GNU autoconf
bind-tools-9.10.1P1 BIND DNS suite with updated DNSSEC and DNS64
binutils-2.24_1 GNU binary tools
bison-2.7.1,1 Parser generator from FSF, (mostly) compatible with Yacc
boost-libs-1.55.0_4 Free portable C++ libraries (without Boost.Python)
ca_root_nss-3.17.3_1 The root certificate bundle from the Mozilla Project
cclient-2007f_2,1 Mark Crispin’s C-client mail access routines
cdrtools-3.00_2 CD/DVD/BluRay and ISO-9660 image creation and extraction tools
cmake-3.0.2 Cross-platform Makefile generator
cmake-modules-3.0.2 Modules and Templates for CMake
curl-7.39.0_1 Non-interactive tool to get files from FTP, GOPHER, HTTP(S) servers
cvsps-2.1_1 Create patchset information from CVS
expat-2.1.0_2 XML 1.0 parser written in C
flex-2.5.39_2 Fast lexical analyzer generator
gawk-4.1.1_1 The GNU version of Awk
gettext-0.19.3 GNU gettext meta package
gettext-runtime-0.19.3 GNU gettext runtime libraries and programs
gettext-tools-0.19.3 GNU gettext development and translation tools
gflags-2.0_1 Commandline flags module for C++
git-2.1.2_1 Distributed source code management tool
glib-2.42.1 Some useful routines of C programming (current stable version)
glog-0.3.3_3 Library of C++ classes for flexible logging
gmake-4.1_1 GNU version of ‘make’ utility
gnulibiberty-2.19.1_2 Miscellaneous GNU functions
icu-53.1 International Components for Unicode (from IBM)
idnkit-1.0_5 Library to handle internationalized domain names
indexinfo-0.2 Utility to regenerate the GNU info page index
isc-dhcp42-server-4.2.7 The ISC Dynamic Host Configuration Protocol server
jpeg-8_6 IJG’s jpeg compression utilities
kbproto-1.0.6 KB extension headers
krb5-1.13 Authentication system developed at MIT, successor to Kerberos IV
libX11-1.6.2_2,1 X11 library
libXau-1.0.8_2 Authentication Protocol library for X11
libXdmcp-1.1.1_2 X Display Manager Control Protocol library
libXext-1.3.3,1 X11 Extension library
libdwarf-20130207 Library to analyze DWARF debugging information in ELF files
libedit-3.1.20141030 Command line editor library
libelf-0.8.13_1 Public ELF file access library similar to libelf(3) in Solaris
libevent-hiphop-1.4.14b_4 Static libevent with custom patches for HipHop
libevent2-2.0.21_3 API for executing callback functions on events or timeouts
libexecinfo-1.1_3 Library for inspecting program’s backtrace
libffi-3.0.13_3 Foreign Function Interface
libgcrypt-1.6.1_5 General purpose crypto library based on code used in GnuPG
libgpg-error-1.17 Common error values for all GnuPG components
libiconv-1.14_6 Character set conversion library
libidn-1.29 Internationalized Domain Names command line tool
libinotify-20140622 Kevent based inotify compatible library
libmcrypt-2.5.8_2 Multi-cipher cryptographic library (used in PHP)
libmemcached-1.0.7_4 C and C++ client library to the memcached server
libpthread-stubs-0.3_6 This library provides weak aliases for pthread functions
libsigsegv-2.10_1 Handling page faults in user mode
libslang2-2.2.4_6 Routines for rapid alpha-numeric terminal applications development
libssh2-1.4.3_4,2 Library implementing the SSH2 protocol
libxcb-1.11 The X protocol C-language Binding (XCB) library
libxml2-2.9.2_2 XML parser library for GNOME
libxslt-1.1.28_5 The XSLT C library for GNOME
libyaml-0.1.6_1 YAML 1.1 parser and emitter written in C
libzip-0.11.2_1 C library for reading, creating, and modifying ZIP archives
lz4-r101 Fast compressor using LZ4 algorithm
m4-1.4.17_1,1 GNU m4
mc-4.8.13_3 Midnight Commander, a free Norton Commander Clone
mysql56-client-5.6.22 Multithreaded SQL database (client)
oniguruma-2.5.8 BSDL Regular Expressions library compatible with POSIX/GNU/Perl
openldap-client-2.4.40_1 Open source LDAP client implementation
openssl-1.0.1_16 SSL and crypto library
p5-Authen-SASL-2.16_1 Perl5 module for SASL authentication
p5-Digest-HMAC-1.03_1 Perl5 interface to HMAC Message-Digest Algorithms
p5-Error-0.17022_1 Error/exception handling in object-oriented programming style
p5-GSSAPI-0.28_1 Perl extension providing access to the GSSAPIv2 library
p5-IO-Socket-IP-0.34 Drop-in replacement for IO::Socket::INET supporting IPv4 and IPv6
p5-IO-Socket-SSL-2.007 Perl5 interface to SSL sockets
p5-MIME-Base64-3.14_1 Perl5 module for Base64 and Quoted-Printable encodings
p5-Mozilla-CA-20130114_1 Perl extension for Mozilla CA cert bundle in PEM format
p5-Net-SMTP-SSL-1.01_3 SSL support for Net::SMTP
p5-Net-SSLeay-1.66_1 Perl5 interface to SSL
p5-Socket-2.016_1 Networking constants and support functions
pcre-8.35_2 Perl Compatible Regular Expressions library
perl5-5.18.4_10 Practical Extraction and Report Language
pkg-1.4.0 Package manager
png-1.5.20 Library for manipulating PNG images
python27-2.7.8_6 Interpreted object-oriented programming language
re2c-0.13.6 Compile regular expression to C (much faster final code than flex)
readline-6.3.8 Library for editing command lines as they are typed
sqlite3-3.8.7.2 SQL database engine in a C library
unixODBC-2.3.2_1 ODBC library suite for Unix
wget-1.16 Retrieve files from the Net via HTTP(S) and FTP
xextproto-7.3.0 XExt extension headers
xproto-7.0.26 X11 protocol headers
#

Great.

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: 183, done.
remote: Compressing objects: 100% (165/165), done.
remote: Total 183 (delta 17), reused 70 (delta 13)
Receiving objects: 100% (183/183), 375.51 KiB | 78.00 KiB/s, done.
Resolving deltas: 100% (17/17), 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 ~/hhvm340
# cd ~/hhvm340/
# mkdir libs

Get latest HHVM code (3.4.0 in this case)

# git clone git://github.com/facebook/hhvm.git --depth=1
Cloning into ‘hhvm’…
remote: Counting objects: 42811, done.
remote: Compressing objects: 100% (32476/32476), done.
remote: Total 42811 (delta 6721), reused 31227 (delta 5930)
Receiving objects: 100% (42811/42811), 21.94 MiB | 167.00 KiB/s, done.
Resolving deltas: 100% (6721/6721), done.
Checking connectivity… done.
Checking out files: 100% (55165/55165), 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: 2444, done.
remote: Total 2444 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (2444/2444), 6.87 MiB | 154.00 KiB/s, done.
Resolving deltas: 100% (1253/1253), done.
Checking connectivity… done.
Submodule path ‘third-party’: checked out ‘230cd6e82bf900581136c242173257afcf025b78’
Submodule ‘folly’ (https://github.com/facebook/folly.git) registered for path ‘folly/src’
Submodule ‘proxygen/src’ (https://github.com/facebook/proxygen) registered for path ‘proxygen/src’
Submodule ‘thrift/src’ (https://github.com/facebook/fbthrift.git) registered for path ‘thrift/src’
Cloning into ‘folly/src’…
remote: Counting objects: 9507, done.
remote: Total 9507 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (9507/9507), 4.23 MiB | 138.00 KiB/s, done.
Resolving deltas: 100% (7262/7262), done.
Checking connectivity… done.
Submodule path ‘third-party/folly/src’: checked out ‘6f9b619d9ffc219296a818a83266d60628e6aedd’
Cloning into ‘proxygen/src’…
remote: Counting objects: 1726, done.
remote: Total 1726 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (1726/1726), 760.78 KiB | 104.00 KiB/s, done.
Resolving deltas: 100% (1203/1203), done.
Checking connectivity… done.
Submodule path ‘third-party/proxygen/src’: checked out ‘8a602aa40383d6dddbdcb2a951067b9923edfc74’
Cloning into ‘thrift/src’…
remote: Counting objects: 10393, done.
remote: Total 10393 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (10393/10393), 5.61 MiB | 106.00 KiB/s, done.
Resolving deltas: 100% (7696/7696), done.
Checking connectivity… done.
Submodule path ‘third-party/thrift/src’: checked out ‘bba5d4590ff71e8f34ce4f90a8d7b2cf867ca3d0’

Try to create binary

# cmake .
— The C compiler identification is GNU 4.7.4
— The CXX compiler identification is GNU 4.7.4
— The ASM compiler identification is GNU
— Found assembler: /usr/bin/cc
— Check for working C compiler: /usr/bin/cc
— Check for working C compiler: /usr/bin/cc — works
— Detecting C compiler ABI info
— Detecting C compiler ABI info – done
— Check for working CXX compiler: /usr/bin/CC
— Check for working CXX compiler: /usr/bin/CC — works
— Detecting CXX compiler ABI info
— Detecting CXX compiler ABI info – done
— Performing Test IS_AARCH64
— Performing Test IS_AARCH64 – Failed
— Build type not specified: cmake build type Release.
CMake Error at CMake/HPHPCompiler.cmake:50 (message):
hhvm requires g++ 4.8 or greater.
Call Stack (most recent call first):
CMake/HPHPSetup.cmake:95 (include)
third-party/CMakeLists.txt:18 (include)
— Configuring incomplete, errors occurred!
See also “/root/hhvm340/hhvm/CMakeFiles/CMakeOutput.log”.
See also “/root/hhvm340/hhvm/CMakeFiles/CMakeError.log”.
# gcc -v
Using built-in specs.
COLLECT_GCC=/usr/libexec/gcc47/gcc
Target: x86_64-pc-dragonflybsd
Configured with: DragonFly/x86_64 system compiler (c, c++, objc, LTO)
Thread model: posix
gcc version 4.7.4 [DragonFly] Release/2014-06-12
#

Ups 🙂

# pkg search gcc
arm-none-eabi-gcc-4.9.1_1
avr-gcc-4.8.3_1
avr-gcc-devel-4.10.0.s20140803
colorgcc-1.3.2
gcc-4.8.3_2
gcc-arm-embedded-4.8.20140805
gcc-aux-20141023_1
gcc-ecj-4.5
gcc46-4.6.4_4,1
gcc47-4.7.4_2,1
gcc47-aux-20140612_1
gcc48-4.8.4.s20141120
gcc49-4.9.3.s20141126
gcc5-5.0.s20141130
gccmakedep-1.0.2_1
mingw32-gcc-4.7.2_2,1
msp430-gcc-4.6.3.20120406_3,2
psptoolchain-gcc-stage1-4.6.2_3
psptoolchain-gcc-stage2-4.6.2_3
tigcc-0.96.b8_3
zpu-gcc-1.0

# pkg install gcc48
Updating Avalon repository catalogue…
Avalon repository is up-to-date.
All repositories are up-to-date.
The following 4 packages will be affected (of 0 checked):

New packages to be INSTALLED:
gcc48: 4.8.4.s20141120
mpfr: 3.1.2_2
gmp: 5.1.3_2
mpc: 1.0.2_1

The process will require 140 MB more space.
31 MB to be downloaded.

Proceed with this action? [y/N]: y

……………
………………..

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.

Retry create hhvm binary.

#cmake .
— Build type not specified: cmake build type Release.
CMake Error at CMake/HPHPCompiler.cmake:50 (message):
hhvm requires g++ 4.8 or greater.
Call Stack (most recent call first):
CMake/HPHPSetup.cmake:95 (include)
third-party/CMakeLists.txt:18 (include)
— Configuring incomplete, errors occurred!
See also “/root/hhvm340/hhvm/CMakeFiles/CMakeOutput.log”.
See also “/root/hhvm340/hhvm/CMakeFiles/CMakeError.log”.

Still found error.

# env
VENDOR=amd
SSH_CLIENT=192.168.43.94 58865 22
LOGNAME=alam
PAGER=less
OSTYPE=DragonFly
MACHTYPE=x86_64
FTP_PASSIVE_MODE=YES
CC=gcc48
MAIL=/var/mail/alam
CMAKE_PREFIX_PATH=/root/hhvm340/libs
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/pkg/bin:/usr/pkg/sbin:/usr/games:/root/bin
EDITOR=vi
HOST=
PWD=/root/hhvm340/hhvm
GROUP=wheel
TERM=xterm
SSH_TTY=/dev/pts/0
HOME=/root
USER=alam
CXX=g++48
SSH_CONNECTION=192.168.43.94 58865 192.168.43.39 22
HOSTTYPE=DragonFly
SHELL=/bin/csh
BLOCKSIZE=K
SHLVL=2

well I need to take a break now 🙂