lol
1{ stdenv, fetchurl, pkgconfig, nspr, perl, python2, zip, libffi
2, enableReadline ? (!stdenv.isDarwin), readline
3, libobjc }:
4
5stdenv.mkDerivation rec {
6 version = "17.0.0";
7 name = "spidermonkey-${version}";
8
9 src = fetchurl {
10 url = "mirror://mozilla/js/mozjs${version}.tar.gz";
11 sha256 = "1fig2wf4f10v43mqx67y68z6h77sy900d1w0pz9qarrqx57rc7ij";
12 };
13
14 outputs = [ "out" "dev" "lib" ];
15
16 propagatedBuildInputs = [ nspr ];
17
18 nativeBuildInputs = [ pkgconfig ];
19 buildInputs = [ perl python2 zip libffi readline ]
20 ++ stdenv.lib.optional enableReadline readline
21 ++ stdenv.lib.optional stdenv.isDarwin libobjc;
22
23 postUnpack = "sourceRoot=\${sourceRoot}/js/src";
24
25 patches = [
26 (fetchurl {
27 name = "jsoptparse-gcc7.patch";
28 url = "https://src.fedoraproject.org/cgit/rpms/mozjs17.git/plain/"
29 + "mozjs17.0.0-gcc7.patch?id=43b846629a299f";
30 sha256 = "17plyaq0jwf9wli4zlgvh4ri3zyk6nj1fiakh3wnd37nsl90raf9";
31 })
32 ];
33 patchFlags = "-p3";
34
35 postPatch = ''
36 # Fixes an issue with version detection under perl 5.22.x
37 sed -i 's/(defined\((@TEMPLATE_FILE)\))/\1/' config/milestone.pl
38 '' + stdenv.lib.optionalString stdenv.isAarch64 ''
39 patch -p1 -d ../.. < ${./aarch64-double-conversion.patch}
40 patch -p1 -d ../.. < ${./aarch64-48bit-va-fix.patch}
41 '';
42
43 preConfigure = ''
44 export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -I${nspr.dev}/include/nspr"
45 export LIBXUL_DIST=$out
46 '';
47
48 setOutputFlags = false;
49 configureFlags = [
50 "--libdir=$(lib)/lib"
51 "--includedir=$(dev)/include"
52 "--enable-threadsafe"
53 "--with-system-nspr"
54 "--with-system-ffi"
55 (if enableReadline then "--enable-readline" else "--disable-readline")
56 ];
57
58 # hack around a make problem, see https://github.com/NixOS/nixpkgs/issues/1279#issuecomment-29547393
59 preBuild = "touch -- {.,shell,jsapi-tests}/{-lpthread,-ldl}";
60
61 enableParallelBuilding = true;
62
63 doCheck = true;
64 preCheck = ''
65 rm jit-test/tests/sunspider/check-date-format-tofte.js # https://bugzil.la/600522
66
67 # Test broken on ARM. Fedora disables it.
68 # https://lists.fedoraproject.org/pipermail/scm-commits/Week-of-Mon-20130617/1041155.html
69 echo -e '#!${stdenv.shell}\nexit 0' > config/find_vanilla_new_calls
70
71 '' + stdenv.lib.optionalString stdenv.isLinux ''
72 paxmark m shell/js17
73 paxmark mr jsapi-tests/jsapi-tests
74 '';
75
76 postInstall = ''
77 rm "$lib"/lib/*.a # halve the output size
78 moveToOutput "bin/js*-config" "$dev" # break the cycle
79 '';
80
81 meta = with stdenv.lib; {
82 description = "Mozilla's JavaScript engine written in C/C++";
83 homepage = https://developer.mozilla.org/en/SpiderMonkey;
84 # TODO: MPL/GPL/LGPL tri-license.
85 maintainers = [ maintainers.goibhniu ];
86 platforms = platforms.unix;
87 };
88}