lol

spidermonkey_78: factor out into a common expression

authored by

Kirill A. Korinsky and committed by
Jan Tojnar
9a99e98e 1573bc92

+47 -142
+2 -137
pkgs/development/interpreters/spidermonkey/78.nix
··· 1 - { lib, stdenv 2 - , fetchurl 3 - , fetchpatch 4 - , autoconf213 5 - , pkg-config 6 - , perl 7 - , python39 8 - , zip 9 - , buildPackages 10 - , which 11 - , readline 12 - , zlib 13 - , icu67 14 - , cargo 15 - , rustc 16 - , rust-cbindgen 17 - , yasm 18 - , nspr 19 - }: 20 - 21 - stdenv.mkDerivation rec { 22 - pname = "spidermonkey"; 1 + import ./common.nix { 23 2 version = "78.15.0"; 24 - 25 - src = fetchurl { 26 - url = "mirror://mozilla/firefox/releases/${version}esr/source/firefox-${version}esr.source.tar.xz"; 27 - sha256 = "0l91cxdc5v9fps79ckb1kid4gw6v5qng1jd9zvaacwaiv628shx4"; 28 - }; 29 - 30 - patches = [ 31 - # Fix build failure on armv7l using Debian patch 32 - # Upstream bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1526653 33 - (fetchpatch { 34 - url = "https://salsa.debian.org/mozilla-team/firefox/commit/fd6847c9416f9eebde636e21d794d25d1be8791d.patch"; 35 - sha256 = "02b7zwm6vxmk61aj79a6m32s1k5sr0hwm3q1j4v6np9jfyd10g1j"; 36 - }) 37 - 38 - # Remove this when updating to 79 - The patches are already applied upstream 39 - # https://bugzilla.mozilla.org/show_bug.cgi?id=1318905 40 - 41 - # Combination of 3 changesets, modified to apply on 78: 42 - # - https://hg.mozilla.org/mozilla-central/rev/06d7e1b6b7e7 43 - # - https://hg.mozilla.org/mozilla-central/rev/ec48f15d085c 44 - # - https://hg.mozilla.org/mozilla-central/rev/6803dda74d33 45 - ./add-riscv64-support.patch 46 - ]; 47 - 48 - outputs = [ "out" "dev" ]; 49 - setOutputFlags = false; # Configure script only understands --includedir 50 - 51 - nativeBuildInputs = [ 52 - autoconf213 53 - cargo 54 - rustc.llvmPackages.llvm # for llvm-objdump 55 - perl 56 - pkg-config 57 - python39 58 - rust-cbindgen 59 - rustc 60 - which 61 - yasm # to buid icu? seems weird 62 - zip 63 - ]; 64 - 65 - buildInputs = [ 66 - icu67 67 - nspr 68 - readline 69 - zlib 70 - ]; 71 - 72 - preConfigure = '' 73 - export CXXFLAGS="-fpermissive" 74 - export LIBXUL_DIST=$out 75 - export PYTHON="${buildPackages.python3.interpreter}" 76 - 77 - # We can't build in js/src/, so create a build dir 78 - mkdir obj 79 - cd obj/ 80 - configureScript=../js/src/configure 81 - ''; 82 - 83 - configureFlags = [ 84 - "--with-system-zlib" 85 - "--with-system-nspr" 86 - "--with-system-icu" 87 - "--with-intl-api" 88 - "--enable-readline" 89 - "--enable-shared-js" 90 - "--disable-jemalloc" 91 - # Fedora and Arch disable optimize, but it doesn't seme to be necessary 92 - # It turns on -O3 which some gcc version had a problem with: 93 - # https://src.fedoraproject.org/rpms/mozjs38/c/761399aba092bcb1299bb4fccfd60f370ab4216e 94 - "--enable-optimize" 95 - "--enable-release" 96 - ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ 97 - # Spidermonkey seems to use different host/build terminology for cross 98 - # compilation here. 99 - "--host=${stdenv.buildPlatform.config}" 100 - "--target=${stdenv.hostPlatform.config}" 101 - ]; 102 - 103 - # mkDerivation by default appends --build/--host to configureFlags when cross compiling 104 - # These defaults are bogus for Spidermonkey - avoid passing them by providing an empty list 105 - configurePlatforms = [ ]; 106 - 107 - depsBuildBuild = [ buildPackages.stdenv.cc ]; 108 - 109 - # cc-rs insists on using -mabi=lp64 (soft-float) for riscv64, 110 - # while we have a double-float toolchain 111 - NIX_CFLAGS_COMPILE = lib.optionalString (with stdenv.hostPlatform; isRiscV && is64bit) "-mabi=lp64d"; 112 - 113 - # Remove unnecessary static lib 114 - preFixup = '' 115 - moveToOutput bin/js78-config "$dev" 116 - rm $out/lib/libjs_static.ajs 117 - ln -s $out/bin/js78 $out/bin/js 118 - ''; 119 - 120 - enableParallelBuilding = true; 121 - 122 - postPatch = '' 123 - # This patch is a manually applied fix of 124 - # https://bugzilla.mozilla.org/show_bug.cgi?id=1644600 125 - # Once that bug is fixed, this can be removed. 126 - # This is needed in, for example, `zeroad`. 127 - substituteInPlace js/public/StructuredClone.h \ 128 - --replace "class SharedArrayRawBufferRefs {" \ 129 - "class JS_PUBLIC_API SharedArrayRawBufferRefs {" 130 - ''; 131 - 132 - meta = with lib; { 133 - description = "Mozilla's JavaScript engine written in C/C++"; 134 - homepage = "https://spidermonkey.dev/"; 135 - license = licenses.gpl2; # TODO: MPL/GPL/LGPL tri-license. 136 - maintainers = with maintainers; [ abbradar lostnet ]; 137 - platforms = platforms.linux; 138 - }; 3 + hash = "sha512-rD3nNbJGzk8OFhnNJmQyH/o3QkDOaEPnhdeaNQ3DDJZ5lrvMXjswHLPYIsqYHL6hFnWPxBIvFzjXXd/RFltjeA==="; 139 4 }
+45 -5
pkgs/development/interpreters/spidermonkey/common.nix
··· 3 3 { lib 4 4 , stdenv 5 5 , fetchurl 6 + , fetchpatch 6 7 7 8 # build time 8 9 , buildPackages ··· 11 12 , perl 12 13 , pkg-config 13 14 , python3 15 + , python39 14 16 , rust-cbindgen 15 17 , rustc 16 18 , which 17 19 , zip 20 + , autoconf213 21 + , yasm 18 22 19 23 # runtime 20 24 , icu 25 + , icu67 21 26 , nspr 22 27 , readline 23 28 , zlib ··· 34 39 inherit hash; 35 40 }; 36 41 42 + patches = lib.optional (lib.versionOlder version "91") [ 43 + # Fix build failure on armv7l using Debian patch 44 + # Upstream bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1526653 45 + (fetchpatch { 46 + url = "https://salsa.debian.org/mozilla-team/firefox/commit/fd6847c9416f9eebde636e21d794d25d1be8791d.patch"; 47 + hash = "sha512-K8U3Qyo7g4si2r/8kJdXyRoTrDHAY48x/YJ7YL+YBwlpfNQcHxX+EZvhRzW8FHYW+f7kOnJu9QykhE8PhSQ9zQ=="; 48 + }) 49 + 50 + # Remove this when updating to 79 - The patches are already applied upstream 51 + # https://bugzilla.mozilla.org/show_bug.cgi?id=1318905 52 + 53 + # Combination of 3 changesets, modified to apply on 78: 54 + # - https://hg.mozilla.org/mozilla-central/rev/06d7e1b6b7e7 55 + # - https://hg.mozilla.org/mozilla-central/rev/ec48f15d085c 56 + # - https://hg.mozilla.org/mozilla-central/rev/6803dda74d33 57 + ./add-riscv64-support.patch 58 + ]; 59 + 37 60 nativeBuildInputs = [ 38 61 cargo 39 62 m4 40 63 perl 41 64 pkg-config 42 - python3 65 + # 78 requires python up to 3.9 66 + (if lib.versionOlder version "91" then python39 else python3) 43 67 rust-cbindgen 44 68 rustc 45 69 rustc.llvmPackages.llvm # for llvm-objdump 46 70 which 47 71 zip 72 + ] ++ lib.optionals (lib.versionOlder version "91") [ 73 + autoconf213 74 + yasm # to buid icu? seems weird 48 75 ]; 49 76 50 77 buildInputs = [ 51 - icu 78 + (if lib.versionOlder version "91" then icu67 else icu) 52 79 nspr 53 80 readline 54 81 zlib ··· 65 92 "--with-system-icu" 66 93 "--with-system-nspr" 67 94 "--with-system-zlib" 95 + # Fedora and Arch disable optimize, but it doesn't seme to be necessary 96 + # It turns on -O3 which some gcc version had a problem with: 97 + # https://src.fedoraproject.org/rpms/mozjs38/c/761399aba092bcb1299bb4fccfd60f370ab4216e 68 98 "--enable-optimize" 69 99 "--enable-readline" 70 100 "--enable-release" 71 101 "--enable-shared-js" 102 + ] ++ lib.optionals (lib.versionAtLeast version "91") [ 72 103 "--disable-debug" 104 + ] ++ [ 73 105 "--disable-jemalloc" 74 106 "--disable-strip" 75 107 "--disable-tests" ··· 86 118 87 119 enableParallelBuilding = true; 88 120 121 + # cc-rs insists on using -mabi=lp64 (soft-float) for riscv64, 122 + # while we have a double-float toolchain 123 + NIX_CFLAGS_COMPILE = lib.optionalString (with stdenv.hostPlatform; isRiscV && is64bit && lib.versionOlder version "91") "-mabi=lp64d"; 124 + 89 125 postPatch = '' 90 126 # This patch is a manually applied fix of 91 127 # https://bugzilla.mozilla.org/show_bug.cgi?id=1644600 ··· 96 132 "class JS_PUBLIC_API SharedArrayRawBufferRefs {" 97 133 ''; 98 134 99 - preConfigure = '' 135 + preConfigure = lib.optionalString (lib.versionOlder version "91") '' 136 + export CXXFLAGS="-fpermissive" 137 + '' + '' 100 138 export LIBXUL_DIST=$out 101 139 export PYTHON="${buildPackages.python3.interpreter}" 140 + '' + lib.optionalString (lib.versionAtLeast version "91") '' 102 141 export M4=m4 103 142 export AWK=awk 104 143 export AC_MACRODIR=$PWD/build/autoconf/ ··· 107 146 sh ../../build/autoconf/autoconf.sh --localdir=$PWD configure.in > configure 108 147 chmod +x configure 109 148 popd 149 + '' + '' 110 150 # We can't build in js/src/, so create a build dir 111 151 mkdir obj 112 152 cd obj/ ··· 123 163 meta = with lib; { 124 164 description = "Mozilla's JavaScript engine written in C/C++"; 125 165 homepage = "https://spidermonkey.dev/"; 126 - license = licenses.mpl20; 127 - maintainers = with maintainers; [ lostnet ]; 166 + license = licenses.mpl20; # TODO: MPL/GPL/LGPL tri-license for 78. 167 + maintainers = with maintainers; [ abbradar lostnet ]; 128 168 platforms = platforms.linux; 129 169 }; 130 170 }