Merge pull request #119126 from fabaff/pycomfoconnect
[NixPkgs.git] / pkgs / development / interpreters / spidermonkey / 68.nix
blob0ac005b07dea9ac61738df010a7e295a3b476b87
1 { lib, stdenv, fetchurl, fetchpatch, autoconf213, pkg-config, perl, python2, python3, zip, buildPackages
2 , which, readline, zlib, icu, cargo, rustc, llvmPackages }:
4 with lib;
6 let
7   python3Env = buildPackages.python3.withPackages (p: [p.six]);
8 in stdenv.mkDerivation rec {
9   pname = "spidermonkey";
10   version = "68.10.0";
12   src = fetchurl {
13     url = "mirror://mozilla/firefox/releases/${version}esr/source/firefox-${version}esr.source.tar.xz";
14     sha256 = "0azdinwqjfv2q37gqpxmfvzsk86pvsi6cjaq1310zs26gric5j1f";
15   };
17   outputs = [ "out" "dev" ];
18   setOutputFlags = false; # Configure script only understands --includedir
20   nativeBuildInputs = [
21     autoconf213
22     pkg-config
23     perl
24     which
25     python2
26     zip
27     cargo
28     rustc
29     llvmPackages.llvm
30   ];
32   buildInputs = [
33     readline
34     zlib
35     icu
36   ];
38   preConfigure = ''
39     export CXXFLAGS="-fpermissive"
40     export LIBXUL_DIST=$out
41     export PYTHON3="${python3Env.interpreter}"
43     # We can't build in js/src/, so create a build dir
44     mkdir obj
45     cd obj/
46     configureScript=../js/src/configure
47   '';
49   configureFlags = [
50     # Reccommended by gjs upstream
51     "--disable-jemalloc"
52     "--enable-unaligned-private-values"
53     "--with-intl-api"
54     "--enable-posix-nspr-emulation"
55     "--with-system-zlib"
56     "--with-system-icu"
58     "--with-libclang-path=${llvmPackages.libclang}/lib"
59     "--with-clang-path=${llvmPackages.clang}/bin/clang"
61     "--enable-shared-js"
62     "--enable-readline"
63     # Fedora and Arch disable optimize, but it doesn't seme to be necessary
64     # It turns on -O3 which some gcc version had a problem with:
65     # https://src.fedoraproject.org/rpms/mozjs38/c/761399aba092bcb1299bb4fccfd60f370ab4216e
66     "--enable-optimize"
67     "--enable-release"
68   ] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
69     # Spidermonkey seems to use different host/build terminology for cross
70     # compilation here.
71     "--host=${stdenv.buildPlatform.config}"
72     "--target=${stdenv.hostPlatform.config}"
73   ];
75   configurePlatforms = [];
77   depsBuildBuild = [ buildPackages.stdenv.cc ];
79   # Remove unnecessary static lib
80   preFixup = ''
81     moveToOutput bin/js60-config "$dev"
82     rm $out/lib/libjs_static.ajs
83     ln -s $out/bin/js60 $out/bin/js
84   '';
86   enableParallelBuilding = true;
88   meta = with lib; {
89     description = "Mozilla's JavaScript engine written in C/C++";
90     homepage = "https://developer.mozilla.org/en/SpiderMonkey";
91     license = licenses.gpl2; # TODO: MPL/GPL/LGPL tri-license.
92     maintainers = [ maintainers.abbradar ];
93     platforms = platforms.linux;
94   };