+# NOTES:
+# - hphp/runtime/base/runtime-option.cpp evalJitDefault enables jit if /.hhvm-jit exists (yes, in filesystem root)
# TODO
# - system libevent2: https://github.com/facebook/hiphop-php/pull/421
-# - build with newer libmemcached than 1.0.7, https://github.com/facebook/hiphop-php/issues/560
# - system libmbfl, system xhp, sqlite3
-# - there should be a bit more packaged into files
-# - linking segfaults
-# using bfd and gcc-6:4.6.2-2.x86_64 binutils-3:2.22.51.0.1-1.x86_64
-# cd /home/users/glen/rpm/packages/BUILD.x86_64-linux/hiphop-php-1.000_cf9b612/src/hphpi && /home/users/glen/rpm/BUILD.x86_64-linux/hiphop-php-1.000_cf9b612/build/src/hphp/hphp -t cpp -f exe --input-dir . -i hphpi.php -o gen -vEnableEval=2 --log=1
-# Segmentation fault
-# make[2]: *** [src/hphp/hphp] Error 139
-# relinking succeeds, but resulting binary segfaults as well:
-# 0x0000000000b9cc0b in HPHP::Extension::LoadModules(HPHP::Hdf) ()
%define githash 78394ee
-%define rel 0.2
+%define rel 3
Summary: Virtual Machine, Runtime, and JIT for PHP
Name: hiphop-php
Version: 2.1.0
BuildRequires: elfutils-devel
BuildRequires: expat-devel
BuildRequires: flex >= 2.5.35
+BuildRequires: gcc >= 6:4.6.0
BuildRequires: gd-devel
BuildRequires: glog-devel >= 0.3.2
BuildRequires: imap-devel >= 1:2007
#BuildRequires: php-xhp-devel >= 1.3.9-6
BuildRequires: re2c >= 0.13.0
BuildRequires: readline-devel
-BuildRequires: rpmbuild(macros) >= 1.600
+BuildRequires: rpmbuild(macros) >= 1.675
BuildRequires: tbb-devel >= 4.0.6000
BuildRequires: zlib-devel
+Provides: php(apc)
+Provides: php(bcmath)
+Provides: php(ctype)
+Provides: php(curl)
+Provides: php(date)
+Provides: php(dom)
+Provides: php(exif)
+Provides: php(fb)
+Provides: php(filter)
+Provides: php(gd)
+Provides: php(hash)
+Provides: php(hotprofiler)
+Provides: php(iconv)
+Provides: php(icu_ucsdet)
+Provides: php(icu_uspoof)
+Provides: php(idn)
+Provides: php(imap)
+Provides: php(json)
+Provides: php(ldap)
+Provides: php(mbstring)
+Provides: php(mcrypt)
+Provides: php(memcache)
+Provides: php(memcached)
+Provides: php(mysql)
+Provides: php(openssl)
+Provides: php(pcntl)
+Provides: php(pcre)
+Provides: php(pdo)
+Provides: php(pdo_mysql)
+Provides: php(pdo_sqlite)
+Provides: php(phar)
+Provides: php(posix)
+Provides: php(reflection)
+Provides: php(server)
+Provides: php(session)
+Provides: php(simplexml)
+Provides: php(soap)
+Provides: php(sockets)
+Provides: php(spl)
+Provides: php(sqlite3)
+Provides: php(sysvmsg)
+Provides: php(sysvsem)
+Provides: php(sysvshm)
+Provides: php(thread)
+Provides: php(thrift_protocol)
+Provides: php(tokenizer)
+Provides: php(xhprof)
+Provides: php(xml)
+Provides: php(xmlreader)
+Provides: php(xmlwriter)
+Provides: php(zlib)
+ExclusiveArch: %{x8664}
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
-# strip would remove systemlib.php copied into binary
-# see CMake/HPHPFunctions.cmake embed_systemlib function
-%define _noautostrip .*%{_bindir}/hhvm
-
%description
HipHop VM (HHVM) is a new open-source virtual machine designed for
executing programs written in PHP. HHVM uses a just-in-time
%prep
%setup -qc -a1
mv %{name}-%{githash}*/* .
-%patch5 -p1
+
+#%patch5 -p1
%patch6 -p1
ln -s libevent-1.4.*-stable libevent
export HPHP_HOME=$(pwd)
export HPHP_LIB=$HPHP_HOME/bin
+# asm linking breaks on $CC containing spaces
+if [[ "%{__cc}" = *ccache* ]]; then
+ cat <<-'EOF' > $HPHP_LIB/gcc
+ #!/bin/sh
+ exec %{__cc} "$@"
+ EOF
+ chmod +x $HPHP_LIB/gcc
+ CC=$HPHP_LIB/gcc
+fi
+
%if 0
export LIBEVENT_PREFIX=$HPHP_HOME/libevent
cd build
%endif
-CPPFLAGS="%{rpmcppflags} -fno-permissive"
%cmake \
-DLIBEVENT_LIB=$HPHP_HOME/libevent/lib/libevent.so \
-DLIBEVENT_INCLUDE_DIR=$HPHP_HOME/libevent \
-DUSE_JEMALLOC=OFF \
-DUSE_TCMALLOC=OFF \
./
+
+# setup COMPILER_ID/HHVM_REPO_SCHEMA so it doesn't look it up from our package git repo
+# see hphp/util/generate-buildinfo.sh
+sha=$(echo %{name}-%{githash}*)
+export COMPILER_ID=HPHP-%{version}-%{release}-${sha#%{name}-}
+export HHVM_REPO_SCHEMA=$(date +%N_%s)
+
%{__make}
%install
rm -rf $RPM_BUILD_ROOT
%{__make} install \
+ HPHP_HOME=$(pwd) \
DESTDIR=$RPM_BUILD_ROOT
install -d $RPM_BUILD_ROOT%{_datadir}/%{name}/hdf