-
Notifications
You must be signed in to change notification settings - Fork 3k
/
hhvm.nix
284 lines (274 loc) · 6.76 KB
/
hhvm.nix
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
{ bison
, boost
, brotli
, bzip2
, cacert
, cmake
, curl
, darwin
, double-conversion
, editline
, expat
, flex
, fmt_8
, freetype
, fribidi
, gcc-unwrapped
, gd
, gdb
, gettext
, gflags
, git
, glog
, gmp
, gperf
, gperftools
, hostPlatform
, icu
, imagemagick6
, jemalloc
, lastModifiedDate
, lib
, libcap
, libdwarf_20210528
, libedit
, libelf
, libevent
, libkrb5
, libmcrypt
, libmemcached
, libpng
, libsodium
, libunwind
, libvpx
, libxml2
, libxslt
, libzip
, linux-pam
, lz4
, numactl
, oniguruma
, openldap
, openssl_1_1
, pcre
, perl
, pkg-config
, python3
, re2
, re2c
, rustChannelOf
, stdenv
, sqlite
, tbb
, tzdata
, unixtools
, unzip
, uwimap
, which
, writeTextFile
, zlib
, zstd
}:
let
# TODO(https://github.com/NixOS/nixpkgs/pull/193086): Use stdenv.cc.libcxx once it is available
isDefaultStdlib =
builtins.match ".*-stdlib=\+\+.*" (builtins.readFile "${stdenv.cc}/nix-support/libcxx-ldflags") == null;
versionParts =
builtins.match
''
.*
#[[:blank:]]*define[[:blank:]]+HHVM_VERSION_MAJOR[[:blank:]]+([[:digit:]]+)
#[[:blank:]]*define[[:blank:]]+HHVM_VERSION_MINOR[[:blank:]]+([[:digit:]]+)
#[[:blank:]]*define[[:blank:]]+HHVM_VERSION_PATCH[[:blank:]]+([[:digit:]]+)
#[[:blank:]]*define[[:blank:]]+HHVM_VERSION_SUFFIX[[:blank:]]+"([^"]*)"
.*
''
(builtins.readFile ./hphp/runtime/version.h);
makeVersion = major: minor: patch: suffix:
if suffix == "-dev" then "${major}.${minor}.${patch}-dev${lastModifiedDate}" else "${major}.${minor}.${patch}";
rustChannel = rustChannelOf {
# When the date attribute changes, sha256 should be updated accordingly.
#
# 1. Export your diff to GitHub;
# 2. Wait for an error message about sha256 mismatch from the GitHub
# Actions;
# 3. Copy the new sha256 from the error message and paste it here;
# 4. Submit the diff and export the diff to GitHub, again.
# 5. Ensure no error message about sha256 mismatch from the GitHub Actions.
sha256 = "wVnIzrnpYGqiCBtc3k55tw4VW8YLA3WZY0mSac+2yl0=";
date = "2022-08-11";
channel = "nightly";
};
in
stdenv.mkDerivation rec {
rust = rustChannel.rust;
pname = "hhvm";
version = builtins.foldl' lib.trivial.id makeVersion versionParts;
src = ./.;
nativeBuildInputs =
[
bison
cacert
cmake
flex
pkg-config
python3
unixtools.getconf
which
] ++ lib.optionals hostPlatform.isMacOS [
# `system_cmds` provides `sysctl`, which is used in hphp/test/run.php on macOS
darwin.system_cmds
];
buildInputs =
[
(if isDefaultStdlib then boost else boost.override { inherit stdenv; })
brotli
bzip2
(curl.override { openssl = openssl_1_1; })
(
if isDefaultStdlib then
double-conversion
else
double-conversion.override { inherit stdenv; }
)
editline
expat
(if isDefaultStdlib then fmt_8 else fmt_8.override { inherit stdenv; })
freetype
fribidi
# Workaround for https://github.com/NixOS/nixpkgs/issues/192665
gcc-unwrapped.lib
gd
gdb
gettext
git
(
if isDefaultStdlib then
glog
else
(glog.override {
inherit stdenv;
gflags = gflags.override { inherit stdenv; };
}).overrideAttrs
(finalAttrs: previousAttrs: {
# Workaround for https://github.com/google/glog/issues/709
doCheck = !stdenv.cc.isClang;
})
)
gmp
(if isDefaultStdlib then gperf else gperf.override { inherit stdenv; })
(
if isDefaultStdlib then
gperftools
else
gperftools.override { inherit stdenv; }
)
(if isDefaultStdlib then icu else icu.override { inherit stdenv; })
imagemagick6
jemalloc
libdwarf_20210528
libedit
libelf
libevent
libkrb5
libmcrypt
libmemcached
libpng
libsodium
libunwind
libvpx
libxml2
libxslt
libzip
lz4
oniguruma
openldap
openssl_1_1
pcre
perl
re2
re2c
sqlite
(if isDefaultStdlib then tbb else tbb.override { inherit stdenv; })
tzdata
unzip
zlib
zstd
]
++ lib.optionals hostPlatform.isLinux [
libcap
linux-pam
numactl
uwimap
]
++ lib.optionals hostPlatform.isMacOS [
darwin.apple_sdk.frameworks.CoreFoundation
darwin.apple_sdk.frameworks.CoreServices
];
NIX_CFLAGS_COMPILE =
lib.optionals stdenv.cc.isClang [
# Workaround for dtoa.0.3.2
"-Wno-error=unused-command-line-argument"
];
CMAKE_TOOLCHAIN_FILE = writeTextFile {
name = "toolchain.cmake";
text = ''
set(ENABLE_SYSTEM_LOCALE_ARCHIVE ON CACHE BOOL "Use system locale archive as the default LOCALE_ARCHIVE for nix patched glibc" FORCE)
set(CAN_USE_SYSTEM_ZSTD ON CACHE BOOL "Use system zstd" FORCE)
set(HAVE_SYSTEM_TZDATA_PREFIX "${tzdata}/share/zoneinfo" CACHE PATH "The zoneinfo directory" FORCE)
set(HAVE_SYSTEM_TZDATA ON CACHE BOOL "Use system zoneinfo" FORCE)
set(MYSQL_UNIX_SOCK_ADDR "/run/mysqld/mysqld.sock" CACHE FILEPATH "The MySQL unix socket" FORCE)
set(CARGO_EXECUTABLE "${rust}/bin/cargo" CACHE FILEPATH "The nightly cargo" FORCE)
set(RUSTC_EXECUTABLE "${rust}/bin/rustc" CACHE FILEPATH "The nightly rustc" FORCE)
set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL "Enable verbose output from Makefile builds" FORCE)
${
lib.optionalString hostPlatform.isMacOS ''
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Targeting macOS version" FORCE)
''
}
'';
};
prePatch = ''
patchShebangs .
'';
preBuild =
''
set -e
make \
-f third-party/proxygen/CMakeFiles/bundled_proxygen.dir/build.make \
third-party/proxygen/bundled_proxygen-prefix/src/bundled_proxygen-stamp/bundled_proxygen-patch
patchShebangs \
third-party/proxygen/bundled_proxygen-prefix/src/bundled_proxygen
'';
doCheck = true;
checkPhase =
''
set -e
runHook preCheck
export HHVM_BIN="$PWD/hphp/hhvm/hhvm"
(cd ${./.} && "$HHVM_BIN" hphp/test/run.php quick)
runHook postCheck
'';
meta = {
description = "High-performance JIT compiler for PHP/Hack";
platforms = [
"x86_64-darwin"
"x86_64-linux"
];
homepage = "https://hhvm.com";
license = [
lib.licenses.php301
{
spdxId = "Zend-2.0";
fullName = "Zend License v2.0";
url = "https://www.zend.com/sites/zend/files/pdfs/2_00.txt";
}
];
maintainers = [{
email = "[email protected]";
github = "hhvm";
githubId = 4553654;
name = "HHVM/Hack Open Source";
}];
};
}