summaryrefslogtreecommitdiff
path: root/hhvm.spec
blob: aeaa3c09d295c396bb8e2af18ac57cb3425bd7fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
#
# Conditional build:
%bcond_without	system_dconv	# system double-conversion
%bcond_without	system_sqlite	# system sqlite3
%bcond_without	system_lz4		# system lz4
%bcond_without	system_fastlz	# system fastlz
%bcond_with	system_libafdt	# system libafdt
%bcond_without	system_libzip	# system libzip
# cotire breaks sqlite3 on builders: https://github.com/facebook/hhvm/issues/4524
%bcond_with	cotire			# cotire (compile time reducer): Speed up the build by precompiling headers

# TODO
# - system xhp
# - system proxygen
# - system thrift

# NOTES:
# - hphp/runtime/base/runtime-option.cpp evalJitDefault enables jit if /.hhvm-jit exists (yes, in filesystem root)

# must be in sync with source. extra check ensuring that it is so is done in %%build
%define		hhvm_api_version	20140829
# hphp/system/idl/constants.idl.json defines it as 5.6.99-hhvm, but use some saner value
%define		php_version			5.6.0

# git show HHVM-3.3.7
%define		githash	e0344cb6ab126e50e611332f03f447f586cc763a
# these hashes are git submodules (be sure to check them on proper branch)
# GIT_DIR=third-party/.git git log -1
%define		thirdparty	bf581f8
# GIT_DIR=third-party/folly/src/.git git log -1
%define		folly		6e46d46
Summary:	Virtual Machine, Runtime, and JIT for PHP
Name:		hhvm
# we prefer LTS versions
# see http://hhvm.com/blog/6083/hhvm-long-term-support
Version:	3.3.7
Release:	14
License:	PHP 3.01 and BSD
Group:		Development/Languages
Source0:	https://github.com/facebook/hhvm/archive/HHVM-%{version}.tar.gz
# Source0-md5:	8df12eef8702515498d6a6caab6e4b7d
Source2:	https://github.com/facebook/folly/archive/%{folly}/folly-3.2-%{folly}.tar.gz
# Source2-md5:	c4bdbea4c0ffe0650d12d9ff370b8255
Source3:	https://github.com/hhvm/hhvm-third-party/archive/%{thirdparty}/third_party-%{thirdparty}.tar.gz
# Source3-md5:	17210db0b2211c63d911076e02aab487
Source5:	%{name}-fcgi.init
Source6:	%{name}-fcgi.sysconfig
Source7:	php.ini
Source100:	get-source.sh
Patch1:		no-debug.patch
Patch2:		hphpize.patch
Patch3:		MAX.patch
Patch4:		system-thirdparty.patch
Patch5:		cmake.patch
Patch6:		libvpx2.patch
Patch7:		gcc5.patch
Patch8:		cxx.patch
Patch9:		gcc6.patch
Patch10:	libevent-2.1.patch
Patch11:	icu59.patch
Patch12:	no-mysql_r.patch
URL:		https://github.com/facebook/hhvm/wiki
BuildRequires:	ImageMagick-devel
BuildRequires:	a52dec-libs-devel
BuildRequires:	apr-devel
BuildRequires:	autoconf
BuildRequires:	binutils-devel
# CMake/HPHPFindLibs.cmake:364 - FIND_LIBRARY (BFD_LIB libbfd.a)
BuildRequires:	binutils-static
BuildRequires:	boost-devel >= 1.50
BuildRequires:	cmake >= 2.8.5
BuildRequires:	curl-devel >= 7.29.0
%{?with_system_dconv:BuildRequires:	double-conversion-devel >= 1.1.1}
BuildRequires:	elfutils-devel
BuildRequires:	expat-devel
%{?with_system_fastlz:BuildRequires:	fastlz-devel >= 0.1.0-0.r12}
BuildRequires:	gcc >= 6:4.6.0
BuildRequires:	gd-devel
BuildRequires:	glog-devel >= 0.3.2
BuildRequires:	imap-devel >= 1:2007
#BuildRequires:	jemalloc-devel >= 3.0.0
%{?with_system_libafdt:BuildRequires:	libafdt-devel >= 0.1.0}
BuildRequires:	libcap-devel
BuildRequires:	libdwarf-devel >= 20130729
BuildRequires:	libicu-devel >= 4.2
#BuildRequires:	libmbfl-devel
BuildRequires:	libmcrypt-devel
BuildRequires:	libmemcached-devel >= 1.0.4
BuildRequires:	libstdc++-devel >= 6:4.8
BuildRequires:	libunwind-devel
BuildRequires:	libxml2-devel
BuildRequires:	libxslt-devel
%{?with_system_libzip:BuildRequires:	libzip-devel >= 0.11.2}
%{?with_system_lz4:BuildRequires:	lz4-devel >= 0.0-1.r119}
BuildRequires:	mysql-devel
BuildRequires:	ocaml-findlib
BuildRequires:	oniguruma-devel
BuildRequires:	openssl-devel
BuildRequires:	pcre-devel >= 8.32
#BuildRequires:	php-xhp-devel >= 1.3.9-6
BuildRequires:	readline-devel
BuildRequires:	rpmbuild(macros) >= 1.675
%{?with_system_sqlite:BuildRequires:	sqlite3-devel >= 3.7.15.2}
BuildRequires:	tbb-devel >= 4.0.6000
BuildRequires:	zlib-devel
# check later, seem unused
#BuildRequires:	bison >= 2.3
#BuildRequires:	flex >= 2.5.35
BuildRequires:	libafdt-devel >= 0.1.0
#BuildRequires:	re2c >= 0.13.0
BuildConflicts:	ImageMagick6-devel
Provides:	%{name}(api) = %{hhvm_api_version}
Provides:	php(core) = %{php_version}
# foreach (get_loaded_extensions() as $ext) printf("Provides:\tphp(%s)\n", strtolower($ext));
Provides:	php(apc)
Provides:	php(bcmath)
Provides:	php(bz2)
Provides:	php(calendar)
Provides:	php(ctype)
Provides:	php(curl)
Provides:	php(date)
Provides:	php(debugger)
Provides:	php(dom)
Provides:	php(enum)
Provides:	php(exif)
Provides:	php(fb)
Provides:	php(fileinfo)
Provides:	php(filter)
Provides:	php(ftp)
Provides:	php(gd)
Provides:	php(gettext)
Provides:	php(gmp)
Provides:	php(hash)
Provides:	php(hh)
Provides:	php(hhvm.debugger)
Provides:	php(hhvm.ini)
Provides:	php(hotprofiler)
Provides:	php(iconv)
Provides:	php(idn)
Provides:	php(imagick)
Provides:	php(imap)
Provides:	php(intl)
Provides:	php(json)
Provides:	php(ldap)
Provides:	php(libxml)
Provides:	php(mail)
Provides:	php(mailparse)
Provides:	php(mbstring)
Provides:	php(mcrypt)
Provides:	php(memcache)
Provides:	php(memcached)
Provides:	php(mysql)
Provides:	php(mysqli)
Provides:	php(oauth)
Provides:	php(openssl)
Provides:	php(pcntl)
Provides:	php(pcre)
Provides:	php(pcre_zend_compat)
Provides:	php(pdo)
Provides:	php(pdo_mysql)
Provides:	php(pdo_sqlite)
Provides:	php(phar)
Provides:	php(posix)
Provides:	php(redis)
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(standard)
Provides:	php(standard_zend_compat)
Provides:	php(stream)
Provides:	php(sysvmsg)
Provides:	php(sysvsem)
Provides:	php(sysvshm)
Provides:	php(thread)
Provides:	php(thrift_protocol)
Provides:	php(tokenizer)
Provides:	php(url)
Provides:	php(wddx)
Provides:	php(xenon)
Provides:	php(xhprof)
Provides:	php(xml)
Provides:	php(xmlreader)
Provides:	php(xmlwriter)
Provides:	php(xsl)
Provides:	php(yaml)
Provides:	php(zip)
Provides:	php(zlib)
Obsoletes:	hiphop-php < 2.3.2-0.2
ExclusiveArch:	%{x8664}
BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)


%define		hhvm_extensiondir	%{_libdir}/hhvm

%description
HHVM (aka the HipHop Virtual Machine) is a new open-source virtual
machine designed for executing programs written in PHP. HHVM uses a
just-in-time compilation approach to achieve superior performance
while maintaining the flexibility that PHP developers are accustomed
to. To date, HHVM (and its predecessor HPHPc before it) has realized
over a 9x increase in web request throughput and over a 5x reduction
in memory consumption for Facebook compared with the Zend PHP 5.2
engine + APC.

HHVM can be run as a standalone webserver (i.e. without the Apache
webserver and the "mod_php" extension). HHVM can also be used together
with a FastCGI-based webserver, and work is in progress to make HHVM
work smoothly with Apache.

%package fcgi
Summary:	Init script to start HHVM as FastCGI daemon
Group:		Development/Languages/PHP
Requires:	%{name} = %{version}-%{release}
Provides:	php(fcgi)
Requires(post,preun):	/sbin/chkconfig
Requires:	rc-scripts

%description fcgi
Init script to start HHVM as FastCGI daemon

%package program
Summary:	/usr/bin/php symlink
Summary(pl.UTF-8):	Dowiązanie symboliczne /usr/bin/php
Group:		Development/Languages/PHP
Requires:	%{name} = %{version}-%{release}
Obsoletes:	/usr/bin/php

%description program
Package providing /usr/bin/php symlink to PHP CLI.

%description program -l pl.UTF-8
Pakiet dostarczający dowiązanie symboliczne /usr/bin/php do PHP CLI.

%package devel
Summary:	Files for HHVM modules development
Group:		Development/Languages/PHP
URL:		https://github.com/facebook/hhvm/wiki/Extension-API
Requires:	boost-devel >= 1.50
Requires:	cmake >= 2.8.5
Requires:	glog-devel >= 0.3.2
Requires:	libstdc++-devel >= 6:4.3
Requires:	tbb-devel >= 4.0.6000
Requires:	zlib-devel

%description devel
HHVM provides a set of APIs for adding built-in functionality to the
runtime either by way of pure PHP code, or a combination of PHP and
C++.

%prep
%setup -q -n %{name}-HHVM-%{version} -a2 -a3

# handle git submodules
rmdir third-party
mv hhvm-third-party-* third-party
rmdir third-party/folly/src
mv folly-* third-party/folly/src

%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
#%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch9 -p1
%patch10 -p1
%patch11 -p1
%patch12 -p1

# prefer ones from system
rm CMake/FindBISON.cmake
rm CMake/FindFLEX.cmake
rm CMake/FindFreetype.cmake

# ensure system libs get used
cd third-party
rm -r pcre \
	%{?with_system_sqlite:libsqlite3} \
	%{?with_system_lz4:lz4} \
	%{?with_system_dconv:double-conversion} \
	%{?with_system_fastlz:fastlz} \
	%{?with_system_libafdt:libafdt} \
	%{?with_system_libzip:libzip} \
	%{nil}

%build
# also in: hphp/tools/hphpize/hphpize.cmake
API=$(awk '/#define HHVM_API_VERSION/{v=$3; sub(/L$/, "", v); print v}' hphp/runtime/ext/extension.h)

if [ $API != %{hhvm_api_version} ]; then
	echo "Set %%define hhvm_api_version to $API and re-run."
	exit 1
fi

export CXXFLAGS="%{rpmcxxflags} -fpermissive -I/usr/include/lz4"

# out of dir build broken (can't find it's tools, or headers)
#install -d build
#cd build

# handle cmake & ccache
# http://stackoverflow.com/questions/1815688/how-to-use-ccache-with-cmake
# ASM fix: http://lists.busybox.net/pipermail/buildroot/2013-March/069436.html
if [[ "%{__cc}" = *ccache* ]]; then
	cc="%{__cc}"
	cxx="%{__cxx}"
	ccache="
	-DCMAKE_C_COMPILER="ccache" -DCMAKE_C_COMPILER_ARG1="${cc#ccache }" \
	-DCMAKE_CXX_COMPILER="ccache" -DCMAKE_CXX_COMPILER_ARG1="${cxx#ccache }" \
	-DCMAKE_ASM_COMPILER="${cc#ccache }" \
	"
fi

%cmake \
	$ccache \
	-DCMAKE_PREFIX_PATH=%{_prefix} \
	-DHHVM_DYNAMIC_EXTENSION_DIR=%{hhvm_extensiondir} \
	-DUSE_JEMALLOC=OFF \
	-DUSE_TCMALLOC=OFF \
	-DTEST_BIN=OFF \
	-DENABLE_COTIRE=%{!?with_cotire:OFF}%{?with_cotire:ON} \
	.

# setup COMPILER_ID/HHVM_REPO_SCHEMA so it doesn't look it up from our package git repo
# see hphp/util/generate-buildinfo.sh
export COMPILER_ID=HHVM-%{version}-%{release}-g%{githash}
export HHVM_REPO_SCHEMA=$(date +%N_%s)

%{__make}

%install
# make install relinks all outputs which is very slow,
# so to speedup rebuild, use timestamps to record states
#test %{_specdir}/%{name}.spec -nt makeinstall.stamp && %{__rm} -f makeinstall.stamp
if [ ! -f makeinstall.stamp -o ! -d $RPM_BUILD_ROOT ]; then
	rm -rf makeinstall.stamp installed.stamp $RPM_BUILD_ROOT

	%{__make} install \
		DESTDIR=$RPM_BUILD_ROOT

	touch makeinstall.stamp
fi

rm -rf $RPM_BUILD_ROOT%{_docdir}
if [ ! -f installed.stamp ]; then
# begin install block

# fix broken cmake rules
# TODO: fix cmake rules
if [ -d $RPM_BUILD_ROOT%{_prefix}/usr ]; then
	cp -a $RPM_BUILD_ROOT%{_prefix}/usr/* $RPM_BUILD_ROOT%{_prefix}
	rm -rf $RPM_BUILD_ROOT%{_prefix}/usr
fi

install -d $RPM_BUILD_ROOT{%{_sysconfdir}/%{name},%{_libdir}/%{name}}
cp -p %{SOURCE7} $RPM_BUILD_ROOT%{_sysconfdir}/%{name}

ln -s hhvm $RPM_BUILD_ROOT%{_bindir}/php
ln -s hhvm $RPM_BUILD_ROOT%{_bindir}/hphp

install -d $RPM_BUILD_ROOT%{_datadir}/%{name}/hdf
cp -p hphp/doc/mime.hdf $RPM_BUILD_ROOT%{_datadir}/%{name}/hdf/static.mime-types.hdf

# install fastcgi initscript
install -d $RPM_BUILD_ROOT/etc/{sysconfig,rc.d/init.d}
cp -p %{SOURCE5} $RPM_BUILD_ROOT/etc/rc.d/init.d/%{name}-fcgi
cp -p %{SOURCE6} $RPM_BUILD_ROOT/etc/sysconfig/%{name}-fcgi

install -p hphp/hack/bin/hh_{server,client} $RPM_BUILD_ROOT%{_bindir}

# end of install block
touch installed.stamp; fi

%clean
rm -rf $RPM_BUILD_ROOT

%post	-p /sbin/ldconfig
%postun	-p /sbin/ldconfig

%post fcgi
/sbin/chkconfig --add %{name}-fcgi
%service %{name}-fcgi restart

%preun fcgi
if [ "$1" = "0" ]; then
	%service -q %{name}-fcgi stop
	/sbin/chkconfig --del %{name}-fcgi
fi

%files
%defattr(644,root,root,755)
%doc README.md hphp/NEWS
%dir %{_sysconfdir}/%{name}
%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/%{name}/php.ini
%attr(755,root,root) %{_bindir}/hhvm
%attr(755,root,root) %{_bindir}/hphp
%attr(755,root,root) %{_bindir}/hh_client
%attr(755,root,root) %{_bindir}/hh_server

%dir %{_datadir}/%{name}
%dir %{_datadir}/%{name}/hdf
%{_datadir}/%{name}/hdf/static.mime-types.hdf

# dir for extensions
%dir %{_libdir}/%{name}

%files fcgi
%defattr(644,root,root,755)
%attr(754,root,root) /etc/rc.d/init.d/%{name}-fcgi
%config(noreplace) %verify(not md5 mtime size) /etc/sysconfig/%{name}-fcgi

%files program
%defattr(644,root,root,755)
%attr(755,root,root) %{_bindir}/php

%files devel
%defattr(644,root,root,755)
%attr(755,root,root) %{_bindir}/hphpize
%{_includedir}/hphp
%dir %{_libdir}/hhvm
%{_libdir}/hhvm/CMake
%{_libdir}/hhvm/hphpize